remove icky FUDGE-ness code when sizing ComboBoxText's (from an idea by david taht)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@4829 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
9917f30a18
commit
e8185a39f2
|
@ -157,17 +157,19 @@ AddRouteDialog::AddRouteDialog ()
|
|||
hbox5->pack_start (track_button, PACK_EXPAND_PADDING);
|
||||
hbox5->pack_start (bus_button, PACK_EXPAND_PADDING);
|
||||
|
||||
set_popdown_strings (channel_combo, channel_combo_strings);
|
||||
set_popdown_strings (track_mode_combo, track_mode_strings);
|
||||
channel_combo.set_active_text (channel_combo_strings.front());
|
||||
channel_combo.set_name (X_("ChannelCountSelector"));
|
||||
track_mode_combo.set_name (X_("ChannelCountSelector"));
|
||||
|
||||
set_popdown_strings (channel_combo, channel_combo_strings, true);
|
||||
set_popdown_strings (track_mode_combo, track_mode_strings, true);
|
||||
|
||||
channel_combo.set_active_text (channel_combo_strings.front());
|
||||
track_mode_combo.set_active_text (track_mode_strings.front());
|
||||
|
||||
track_button.signal_clicked().connect (mem_fun (*this, &AddRouteDialog::track_type_chosen));
|
||||
bus_button.signal_clicked().connect (mem_fun (*this, &AddRouteDialog::track_type_chosen));
|
||||
template_button.signal_clicked().connect (mem_fun (*this, &AddRouteDialog::track_type_chosen));
|
||||
|
||||
track_mode_combo.set_active_text (track_mode_strings.front());
|
||||
track_mode_combo.set_name (X_("ChannelCountSelector"));
|
||||
|
||||
VBox* vbox1 = manage (new VBox);
|
||||
vbox1->set_spacing (6);
|
||||
|
|
|
@ -188,11 +188,6 @@ ARDOUR_UI::transport_forwarding ()
|
|||
void
|
||||
ARDOUR_UI::setup_transport ()
|
||||
{
|
||||
#ifdef GTKOSX
|
||||
const guint32 FUDGE = 38; // Combo's are stupid - they steal space from the entry for the button
|
||||
#else
|
||||
const guint32 FUDGE = 24; // Combo's are stupid - they steal space from the entry for the button
|
||||
#endif
|
||||
transport_tearoff = manage (new TearOff (transport_tearoff_hbox));
|
||||
transport_tearoff->set_name ("TransportBase");
|
||||
|
||||
|
@ -384,8 +379,7 @@ ARDOUR_UI::setup_transport ()
|
|||
vector<string> shuttle_strings;
|
||||
shuttle_strings.push_back (_("sprung"));
|
||||
shuttle_strings.push_back (_("wheel"));
|
||||
set_size_request_to_display_given_text (shuttle_style_button, shuttle_strings, 6+FUDGE, 10);
|
||||
set_popdown_strings (shuttle_style_button, shuttle_strings);
|
||||
set_popdown_strings (shuttle_style_button, shuttle_strings, true);
|
||||
shuttle_style_button.signal_changed().connect (mem_fun (*this, &ARDOUR_UI::shuttle_style_changed));
|
||||
|
||||
Frame* sdframe = manage (new Frame);
|
||||
|
@ -395,7 +389,9 @@ ARDOUR_UI::setup_transport ()
|
|||
|
||||
mtc_port_changed ();
|
||||
sync_option_combo.signal_changed().connect (mem_fun (*this, &ARDOUR_UI::sync_option_changed));
|
||||
set_size_request_to_display_given_text (sync_option_combo, X_("Igternal"), 4+FUDGE, 10);
|
||||
// XXX HOW TO USE set_popdown_strings() and combo_fudge with this when we don't know
|
||||
// the real strings till later?
|
||||
set_size_request_to_display_given_text (sync_option_combo, X_("Igternal"), 4+COMBO_FUDGE, 10);
|
||||
|
||||
shbox->pack_start (*sdframe, false, false);
|
||||
shbox->pack_start (shuttle_units_button, true, true);
|
||||
|
|
|
@ -2853,12 +2853,6 @@ Editor::setup_toolbar ()
|
|||
{
|
||||
string pixmap_path;
|
||||
|
||||
#ifdef GTKOSX
|
||||
const guint32 FUDGE = 38; // Combo's are stupid - they steal space from the entry for the button
|
||||
#else
|
||||
const guint32 FUDGE = 24; // Combo's are stupid - they steal space from the entry for the button
|
||||
#endif
|
||||
|
||||
/* Mode Buttons (tool selection) */
|
||||
|
||||
vector<ToggleButton *> mouse_mode_buttons;
|
||||
|
@ -2913,8 +2907,7 @@ Editor::setup_toolbar ()
|
|||
edit_mode_strings.push_back (edit_mode_to_string (Lock));
|
||||
|
||||
edit_mode_selector.set_name ("EditModeSelector");
|
||||
Gtkmm2ext::set_size_request_to_display_given_text (edit_mode_selector, edit_mode_strings, 7+FUDGE, 10);
|
||||
set_popdown_strings (edit_mode_selector, edit_mode_strings);
|
||||
set_popdown_strings (edit_mode_selector, edit_mode_strings, true);
|
||||
edit_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_mode_selection_done));
|
||||
|
||||
mode_box->pack_start(edit_mode_selector);
|
||||
|
@ -2993,8 +2986,7 @@ Editor::setup_toolbar ()
|
|||
ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_full_button, _("Zoom to Session"));
|
||||
|
||||
zoom_focus_selector.set_name ("ZoomFocusSelector");
|
||||
Gtkmm2ext::set_size_request_to_display_given_text (zoom_focus_selector, zoom_focus_strings, 2+FUDGE, 10);
|
||||
set_popdown_strings (zoom_focus_selector, zoom_focus_strings);
|
||||
set_popdown_strings (zoom_focus_selector, zoom_focus_strings, true);
|
||||
zoom_focus_selector.signal_changed().connect (mem_fun(*this, &Editor::zoom_focus_selection_done));
|
||||
ARDOUR_UI::instance()->tooltips().set_tip (zoom_focus_selector, _("Zoom focus"));
|
||||
|
||||
|
@ -3007,20 +2999,17 @@ Editor::setup_toolbar ()
|
|||
snap_box.set_border_width (2);
|
||||
|
||||
snap_type_selector.set_name ("SnapTypeSelector");
|
||||
Gtkmm2ext::set_size_request_to_display_given_text (snap_type_selector, snap_type_strings, 7+FUDGE, 10);
|
||||
set_popdown_strings (snap_type_selector, snap_type_strings);
|
||||
set_popdown_strings (snap_type_selector, snap_type_strings, true);
|
||||
snap_type_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_type_selection_done));
|
||||
ARDOUR_UI::instance()->tooltips().set_tip (snap_type_selector, _("Snap/Grid Units"));
|
||||
|
||||
snap_mode_selector.set_name ("SnapModeSelector");
|
||||
Gtkmm2ext::set_size_request_to_display_given_text (snap_mode_selector, snap_mode_strings, 7+FUDGE, 10);
|
||||
set_popdown_strings (snap_mode_selector, snap_mode_strings);
|
||||
set_popdown_strings (snap_mode_selector, snap_mode_strings, true);
|
||||
snap_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_mode_selection_done));
|
||||
ARDOUR_UI::instance()->tooltips().set_tip (snap_mode_selector, _("Snap/Grid Mode"));
|
||||
|
||||
edit_point_selector.set_name ("EditPointSelector");
|
||||
Gtkmm2ext::set_size_request_to_display_given_text (edit_point_selector, edit_point_strings, 7+FUDGE, 10);
|
||||
set_popdown_strings (edit_point_selector, edit_point_strings);
|
||||
set_popdown_strings (edit_point_selector, edit_point_strings, true);
|
||||
edit_point_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_point_selection_done));
|
||||
ARDOUR_UI::instance()->tooltips().set_tip (edit_point_selector, _("Edit point"));
|
||||
|
||||
|
|
|
@ -1352,35 +1352,6 @@ OptionEditor::edit_button_changed ()
|
|||
Keyboard::set_edit_button ((guint) edit_button_adjustment.get_value());
|
||||
}
|
||||
|
||||
void
|
||||
OptionEditor::fixup_combo_size (Gtk::ComboBoxText& combo, vector<string>& strings)
|
||||
{
|
||||
/* find the widest string */
|
||||
|
||||
string::size_type maxlen = 0;
|
||||
string maxstring;
|
||||
|
||||
for (vector<string>::iterator i = strings.begin(); i != strings.end(); ++i) {
|
||||
string::size_type l;
|
||||
|
||||
if ((l = (*i).length()) > maxlen) {
|
||||
maxlen = l;
|
||||
maxstring = *i;
|
||||
}
|
||||
}
|
||||
|
||||
/* try to include ascenders and descenders */
|
||||
|
||||
if (maxstring.length() > 2) {
|
||||
maxstring[0] = 'g';
|
||||
maxstring[1] = 'l';
|
||||
}
|
||||
|
||||
const guint32 FUDGE = 10; // Combo's are stupid - they steal space from the entry for the button
|
||||
|
||||
set_size_request_to_display_given_text (combo, maxstring.c_str(), 10 + FUDGE, 10);
|
||||
}
|
||||
|
||||
void
|
||||
OptionEditor::parameter_changed (const char* parameter_name)
|
||||
{
|
||||
|
|
|
@ -229,8 +229,6 @@ class OptionEditor : public ArdourDialog
|
|||
void edit_button_changed ();
|
||||
void delete_button_changed ();
|
||||
void bindings_changed ();
|
||||
|
||||
void fixup_combo_size (Gtk::ComboBoxText&, std::vector<std::string>& strings);
|
||||
};
|
||||
|
||||
#endif /* __gtk_ardour_option_editor_h__ */
|
||||
|
|
|
@ -82,13 +82,7 @@ TempoDialog::init (const BBT_Time& when, double bpm, double note_type, bool mova
|
|||
strings.push_back (_("sixteenth (16)"));
|
||||
strings.push_back (_("thirty-second (32)"));
|
||||
|
||||
/* the string here needs to be the longest one to display */
|
||||
const guint32 FUDGE = 20; // Combo's are stupid - they steal space from the entry for the button
|
||||
// TRANSLATORS: this is not a mis-spelling of "thirty", we're including a vertical
|
||||
// descender to make sure the height gets computed properly.
|
||||
Gtkmm2ext::set_size_request_to_display_given_text (note_types, "thirtq-second (32)", 7+FUDGE, 15);
|
||||
|
||||
set_popdown_strings (note_types, strings);
|
||||
set_popdown_strings (note_types, strings, true);
|
||||
|
||||
if (note_type==1.0f)
|
||||
note_types.set_active_text (_("whole (1)"));
|
||||
|
@ -309,14 +303,7 @@ MeterDialog::init (const BBT_Time& when, double bpb, double note_type, bool mova
|
|||
strings.push_back (_("sixteenth (16)"));
|
||||
strings.push_back (_("thirty-second (32)"));
|
||||
|
||||
/* the string here needs to be the longest one to display */
|
||||
const guint32 FUDGE = 20; // Combo's are stupid - they steal space from the entry for the button
|
||||
|
||||
// TRANSLATORS: this is not a mis-spelling of "thirty", we're including a vertical
|
||||
// descender to make sure the height gets computed properly.
|
||||
Gtkmm2ext::set_size_request_to_display_given_text (note_types, _("thirtq-second (32)"), 7+FUDGE, 15);
|
||||
|
||||
set_popdown_strings (note_types, strings);
|
||||
set_popdown_strings (note_types, strings, true);
|
||||
|
||||
if (note_type==1.0f)
|
||||
note_types.set_active_text (_("whole (1)"));
|
||||
|
|
|
@ -45,12 +45,21 @@ namespace Gtkmm2ext {
|
|||
gint vpadding);
|
||||
|
||||
void set_size_request_to_display_given_text (Gtk::Widget &w,
|
||||
const std::vector<std::string>&,
|
||||
const std::vector<std::string>&,
|
||||
gint hpadding,
|
||||
gint vpadding);
|
||||
|
||||
void set_popdown_strings (Gtk::ComboBoxText&,
|
||||
const std::vector<std::string>&);
|
||||
const std::vector<std::string>&,
|
||||
bool set_size = false,
|
||||
gint hpadding = 0, gint vpadding = 0);
|
||||
|
||||
// Combo's are stupid - they steal space from the entry for the button
|
||||
#ifdef GTKOSX
|
||||
static const guint32 COMBO_FUDGE = 38;
|
||||
#else
|
||||
static const guint32 COMBO_FUDGE = 24;
|
||||
#endif
|
||||
|
||||
template<class T> void deferred_delete (void *ptr) {
|
||||
delete static_cast<T *> (ptr);
|
||||
|
|
|
@ -60,8 +60,8 @@ Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w, const gchar *
|
|||
|
||||
void
|
||||
Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w,
|
||||
const std::vector<std::string>& strings,
|
||||
gint hpadding, gint vpadding)
|
||||
const std::vector<std::string>& strings,
|
||||
gint hpadding, gint vpadding)
|
||||
|
||||
{
|
||||
int width, height;
|
||||
|
@ -69,11 +69,10 @@ Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w,
|
|||
int height_max = 0;
|
||||
w.ensure_style ();
|
||||
|
||||
for (vector<string>::const_iterator i = strings.begin();
|
||||
i != strings.end(); ++i) {
|
||||
get_ink_pixel_size (w.create_pango_layout (*i), width, height);
|
||||
width_max = max(width_max,width);
|
||||
height_max = max(height_max, height);
|
||||
for (vector<string>::const_iterator i = strings.begin(); i != strings.end(); ++i) {
|
||||
get_ink_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);
|
||||
}
|
||||
|
@ -86,11 +85,36 @@ Gtkmm2ext::init ()
|
|||
}
|
||||
|
||||
void
|
||||
Gtkmm2ext::set_popdown_strings (Gtk::ComboBoxText& cr, const vector<string>& strings)
|
||||
Gtkmm2ext::set_popdown_strings (Gtk::ComboBoxText& cr, const vector<string>& strings, bool set_size, gint hpadding, gint vpadding)
|
||||
{
|
||||
vector<string>::const_iterator i;
|
||||
|
||||
cr.clear ();
|
||||
|
||||
for (vector<string>::const_iterator i = strings.begin(); i != strings.end(); ++i) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = strings.begin(); i != strings.end(); ++i) {
|
||||
cr.append_text (*i);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue