Pack toolbar combo boxes with expand=false and remove size kludges.

Turns out gtk these days sizes combo boxes with precisely enough space if
packed to not expand, none of this mess is necessary any more.


git-svn-id: svn://localhost/ardour2/branches/3.0@10790 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2011-11-23 08:35:41 +00:00
parent 8301e6c55f
commit e70249ab65
9 changed files with 22 additions and 53 deletions

View File

@ -245,7 +245,7 @@ AddRouteDialog::refill_track_modes ()
}
}
set_popdown_strings (mode_combo, s, true);
set_popdown_strings (mode_combo, s);
mode_combo.set_active_text (s.front());
}
@ -386,7 +386,7 @@ AddRouteDialog::refill_channel_setups ()
channel_combo_strings.push_back ((*i).name);
}
set_popdown_strings (channel_combo, channel_combo_strings, true);
set_popdown_strings (channel_combo, channel_combo_strings);
channel_combo.set_active_text (channel_combo_strings.front());
}

View File

@ -555,8 +555,6 @@ ARDOUR_UI::build_menu_bar ()
buffer_load_label.set_name ("BufferLoad");
buffer_load_label.set_use_markup ();
resize_text_widgets ();
sample_rate_box.add (sample_rate_label);
sample_rate_box.set_name ("SampleRate");
sample_rate_label.set_name ("SampleRate");

View File

