resize all editor comboboxes when DPI is reset. involved a minor refactoring of some...
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 30 Dec 2010 21:15:51 +0000 (21:15 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 30 Dec 2010 21:15:51 +0000 (21:15 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@8398 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/utils.h
libs/gtkmm2ext/utils.cc

index b7566a89192a61b3ad9eb7690d89f1de45b56770..ab6c171411931bb562205075353b3d5c466311b6 100644 (file)
@@ -2683,7 +2683,6 @@ Editor::setup_toolbar ()
        mouse_mode_button_box->pack_start (mouse_audition_button);
        mouse_mode_button_box->pack_start (internal_edit_button);
 
-       vector<string> edit_mode_strings;
        edit_mode_strings.push_back (edit_mode_to_string (Slide));
        if (!Profile->get_sae()) {
                edit_mode_strings.push_back (edit_mode_to_string (Splice));
@@ -2866,6 +2865,8 @@ Editor::setup_toolbar ()
        toolbar_frame.set_shadow_type (SHADOW_OUT);
        toolbar_frame.set_name ("BaseFrame");
        toolbar_frame.add (toolbar_base);
+        
+        DPIReset.connect (sigc::mem_fun (*this, &Editor::resize_text_widgets));
 }
 
 void
@@ -3299,7 +3300,11 @@ Editor::cycle_edit_mode ()
 void
 Editor::edit_mode_selection_done ()
 {
-       Config->set_edit_mode (string_to_edit_mode (edit_mode_selector.get_active_text ()));
+        string s = edit_mode_selector.get_active_text ();
+
+        if (!s.empty()) {
+                Config->set_edit_mode (string_to_edit_mode (s));
+        }
 }
 
 void
@@ -5392,3 +5397,13 @@ Editor::action_menu_item (std::string const & name)
        return *manage (a->create_menu_item ());
 }
 
+void
+Editor::resize_text_widgets ()
+{
+        set_size_request_to_display_given_text (edit_mode_selector, edit_mode_strings, COMBO_FUDGE+10, 15);
+        set_size_request_to_display_given_text (zoom_focus_selector, zoom_focus_strings, COMBO_FUDGE+10, 15);
+        set_size_request_to_display_given_text (snap_type_selector, snap_type_strings, COMBO_FUDGE+10, 15);
+        set_size_request_to_display_given_text (snap_mode_selector, snap_mode_strings, COMBO_FUDGE+10, 15);
+        set_size_request_to_display_given_text (edit_point_selector, edit_point_strings, COMBO_FUDGE+10, 15);
+}
+        
index dfbb4535e26aaa10d03ce7996abd2b289170b18d..6d7b94d0dcd2a0caebc7063743f13753342f9dba 100644 (file)
@@ -1545,6 +1545,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        Gtk::ComboBoxText edit_mode_selector;
        Gtk::VBox         edit_mode_box;
+        std::vector<std::string> edit_mode_strings;
 
        void set_edit_mode (ARDOUR::EditMode);
        void cycle_edit_mode ();
@@ -2054,6 +2055,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
         void set_canvas_cursor_for_region_view (double, RegionView *);
 
        MouseCursors* _cursors;
+
+        void resize_text_widgets ();
        
        friend class Drag;
        friend class RegionDrag;
index fbfba08a773054ec39813f7f66df1535c7119510..2dce61e9080e468f3144dcfdb2f0bfc69f64ac3a 100644 (file)
@@ -42,6 +42,8 @@ namespace Gtk {
         class Adjustment;
 }
 
+extern sigc::signal<void>  DPIReset;
+
 std::string fit_to_pixels (const std::string&, int pixel_width, Pango::FontDescription& font, int& actual_width, bool with_ellipses = false);
 
 std::pair<std::string, double> fit_to_pixels (cairo_t *, std::string, double);
index cded38786e60a46e47d6853a67fdca31bb326ed2..afff784ae8f85d849badeb96a2fbfc45c8865a46 100644 (file)
@@ -82,12 +82,32 @@ Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w,
        int width_max = 0;
        int height_max = 0;
        w.ensure_style ();
+        vector<string> copy;
+        const vector<string>* to_use;
+        vector<string>::const_iterator i;
+
+        for (i = strings.begin(); i != strings.end(); ++i) {
+                if ((*i).find_first_of ("gy") != string::npos) {
+                        /* contains a descender */
+                        break;
+                }
+        }
+       
+        if (i == strings.end()) {
+                /* make a copy of the strings then add one that has a descener */
+                copy = strings;
+                copy.push_back ("g");
+                to_use = &copy;
+        } else {
+                to_use = &strings;
+        }
        
-       for (vector<string>::const_iterator i = strings.begin(); i != strings.end(); ++i) {
+       for (vector<string>::const_iterator i = to_use->begin(); i != to_use->end(); ++i) {
                get_pixel_size (w.create_pango_layout (*i), width, height);
                width_max = max(width_max,width);
                height_max = max(height_max, height);
        }
+
        w.set_size_request(width_max + hpadding, height_max + vpadding);
 }
 
@@ -207,26 +227,7 @@ Gtkmm2ext::set_popdown_strings (Gtk::ComboBoxText& cr, const vector<string>& str
        cr.clear ();
 
        if (set_size) {
-               vector<string> copy;
-
-               for (i = strings.begin(); i != strings.end(); ++i) {
-                       if ((*i).find_first_of ("gy") != string::npos) {
-                               /* contains a descender */
-                               break;
-                       }
-               }
-               
-               if (i == strings.end()) {
-                       
-                       /* make a copy of the strings then add one that has a descener */
-                       
-                       copy = strings;
-                       copy.push_back ("g");
-                       set_size_request_to_display_given_text (cr, copy, COMBO_FUDGE+10+hpadding, 15+vpadding); 
-
-               } else {
-                       set_size_request_to_display_given_text (cr, strings, COMBO_FUDGE+10+hpadding, 15+vpadding); 
-               }
+                set_size_request_to_display_given_text (cr, strings, COMBO_FUDGE+10+hpadding, 15+vpadding); 
        }
 
        for (i = strings.begin(); i != strings.end(); ++i) {