summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-12-30 21:15:51 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-12-30 21:15:51 +0000
commit5e7b4559fefc15e91ccafdb6ea5ba52211d6cef0 (patch)
tree7cae2c87ce08bcf040a1825b4e2283d0d9d938eb
parent2cf464cf1daeb2dfdbb8445ff49df67fc85af26c (diff)
resize all editor comboboxes when DPI is reset. involved a minor refactoring of some code and the spreading of the awful COMBO_FUDGE+10 hack
git-svn-id: svn://localhost/ardour2/branches/3.0@8398 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/editor.cc19
-rw-r--r--gtk2_ardour/editor.h3
-rw-r--r--gtk2_ardour/utils.h2
-rw-r--r--libs/gtkmm2ext/utils.cc43
4 files changed, 44 insertions, 23 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index b7566a8919..ab6c171411 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -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);
+}
+
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index dfbb4535e2..6d7b94d0dc 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -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;
diff --git a/gtk2_ardour/utils.h b/gtk2_ardour/utils.h
index fbfba08a77..2dce61e908 100644
--- a/gtk2_ardour/utils.h
+++ b/gtk2_ardour/utils.h
@@ -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);
diff --git a/libs/gtkmm2ext/utils.cc b/libs/gtkmm2ext/utils.cc
index cded38786e..afff784ae8 100644
--- a/libs/gtkmm2ext/utils.cc
+++ b/libs/gtkmm2ext/utils.cc
@@ -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) {