mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 06:44:57 +01:00
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
2 changed files with 13 additions and 7 deletions
|
|
@ -30,9 +30,10 @@
|
|||
#include "widgets/slider_controller.h"
|
||||
|
||||
#include "stripable_colorpicker.h"
|
||||
#include "ardour_dialog.h"
|
||||
#include "luadialog.h"
|
||||
#include "public_editor.h"
|
||||
#include "splash.h"
|
||||
#include "ui_config.h"
|
||||
#include "utils.h"
|
||||
|
||||
using namespace LuaDialog;
|
||||
|
|
@ -763,7 +764,7 @@ Dialog::Dialog (std::string const& title, luabridge::LuaRef lr)
|
|||
Gtk::Table* table = Gtk::manage (new Gtk::Table ());
|
||||
table->set_col_spacings (20);
|
||||
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_border_width(0);
|
||||
|
|
@ -833,12 +834,15 @@ Dialog::run (lua_State *L)
|
|||
}
|
||||
|
||||
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 */
|
||||
if (allocation.get_height () > 512) {
|
||||
int h = Gtkmm2ext::physical_screen_height (PublicEditor::instance ().current_toplevel()->get_window());
|
||||
|
||||
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);
|
||||
_ad.set_size_request (-1, 512);
|
||||
_ad.set_size_request (-1, max_height);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,11 +20,13 @@
|
|||
#define _gtk2ardour_luadialog_h_
|
||||
|
||||
#include <cassert>
|
||||
#include <gtkmm/scrolledwindow.h>
|
||||
#include <gtkmm/table.h>
|
||||
#include <gtkmm/progressbar.h>
|
||||
|
||||
#include "LuaBridge/LuaBridge.h"
|
||||
|
||||
#include "ardour_dialog.h"
|
||||
#include "ardour_message.h"
|
||||
|
||||
namespace LuaDialog {
|
||||
|
|
@ -91,7 +93,7 @@ public:
|
|||
|
||||
private:
|
||||
Dialog (Dialog const&); // prevent copy construction
|
||||
void table_size_alloc (Gtk::Allocation&);
|
||||
void table_size_request (Gtk::Requisition*);
|
||||
|
||||
ArdourDialog _ad;
|
||||
Gtk::ScrolledWindow _scroller;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue