From 05f70a7a9949a65d0aef84f6becc1f7124977ef1 Mon Sep 17 00:00:00 2001 From: Hombre Date: Sat, 2 Oct 2010 22:24:32 +0200 Subject: [PATCH] Left and right panels of the directory browser and the editor tab now remember theire position when RT is restarted. When a new editor tab opens, it remember the last width value. Morever, if you change the width if the left or right panel in one editor tab, it does propagate in all the others. Those values are stored in the options file. This is not related to the automatic grow of the window when an editor opens (not solved yet). To avoid having too wide windows at the first start, the font of all styles are now "sans 10". --- rtdata/options/options.lin | 4 +-- rtdata/options/options.osx | 4 +-- rtdata/options/options.win | 4 +-- rtdata/themes/ClearLooks (Dark Orange) | 1 + rtdata/themes/Dark | 2 +- rtdata/themes/Default | 2 +- rtdata/themes/Gray | 2 +- rtdata/themes/Gray Textured | 2 +- rtdata/themes/Light | 2 +- rtgui/editorpanel.cc | 43 +++++++++++++++++++++++--- rtgui/editorpanel.h | 6 +++- rtgui/filepanel.cc | 28 +++++++++++------ rtgui/filepanel.h | 2 ++ rtgui/options.cc | 21 +++++++------ rtgui/options.h | 1 + rtgui/rtwindow.cc | 32 +++++++++++++++---- rtgui/rtwindow.h | 4 ++- 17 files changed, 118 insertions(+), 42 deletions(-) diff --git a/rtdata/options/options.lin b/rtdata/options/options.lin index e02431966..aa64fe988 100644 --- a/rtdata/options/options.lin +++ b/rtdata/options/options.lin @@ -65,8 +65,8 @@ SaveParamsToCache=true LoadParamsFromLocation=0 [GUI] -WindowWidth=1000 -WindowHeight=900 +WindowWidth=900 +WindowHeight=560 WindowMaximized=false FileBrowserHeight=250 ToolPanelWidth=300 diff --git a/rtdata/options/options.osx b/rtdata/options/options.osx index 005fd0064..a7c5e6ec3 100644 --- a/rtdata/options/options.osx +++ b/rtdata/options/options.osx @@ -65,8 +65,8 @@ SaveParamsToCache=true LoadParamsFromLocation=0 [GUI] -WindowWidth=1000 -WindowHeight=900 +WindowWidth=900 +WindowHeight=560 WindowMaximized=false FileBrowserHeight=250 ToolPanelWidth=300 diff --git a/rtdata/options/options.win b/rtdata/options/options.win index 9975d8e34..f589ba814 100644 --- a/rtdata/options/options.win +++ b/rtdata/options/options.win @@ -65,8 +65,8 @@ SaveParamsToCache=true LoadParamsFromLocation=0 [GUI] -WindowWidth=1000 -WindowHeight=900 +WindowWidth=900 +WindowHeight=560 WindowMaximized=false FileBrowserHeight=250 ToolPanelWidth=300 diff --git a/rtdata/themes/ClearLooks (Dark Orange) b/rtdata/themes/ClearLooks (Dark Orange) index 74f839aed..dc86995e6 100644 --- a/rtdata/themes/ClearLooks (Dark Orange) +++ b/rtdata/themes/ClearLooks (Dark Orange) @@ -23,6 +23,7 @@ style "clearlooks-default" { + font_name = "sans 8" GtkMenuItem::selected_shadow_type = none GtkWidget::interior_focus = 1 GtkButton::default_border = { 3, 3, 3, 3 } diff --git a/rtdata/themes/Dark b/rtdata/themes/Dark index 11e332b29..3d1d6dded 100644 --- a/rtdata/themes/Dark +++ b/rtdata/themes/Dark @@ -26,7 +26,7 @@ style "clearlooks-default" { - font_name = "tahoma 8" + font_name = "sans 8" GtkButton ::default_border = { 0, 0, 0, 0 } GtkComboBox ::default_border = { 0, 0, 0, 0 } GtkRange ::trough_border = 0 diff --git a/rtdata/themes/Default b/rtdata/themes/Default index 9693e0ba5..600eeefa2 100644 --- a/rtdata/themes/Default +++ b/rtdata/themes/Default @@ -26,7 +26,7 @@ style "clearlooks-default" { -font_name = "tahoma 8" + font_name = "sans 8" GtkButton ::default_border = { 0, 0, 0, 0 } GtkRange ::trough_border = 0 GtkPaned ::handle_size = 6 diff --git a/rtdata/themes/Gray b/rtdata/themes/Gray index 12e794db5..9a5cf0170 100644 --- a/rtdata/themes/Gray +++ b/rtdata/themes/Gray @@ -19,7 +19,7 @@ style "theme-default" { - font_name = "tahoma 12" + font_name = "sans 8" GtkButton ::default_border = { 0, 0, 0, 0 } GtkRange ::trough_border = 1 diff --git a/rtdata/themes/Gray Textured b/rtdata/themes/Gray Textured index 1576fcba2..fd73ba43c 100644 --- a/rtdata/themes/Gray Textured +++ b/rtdata/themes/Gray Textured @@ -32,7 +32,7 @@ style "clearlooks-default" # change it to use an actual font, enter the full name of the font # here, along with optional style and size, e.g. # "Monaco Bold 15". - font_name = "Default" + font_name = "sans 8" GtkRange::trough_border = 0 GtkRange::slider_width = 14 diff --git a/rtdata/themes/Light b/rtdata/themes/Light index 92064a2a2..05e7d6621 100644 --- a/rtdata/themes/Light +++ b/rtdata/themes/Light @@ -23,7 +23,7 @@ style "clearlooks-default" { -font_name = "sans 8" + font_name = "sans 8" GtkButton ::default_border = { 0, 0, 0, 0 } GtkRange ::trough_border = 0 GtkPaned ::handle_size = 6 diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index 4b5ace20c..53fdff755 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -192,7 +192,8 @@ EditorPanel::EditorPanel () : beforePreviewHandler(NULL), beforeIarea(NULL), par hpanedr->pack1(*hpanedl, true, true); hpanedr->pack2(*vboxright, false, true); - //hpanedr->set_position(options.toolPanelWidth); + hpanedl->signal_button_release_event().connect_notify( sigc::mem_fun(*this, &EditorPanel::leftPaneButtonReleased) ); + hpanedr->signal_button_release_event().connect_notify( sigc::mem_fun(*this, &EditorPanel::rightPaneButtonReleased) ); pack_start (*hpanedr); show_all (); @@ -263,6 +264,40 @@ EditorPanel::~EditorPanel () { delete saveAsDialog; } +void EditorPanel::leftPaneButtonReleased(GdkEventButton *event) { + if (event->button == 1) { + // Button 1 released : it's a resize + options.historyPanelWidth = hpanedl->get_position(); + } + /*else if (event->button == 3) { + }*/ +} + +void EditorPanel::rightPaneButtonReleased(GdkEventButton *event) { + if (event->button == 1) { + int winW, winH; + parent->get_size(winW, winH); + // Button 1 released : it's a resize + options.toolPanelWidth = winW - hpanedr->get_position(); + } + /*else if (event->button == 3) { + }*/ +} + +void EditorPanel::setAspect () { + int winW, winH; + parent->get_size(winW, winH); + hpanedl->set_position(options.historyPanelWidth); + hpanedr->set_position(winW - options.toolPanelWidth); +} + +void EditorPanel::on_realize () { + + Gtk::VBox::on_realize (); + // This line is needed to avoid autoexpansion of the window :-/ + vboxright->set_size_request (options.toolPanelWidth, -1); +} + void EditorPanel::open (Thumbnail* tmb, rtengine::InitialImage* isrc) { // initialize everything @@ -849,12 +884,10 @@ bool EditorPanel::idle_sentToGimp(ProgressConnector *pc,rtengine::IImage16* return false; } +/* void EditorPanel::saveOptions () { - - //options.historyPanelWidth = hpanedl->get_position ();//older code - //options.toolPanelWidth = vboxright->get_width ();//older code - //options.toolPanelWidth = hpanedr->get_position ();//Hombre's change which screws up OSX build } +*/ void EditorPanel::historyBeforeLineChanged (const rtengine::procparams::ProcParams& params) { diff --git a/rtgui/editorpanel.h b/rtgui/editorpanel.h index 2b9d3394e..d870a7c33 100644 --- a/rtgui/editorpanel.h +++ b/rtgui/editorpanel.h @@ -104,6 +104,10 @@ class EditorPanel : public Gtk::VBox, virtual ~EditorPanel (); void open (Thumbnail* tmb, rtengine::InitialImage* isrc); + void setAspect (); + void on_realize (); + void leftPaneButtonReleased(GdkEventButton *event); + void rightPaneButtonReleased(GdkEventButton *event); void setParent (RTWindow* p) { parent = p; } @@ -138,7 +142,7 @@ class EditorPanel : public Gtk::VBox, Glib::ustring getFileName (); bool handleShortcutKey (GdkEventKey* event); - void saveOptions (); + //void saveOptions (); }; #endif diff --git a/rtgui/filepanel.cc b/rtgui/filepanel.cc index 43349670b..224c0459d 100644 --- a/rtgui/filepanel.cc +++ b/rtgui/filepanel.cc @@ -47,7 +47,7 @@ FilePanel::FilePanel () : parent(NULL) { placespaned->pack1 (*placesBrowser, false, true); placespaned->pack2 (*obox, true, true); - dirpaned->pack1 (*placespaned, true, true); + dirpaned->pack1 (*placespaned, false, true); tpc = new BatchToolPanelCoordinator (this); fileCatalog = new FileCatalog (tpc->coarse, tpc->getToolBar()); @@ -88,8 +88,8 @@ FilePanel::FilePanel () : parent(NULL) { Gtk::Label* tagLab = new Gtk::Label (M("MAIN_TAB_TAGGING")); tagLab->set_angle (90); - Gtk::VPaned* tpcPaned = new Gtk::VPaned (); - tpcPaned->pack1 (*tpc->toolPanelNotebook, true, true); + tpcPaned = new Gtk::VPaned (); + tpcPaned->pack1 (*tpc->toolPanelNotebook, false, true); tpcPaned->pack2 (*history, true, true); rightNotebook->append_page (*tpcPaned, *devLab); @@ -99,9 +99,7 @@ FilePanel::FilePanel () : parent(NULL) { rightBox->pack_start (*rightNotebook); pack1(*dirpaned, true, true); - pack2(*rightBox, true, true); - - //set_position(options.browserToolPanelWidth);////Hombre's change which screws up OSX build + pack2(*rightBox, false, true); fileCatalog->setFileSelectionChangeListener (tpc); @@ -111,6 +109,15 @@ FilePanel::FilePanel () : parent(NULL) { show_all (); } +void FilePanel::setAspect () { + int winW, winH; + parent->get_size(winW, winH); + placespaned->set_position(options.dirBrowserHeight); + dirpaned->set_position(options.dirBrowserWidth); + tpcPaned->set_position(options.browserToolPanelHeight); + set_position(winW - options.browserToolPanelWidth); +} + void FilePanel::init () { dirBrowser->fillDirTree (); @@ -161,9 +168,12 @@ bool FilePanel::imageLoaded( Thumbnail* thm, ProgressConnectorget_position (); - //options.dirBrowserHeight = placespaned->get_position (); - //options.browserToolPanelWidth = get_position(); + int winW, winH; + parent->get_size(winW, winH); + options.dirBrowserWidth = dirpaned->get_position (); + options.dirBrowserHeight = placespaned->get_position (); + options.browserToolPanelWidth = winW - get_position(); + options.browserToolPanelHeight = tpcPaned->get_position (); if (options.startupDir==STARTUPDIR_LAST && fileCatalog->lastSelectedDir ()!="") options.startupPath = fileCatalog->lastSelectedDir (); fileCatalog->closeDir (); diff --git a/rtgui/filepanel.h b/rtgui/filepanel.h index 9dff610be..bfdf38cf4 100644 --- a/rtgui/filepanel.h +++ b/rtgui/filepanel.h @@ -45,6 +45,7 @@ class FilePanel : public Gtk::HPaned, RecentBrowser* recentBrowser; FileCatalog* fileCatalog; // filecatalog is the file browser with the button bar above it Gtk::HBox* rightBox; + Gtk::VPaned* tpcPaned; BatchToolPanelCoordinator* tpc; History* history; FilterPanel* filterPanel; @@ -58,6 +59,7 @@ class FilePanel : public Gtk::HPaned, void setParent (RTWindow* p) { parent = p; } void init (); // dont call it directly, the constructor calls it as idle source + void setAspect(); void open (const Glib::ustring& d); // open a file or a directory void refreshEditedState (const std::set& efiles) { fileCatalog->refreshEditedState (efiles); } diff --git a/rtgui/options.cc b/rtgui/options.cc index fcf9efd79..dd919e15c 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -38,8 +38,8 @@ const char *DefaultLanguage = "English (US)"; void Options::setDefaults () { - windowWidth = 1000; - windowHeight = 600; + windowWidth = 900; + windowHeight = 560; windowMaximized = false; firstRun = true; savesParamsAtExit = true; @@ -50,7 +50,7 @@ void Options::setDefaults () { saveFormat.tiffBits = 8; saveFormat.tiffUncompressed = true; saveFormat.saveParams = false; - savePathTemplate = "\%p1/converted/\%f"; + savePathTemplate = "%p1/converted/%f"; savePathFolder = ""; saveUsePathTemplate = true; defProfRaw = "default"; @@ -63,6 +63,7 @@ void Options::setDefaults () { dirBrowserHeight = 150; toolPanelWidth = 300; browserToolPanelWidth = 300; + browserToolPanelHeight = 300; historyPanelWidth = 150; lastScale = 4; lastCropSize = 1; @@ -246,12 +247,13 @@ if (keyFile.has_group ("GUI")) { if (keyFile.has_key ("GUI", "WindowWidth")) windowWidth = keyFile.get_integer ("GUI", "WindowWidth"); if (keyFile.has_key ("GUI", "WindowHeight")) windowHeight = keyFile.get_integer ("GUI", "WindowHeight"); if (keyFile.has_key ("GUI", "WindowMaximized")) windowMaximized = keyFile.get_boolean ("GUI", "WindowMaximized"); - if (keyFile.has_key ("GUI", "DirBrowserWidth")) dirBrowserWidth = keyFile.get_integer ("GUI", "DirBrowserWidth"); - if (keyFile.has_key ("GUI", "DirBrowserHeight")) dirBrowserHeight = keyFile.get_integer ("GUI", "DirBrowserHeight"); - if (keyFile.has_key ("GUI", "SaveAsDialogWidth")) saveAsDialogWidth = keyFile.get_integer ("GUI", "SaveAsDialogWidth"); - if (keyFile.has_key ("GUI", "SaveAsDialogHeight")) saveAsDialogHeight = keyFile.get_integer ("GUI", "SaveAsDialogHeight"); - if (keyFile.has_key ("GUI", "ToolPanelWidth")) toolPanelWidth = keyFile.get_integer ("GUI", "ToolPanelWidth"); - if (keyFile.has_key ("GUI", "BrowserToolPanelWidth"))browserToolPanelWidth = keyFile.get_integer ("GUI", "BrowserToolPanelWidth"); + if (keyFile.has_key ("GUI", "DirBrowserWidth")) dirBrowserWidth = keyFile.get_integer ("GUI", "DirBrowserWidth"); + if (keyFile.has_key ("GUI", "DirBrowserHeight")) dirBrowserHeight = keyFile.get_integer ("GUI", "DirBrowserHeight"); + if (keyFile.has_key ("GUI", "SaveAsDialogWidth")) saveAsDialogWidth = keyFile.get_integer ("GUI", "SaveAsDialogWidth"); + if (keyFile.has_key ("GUI", "SaveAsDialogHeight")) saveAsDialogHeight = keyFile.get_integer ("GUI", "SaveAsDialogHeight"); + if (keyFile.has_key ("GUI", "ToolPanelWidth")) toolPanelWidth = keyFile.get_integer ("GUI", "ToolPanelWidth"); + if (keyFile.has_key ("GUI", "BrowserToolPanelWidth"))browserToolPanelWidth = keyFile.get_integer ("GUI", "BrowserToolPanelWidth"); + if (keyFile.has_key ("GUI", "BrowserToolPanelHeight"))browserToolPanelHeight = keyFile.get_integer ("GUI", "BrowserToolPanelHeight"); if (keyFile.has_key ("GUI", "HistoryPanelWidth")) historyPanelWidth = keyFile.get_integer ("GUI", "HistoryPanelWidth"); if (keyFile.has_key ("GUI", "LastPreviewScale")) lastScale = keyFile.get_integer ("GUI", "LastPreviewScale"); if (keyFile.has_key ("GUI", "LastCropSize")) lastCropSize = keyFile.get_integer ("GUI", "LastCropSize"); @@ -381,6 +383,7 @@ int Options::saveToFile (Glib::ustring fname) { keyFile.set_integer ("GUI", "SaveAsDialogHeight", saveAsDialogHeight); keyFile.set_integer ("GUI", "ToolPanelWidth", toolPanelWidth); keyFile.set_integer ("GUI", "BrowserToolPanelWidth", browserToolPanelWidth); + keyFile.set_integer ("GUI", "BrowserToolPanelHeight", browserToolPanelHeight); keyFile.set_integer ("GUI", "HistoryPanelWidth", historyPanelWidth); keyFile.set_integer ("GUI", "LastPreviewScale", lastScale); keyFile.set_integer ("GUI", "LastCropSize", lastCropSize); diff --git a/rtgui/options.h b/rtgui/options.h index b0a929adc..8ae2c9bd3 100644 --- a/rtgui/options.h +++ b/rtgui/options.h @@ -66,6 +66,7 @@ class Options { int saveAsDialogHeight; int toolPanelWidth; int browserToolPanelWidth; + int browserToolPanelHeight; int historyPanelWidth; int windowWidth; int windowHeight; diff --git a/rtgui/rtwindow.cc b/rtgui/rtwindow.cc index 37e619dcd..0fd85a304 100644 --- a/rtgui/rtwindow.cc +++ b/rtgui/rtwindow.cc @@ -47,6 +47,7 @@ RTWindow::RTWindow () { mainNB = Gtk::manage (new Gtk::Notebook ()); mainNB->set_scrollable (true); + mainNB->signal_switch_page().connect_notify( sigc::mem_fun(*this, &RTWindow::on_mainNB_switch_page) ); fpanel = new FilePanel (); fpanel->setParent (this); @@ -108,9 +109,30 @@ void RTWindow::on_realize () { Gtk::Window::on_realize (); + fpanel->setAspect(); + cursorManager.init (get_window()); } +bool RTWindow::on_my_window_state_event(GdkEventWindowState* event) { + if (!event->new_window_state) { + // Window mode + options.windowMaximized = false; + } + else if (event->new_window_state & (GDK_WINDOW_STATE_MAXIMIZED|GDK_WINDOW_STATE_FULLSCREEN)) { + // Fullscreen mode + options.windowMaximized = true; + } + return true; +} + +void RTWindow::on_mainNB_switch_page(GtkNotebookPage* page, guint page_num) { + if (page_num > 1) { + EditorPanel *ep = (EditorPanel *)mainNB->get_nth_page(page_num); + ep->setAspect(); + } +} + void RTWindow::addEditorPanel (EditorPanel* ep, const std::string &name) { ep->setParent (this); @@ -133,7 +155,9 @@ void RTWindow::addEditorPanel (EditorPanel* ep, const std::string &name) { hb->pack_end (*closeb); hb->set_spacing (2); hb->show_all (); + mainNB->append_page (*ep, *hb); + //ep->setAspect (); mainNB->set_current_page (mainNB->page_num (*ep)); mainNB->set_tab_reorderable (*ep, true); @@ -144,7 +168,7 @@ void RTWindow::addEditorPanel (EditorPanel* ep, const std::string &name) { void RTWindow::remEditorPanel (EditorPanel* ep) { - ep->saveOptions (); + //ep->saveOptions (); epanels.erase (ep->getFileName()); filesEdited.erase (ep->getFileName ()); fpanel->refreshEditedState (filesEdited); @@ -222,14 +246,10 @@ bool RTWindow::on_delete_event(GdkEventAny* event) { options.fbArrangement = fileBrowser->getFileCatalog()->getArrangement (); options.firstRun = false; */ - Gdk::WindowState state = get_window()->get_state(); - if (!(state & (Gdk::WINDOW_STATE_MAXIMIZED | Gdk::WINDOW_STATE_FULLSCREEN))) { + if (!options.windowMaximized) { options.windowWidth = get_width(); options.windowHeight = get_height(); - options.windowMaximized = false; } - else - options.windowMaximized = true; Options::save (); hide(); diff --git a/rtgui/rtwindow.h b/rtgui/rtwindow.h index 6ec0b1114..aa0db4048 100644 --- a/rtgui/rtwindow.h +++ b/rtgui/rtwindow.h @@ -52,7 +52,9 @@ class RTWindow : public Gtk::Window, public rtengine::ProgressListener{ bool keyPressed (GdkEventKey* event); bool on_delete_event(GdkEventAny* event); - + bool on_my_window_state_event(GdkEventWindowState* event); + void on_mainNB_switch_page(GtkNotebookPage* page, guint page_num); + void imageDeveloped (Glib::ustring fname); // called by the batchqueue when it finishes an image void showPreferences (); void on_realize ();