Merge branch 'scrolled-toolbar' into dev

This commit is contained in:
Hombre 2018-09-05 22:35:26 +02:00
commit 8d3350fa93
5 changed files with 102 additions and 18 deletions

View File

@ -630,7 +630,10 @@ EditorPanel::EditorPanel (FilePanel* filePanel)
beforeAfterBox->set_name ("BeforeAfterContainer");
beforeAfterBox->pack_start (*afterBox);
editbox->pack_start (*toolBarPanel, Gtk::PACK_SHRINK, 2);
MyScrolledToolbar *stb1 = Gtk::manage(new MyScrolledToolbar());
stb1->set_name("EditorToolbarTop");
stb1->add(*toolBarPanel);
editbox->pack_start (*stb1, Gtk::PACK_SHRINK, 2);
editbox->pack_start (*beforeAfterBox);
// build right side panel
@ -763,7 +766,11 @@ EditorPanel::EditorPanel (FilePanel* filePanel)
iops->attach_next_to (*tbShowHideSidePanels, Gtk::POS_RIGHT, 1, 1);
iops->attach_next_to (*tbRightPanel_1, Gtk::POS_RIGHT, 1, 1);
editbox->pack_start (*iops, Gtk::PACK_SHRINK, 0);
MyScrolledToolbar *stb2 = Gtk::manage(new MyScrolledToolbar());
stb2->set_name("EditorToolbarBottom");
stb2->add(*iops);
editbox->pack_start (*stb2, Gtk::PACK_SHRINK, 0);
editbox->show_all ();
// build screen

View File

@ -48,6 +48,7 @@ FileCatalog::FileCatalog (CoarsePanel* cp, ToolBar* tb, FilePanel* filepanel) :
listener(nullptr),
fslistener(nullptr),
iatlistener(nullptr),
hbToolBar1STB(nullptr),
hasValidCurrentEFS(false),
filterPanel(nullptr),
exportPanel(nullptr),
@ -61,7 +62,6 @@ FileCatalog::FileCatalog (CoarsePanel* cp, ToolBar* tb, FilePanel* filepanel) :
inTabMode = false;
set_name ("FileBrowser");
set_spacing (2);
// construct and initialize thumbnail browsers
fileBrowser = Gtk::manage( new FileBrowser() );
@ -127,13 +127,19 @@ FileCatalog::FileCatalog (CoarsePanel* cp, ToolBar* tb, FilePanel* filepanel) :
// if NOT a single row toolbar
if (!options.FileBrowserToolbarSingleRow) {
pack_start (*hbToolBar1, Gtk::PACK_SHRINK, 0);
hbToolBar1STB = Gtk::manage(new MyScrolledToolbar());
hbToolBar1STB->set_name("FileBrowserQueryToolbar");
hbToolBar1STB->add(*hbToolBar1);
pack_start (*hbToolBar1STB, Gtk::PACK_SHRINK, 0);
}
// setup button bar
buttonBar = Gtk::manage( new Gtk::HBox () );
buttonBar->set_name ("ToolBarPanelFileBrowser");
pack_start (*buttonBar, Gtk::PACK_SHRINK);
MyScrolledToolbar *stb = Gtk::manage(new MyScrolledToolbar());
stb->set_name("FileBrowserIconToolbar");
stb->add(*buttonBar);
pack_start (*stb, Gtk::PACK_SHRINK);
tbLeftPanel_1 = new Gtk::ToggleButton ();
iLeftPanel_1_Show = new RTImage("panel-to-right.png");
@ -692,6 +698,9 @@ void FileCatalog::enableTabMode(bool enable)
} else {
buttonBar->show();
hbToolBar1->show();
if (hbToolBar1STB) {
hbToolBar1STB->show();
}
exifInfo->set_active( options.showFileNames );
}
@ -910,8 +919,8 @@ void FileCatalog::refreshHeight ()
newHeight = h;
}
if (hbToolBar1->is_visible() && !options.FileBrowserToolbarSingleRow) {
newHeight += hbToolBar1->get_height();
if (hbToolBar1STB && hbToolBar1STB->is_visible()) {
newHeight += hbToolBar1STB->get_height();
}
if (buttonBar->is_visible()) {
@ -2039,17 +2048,21 @@ void FileCatalog::updateFBQueryTB (bool singleRow)
hbToolBar1->reference();
if (singleRow) {
bool removed = removeIfThere(this, hbToolBar1, false);
if (removed) {
if (hbToolBar1STB) {
hbToolBar1STB->remove_with_viewport();
removeIfThere(this, hbToolBar1STB, false);
buttonBar->pack_start(*hbToolBar1, Gtk::PACK_EXPAND_WIDGET, 0);
hbToolBar1STB = nullptr;
}
} else {
bool removed = removeIfThere(buttonBar, hbToolBar1, false);
if (removed) {
pack_start(*hbToolBar1, Gtk::PACK_SHRINK, 0);
reorder_child(*hbToolBar1, 0);
if (!hbToolBar1STB) {
removeIfThere(buttonBar, hbToolBar1, false);
hbToolBar1STB = Gtk::manage(new MyScrolledToolbar());
hbToolBar1STB->set_name("FileBrowserQueryToolbar");
hbToolBar1STB->add(*hbToolBar1);
hbToolBar1STB->show();
pack_start (*hbToolBar1STB, Gtk::PACK_SHRINK, 0);
reorder_child(*hbToolBar1STB, 0);
}
}
@ -2592,7 +2605,7 @@ bool FileCatalog::handleShortcutKey (GdkEventKey* event)
void FileCatalog::showToolBar()
{
if (!options.FileBrowserToolbarSingleRow) {
hbToolBar1->show();
hbToolBar1STB->show();
}
buttonBar->show();
@ -2601,7 +2614,7 @@ void FileCatalog::showToolBar()
void FileCatalog::hideToolBar()
{
if (!options.FileBrowserToolbarSingleRow) {
hbToolBar1->hide();
hbToolBar1STB->hide();
}
buttonBar->hide();

View File

@ -73,6 +73,7 @@ private:
Gtk::HBox* buttonBar;
Gtk::HBox* hbToolBar1;
MyScrolledToolbar* hbToolBar1STB;
Gtk::HBox* fltrRankbox;
Gtk::HBox* fltrLabelbox;

View File

@ -955,7 +955,7 @@ bool MyScrolledWindow::on_scroll_event (GdkEventScroll* event)
if (value2 != value) {
scroll->set_value(value2);
}
} else {
} else if (event->direction == GDK_SCROLL_UP) {
value2 = value - step;
if (value2 < lower) {
@ -981,6 +981,57 @@ void MyScrolledWindow::get_preferred_height_for_width_vfunc (int width, int &min
natural_height = minimum_height = 50;
}
/*
*
* Derived class of some widgets to properly handle the scroll wheel ;
* the user has to use the Shift key to be able to change the widget's value,
* otherwise the mouse wheel will scroll the toolbar.
*
*/
MyScrolledToolbar::MyScrolledToolbar ()
{
set_policy (Gtk::POLICY_EXTERNAL, Gtk::POLICY_NEVER);
set_propagate_natural_height(true);
get_style_context()->add_class("scrollableToolbar");
}
bool MyScrolledToolbar::on_scroll_event (GdkEventScroll* event)
{
Glib::RefPtr<Gtk::Adjustment> adjust = get_hadjustment();
Gtk::Scrollbar *scroll = get_hscrollbar();
if (adjust && scroll) {
double upper = adjust->get_upper();
double lower = adjust->get_lower();
double value = adjust->get_value();
double step = adjust->get_step_increment() * 2;
double value2 = 0.;
if (event->direction == GDK_SCROLL_DOWN) {
value2 = rtengine::min<double>(value + step, upper);
if (value2 != value) {
scroll->set_value(value2);
}
} else if (event->direction == GDK_SCROLL_UP) {
value2 = rtengine::max<double>(value - step, lower);
if (value2 != value) {
scroll->set_value(value2);
}
} else if (event->direction == GDK_SCROLL_SMOOTH) {
if (event->delta_x) { // if the user use a pad, it can scroll horizontally
value2 = rtengine::LIM<double>(value + (event->delta_x > 0 ? 30 : -30), lower, upper);
} else if (event->delta_y) {
value2 = rtengine::LIM<double>(value + (event->delta_y > 0 ? 30 : -30), lower, upper);
}
if (value2 != value) {
scroll->set_value(value2);
}
}
}
return true;
}
MyComboBoxText::MyComboBoxText (bool has_entry) : Gtk::ComboBoxText(has_entry)
{
minimumWidth = naturalWidth = 70;

View File

@ -293,6 +293,18 @@ public:
MyScrolledWindow();
};
/**
* @brief subclass of Gtk::ScrolledWindow in order to handle the large toolbars (wider than available space)
*/
class MyScrolledToolbar : public Gtk::ScrolledWindow
{
bool on_scroll_event (GdkEventScroll* event);
public:
MyScrolledToolbar();
};
/**
* @brief subclass of Gtk::ComboBox in order to handle the scrollwheel
*/