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
This commit is contained in:
Paul Davis 2010-12-30 21:15:51 +00:00
parent 2cf464cf1d
commit 5e7b4559fe
4 changed files with 44 additions and 23 deletions

View 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);
}

View 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;

View 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);

View 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;
}
}
for (vector<string>::const_iterator i = strings.begin(); i != strings.end(); ++i) {
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 = 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) {