@ -2788,11 +2788,11 @@ Editor::setup_toolbar ()
edit_mode_strings.push_back (edit_mode_to_string (Lock));
edit_mode_selector.set_name ("EditModeSelector");
set_popdown_strings (edit_mode_selector, edit_mode_strings, true);
set_popdown_strings (edit_mode_selector, edit_mode_strings);
edit_mode_selector.signal_changed().connect (sigc::mem_fun(*this, &Editor::edit_mode_selection_done));
mode_box->pack_start (edit_mode_selector);
mode_box->pack_start (*mouse_mode_button_box);
mode_box->pack_start (edit_mode_selector, false, false);
mode_box->pack_start (*mouse_mode_button_box, false, false);
_mouse_mode_tearoff = manage (new TearOff (*mode_box));
_mouse_mode_tearoff->set_name ("MouseModeBase");
@ -2837,14 +2837,14 @@ Editor::setup_toolbar ()
zoom_out_full_button.set_related_action (act);
zoom_focus_selector.set_name ("ZoomFocusSelector");
set_popdown_strings (zoom_focus_selector, zoom_focus_strings, true);
set_popdown_strings (zoom_focus_selector, zoom_focus_strings);
zoom_focus_selector.signal_changed().connect (sigc::mem_fun(*this, &Editor::zoom_focus_selection_done));
_zoom_box.pack_start (zoom_out_button, false, false);
_zoom_box.pack_start (zoom_in_button, false, false);
_zoom_box.pack_start (zoom_out_full_button, false, false);
_zoom_box.pack_start (zoom_focus_selector);
_zoom_box.pack_start (zoom_focus_selector, false, false);
/* Track zoom buttons */
tav_expand_button.set_name ("TrackHeightButton");
@ -2877,15 +2877,15 @@ Editor::setup_toolbar ()
snap_box.set_border_width (2);
snap_type_selector.set_name ("SnapTypeSelector");
set_popdown_strings (snap_type_selector, snap_type_strings, true);
set_popdown_strings (snap_type_selector, snap_type_strings);
snap_type_selector.signal_changed().connect (sigc::mem_fun(*this, &Editor::snap_type_selection_done));
snap_mode_selector.set_name ("SnapModeSelector");
set_popdown_strings (snap_mode_selector, snap_mode_strings, true);
set_popdown_strings (snap_mode_selector, snap_mode_strings);
snap_mode_selector.signal_changed().connect (sigc::mem_fun(*this, &Editor::snap_mode_selection_done));
edit_point_selector.set_name ("EditPointSelector");
set_popdown_strings (edit_point_selector, edit_point_strings, true);
set_popdown_strings (edit_point_selector, edit_point_strings);
edit_point_selector.signal_changed().connect (sigc::mem_fun(*this, &Editor::edit_point_selection_done));
snap_box.pack_start (snap_mode_selector, false, false);
@ -2955,8 +2955,6 @@ Editor::setup_toolbar ()
toolbar_frame.set_shadow_type (SHADOW_OUT);
toolbar_frame.set_name ("BaseFrame");
toolbar_frame.add (_toolbar_viewport);
DPIReset.connect (sigc::mem_fun (*this, &Editor::resize_text_widgets));
}
void
@ -5440,16 +5438,6 @@ 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);
}
void
Editor::add_notebook_page (string const & name, Gtk::Widget& widget)
{

View File

@ -2067,8 +2067,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
MouseCursors* _cursors;
void resize_text_widgets ();
void follow_mixer_selection ();
bool _following_mixer_selection;

View File

@ -1447,14 +1447,14 @@ SoundFileOmega::SoundFileOmega (Gtk::Window& parent, string title, ARDOUR::Sessi
t.push_back (_("one track per channel"));
t.push_back (_("sequence files"));
t.push_back (_("all files in one region"));
set_size_request_to_display_given_text (channel_combo, t, COMBO_FUDGE + 10, 15);
set_popdown_strings (channel_combo, t);
t.clear ();
t.push_back (importmode2string (ImportAsTrack));
t.push_back (importmode2string (ImportToTrack));
t.push_back (importmode2string (ImportAsRegion));
t.push_back (importmode2string (ImportAsTapeTrack));
set_size_request_to_display_given_text (action_combo, t, COMBO_FUDGE + 10, 15);
set_popdown_strings (action_combo, t);
}
void

View File

@ -77,7 +77,7 @@ TempoDialog::init (const Timecode::BBT_Time& when, double bpm, double note_type,
strings.push_back (_("sixteenth (16)"));
strings.push_back (_("thirty-second (32)"));
set_popdown_strings (note_types, strings, true);
set_popdown_strings (note_types, strings);
if (note_type == 1.0f) {
note_types.set_active_text (_("whole (1)"));
@ -275,7 +275,7 @@ MeterDialog::init (const Timecode::BBT_Time& when, double bpb, double note_type,
strings.push_back (_("sixteenth (16)"));
strings.push_back (_("thirty-second (32)"));
set_popdown_strings (note_types, strings, true);
set_popdown_strings (note_types, strings);
if (note_type == 1.0f) {
note_types.set_active_text (_("whole (1)"));

View File

@ -60,23 +60,14 @@ namespace Gtkmm2ext {
gint hpadding,
gint vpadding);
Glib::RefPtr<Gdk::Pixbuf> pixbuf_from_string (const std::string& name,
const Pango::FontDescription& font,
int clip_width,
int clip_height,
Gdk::Color fg);
Glib::RefPtr<Gdk::Pixbuf> pixbuf_from_string (const std::string& name,
const Pango::FontDescription& font,
int clip_width,
int clip_height,
Gdk::Color fg);
void set_popdown_strings (Gtk::ComboBoxText&,
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
const std::vector<std::string>&);
template<class T> void deferred_delete (void *ptr) {
delete static_cast<T *> (ptr);

View File

@ -63,7 +63,6 @@ get_pixel_size (Glib::RefPtr<Pango::Layout> layout,
void
Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w, const gchar *text,
gint hpadding, gint vpadding)
{
int width, height;
w.ensure_style ();
@ -76,7 +75,6 @@ void
Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w,
const std::vector<std::string>& strings,
gint hpadding, gint vpadding)
{
int width, height;
int width_max = 0;
@ -220,16 +218,12 @@ Gtkmm2ext::pixbuf_from_string(const string& name, const Pango::FontDescription&
}
void
Gtkmm2ext::set_popdown_strings (Gtk::ComboBoxText& cr, const vector<string>& strings, bool set_size, gint hpadding, gint vpadding)
Gtkmm2ext::set_popdown_strings (Gtk::ComboBoxText& cr, const vector<string>& strings)
{
vector<string>::const_iterator i;
cr.clear ();
if (set_size) {
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);
}

View File

@ -71,7 +71,7 @@ GMCPGUI::GMCPGUI (GenericMidiControlProtocol& p)
popdowns.push_back ((*x).name);
}
set_popdown_strings (map_combo, popdowns, true, 5, 2);
set_popdown_strings (map_combo, popdowns);
if (cp.current_binding().empty()) {
map_combo.set_active_text (popdowns[0]);