Update scroll-window policy of Lua dialog windows
Better version of 817fccb3e5
, the visibility should not depend
on the number of items in the dialog, but its requested height
vs screen height.
The main use-case is to not show the scroll-bar if the dialog has only
a few rows. Then again if the scrollbar is visible, the dialog
should not shrink below a reasonable min. height.
This commit is contained in:
parent
2cef35247c
commit
5db59b9fd6
@ -30,9 +30,10 @@
|
|||||||
#include "widgets/slider_controller.h"
|
#include "widgets/slider_controller.h"
|
||||||
|
|
||||||
#include "stripable_colorpicker.h"
|
#include "stripable_colorpicker.h"
|
||||||
#include "ardour_dialog.h"
|
|
||||||
#include "luadialog.h"
|
#include "luadialog.h"
|
||||||
|
#include "public_editor.h"
|
||||||
#include "splash.h"
|
#include "splash.h"
|
||||||
|
#include "ui_config.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
using namespace LuaDialog;
|
using namespace LuaDialog;
|
||||||
@ -763,7 +764,7 @@ Dialog::Dialog (std::string const& title, luabridge::LuaRef lr)
|
|||||||
Gtk::Table* table = Gtk::manage (new Gtk::Table ());
|
Gtk::Table* table = Gtk::manage (new Gtk::Table ());
|
||||||
table->set_col_spacings (20);
|
table->set_col_spacings (20);
|
||||||
table->set_row_spacings (8);
|
table->set_row_spacings (8);
|
||||||
table->signal_size_allocate ().connect (sigc::mem_fun (this, &Dialog::table_size_alloc));
|
table->signal_size_request ().connect (sigc::mem_fun (this, &Dialog::table_size_request));
|
||||||
|
|
||||||
_scroller.set_shadow_type(Gtk::SHADOW_NONE);
|
_scroller.set_shadow_type(Gtk::SHADOW_NONE);
|
||||||
_scroller.set_border_width(0);
|
_scroller.set_border_width(0);
|
||||||
@ -833,12 +834,15 @@ Dialog::run (lua_State *L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Dialog::table_size_alloc (Gtk::Allocation& allocation)
|
Dialog::table_size_request (Gtk::Requisition* req)
|
||||||
{
|
{
|
||||||
/* XXX: consider using 0.75 * screen-height instead of 512 */
|
int h = Gtkmm2ext::physical_screen_height (PublicEditor::instance ().current_toplevel()->get_window());
|
||||||
if (allocation.get_height () > 512) {
|
|
||||||
|
int max_height = std::max (400., std::min (768.0 * UIConfiguration::instance().get_ui_scale(), h * .7));
|
||||||
|
|
||||||
|
if (req->height > max_height) {
|
||||||
_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
|
_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
|
||||||
_ad.set_size_request (-1, 512);
|
_ad.set_size_request (-1, max_height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,11 +20,13 @@
|
|||||||
#define _gtk2ardour_luadialog_h_
|
#define _gtk2ardour_luadialog_h_
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <gtkmm/scrolledwindow.h>
|
||||||
#include <gtkmm/table.h>
|
#include <gtkmm/table.h>
|
||||||
#include <gtkmm/progressbar.h>
|
#include <gtkmm/progressbar.h>
|
||||||
|
|
||||||
#include "LuaBridge/LuaBridge.h"
|
#include "LuaBridge/LuaBridge.h"
|
||||||
|
|
||||||
|
#include "ardour_dialog.h"
|
||||||
#include "ardour_message.h"
|
#include "ardour_message.h"
|
||||||
|
|
||||||
namespace LuaDialog {
|
namespace LuaDialog {
|
||||||
@ -91,7 +93,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Dialog (Dialog const&); // prevent copy construction
|
Dialog (Dialog const&); // prevent copy construction
|
||||||
void table_size_alloc (Gtk::Allocation&);
|
void table_size_request (Gtk::Requisition*);
|
||||||
|
|
||||||
ArdourDialog _ad;
|
ArdourDialog _ad;
|
||||||
Gtk::ScrolledWindow _scroller;
|
Gtk::ScrolledWindow _scroller;
|
||||||
|
Loading…
Reference in New Issue
Block a user