Use text to specify combo box padding for better font/display tolerance.
Consistent mixer strip button height. The latter works by setting all the button size request heights to the calculated height of the alphabet. Thus, all buttons of the same class will be the same height regardless of their actual text.
This commit is contained in:
parent
394ea9cb86
commit
b75b88a1eb
@ -219,6 +219,8 @@ static const gchar *_rb_opt_strings[] = {
|
||||
};
|
||||
#endif
|
||||
|
||||
static const gchar *_combo_pad_string = "mm"; ///< ~2em
|
||||
|
||||
static void
|
||||
pane_size_watcher (Paned* pane)
|
||||
{
|
||||
@ -3063,7 +3065,7 @@ Editor::build_edit_point_menu ()
|
||||
edit_point_selector.AddMenuElem (MenuElem ( edit_point_strings[(int)EditAtSelectedMarker], sigc::bind (sigc::mem_fun(*this, &Editor::edit_point_selection_done), (EditPoint) EditAtSelectedMarker)));
|
||||
edit_point_selector.AddMenuElem (MenuElem ( edit_point_strings[(int)EditAtMouse], sigc::bind (sigc::mem_fun(*this, &Editor::edit_point_selection_done), (EditPoint) EditAtMouse)));
|
||||
|
||||
set_size_request_to_display_given_text (edit_point_selector, edit_point_strings, 30, 2);
|
||||
set_size_request_to_display_given_text (edit_point_selector, edit_point_strings, _combo_pad_string, 2);
|
||||
}
|
||||
|
||||
void
|
||||
@ -3076,7 +3078,7 @@ Editor::build_edit_mode_menu ()
|
||||
edit_mode_selector.AddMenuElem (MenuElem ( edit_mode_strings[(int)Ripple], sigc::bind (sigc::mem_fun(*this, &Editor::edit_mode_selection_done), (EditMode) Ripple)));
|
||||
edit_mode_selector.AddMenuElem (MenuElem ( edit_mode_strings[(int)Lock], sigc::bind (sigc::mem_fun(*this, &Editor::edit_mode_selection_done), (EditMode) Lock)));
|
||||
|
||||
set_size_request_to_display_given_text (edit_mode_selector, edit_mode_strings, 30, 2);
|
||||
set_size_request_to_display_given_text (edit_mode_selector, edit_mode_strings, _combo_pad_string, 2);
|
||||
}
|
||||
|
||||
void
|
||||
@ -3088,7 +3090,7 @@ Editor::build_snap_mode_menu ()
|
||||
snap_mode_selector.AddMenuElem (MenuElem ( snap_mode_strings[(int)SnapNormal], sigc::bind (sigc::mem_fun(*this, &Editor::snap_mode_selection_done), (SnapMode) SnapNormal)));
|
||||
snap_mode_selector.AddMenuElem (MenuElem ( snap_mode_strings[(int)SnapMagnetic], sigc::bind (sigc::mem_fun(*this, &Editor::snap_mode_selection_done), (SnapMode) SnapMagnetic)));
|
||||
|
||||
set_size_request_to_display_given_text (snap_mode_selector, snap_mode_strings, 30, 2);
|
||||
set_size_request_to_display_given_text (snap_mode_selector, snap_mode_strings, _combo_pad_string, 2);
|
||||
}
|
||||
|
||||
void
|
||||
@ -3127,7 +3129,7 @@ Editor::build_snap_type_menu ()
|
||||
snap_type_selector.AddMenuElem (MenuElem ( snap_type_strings[(int)SnapToRegionSync], sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_selection_done), (SnapType) SnapToRegionSync)));
|
||||
snap_type_selector.AddMenuElem (MenuElem ( snap_type_strings[(int)SnapToRegionBoundary], sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_selection_done), (SnapType) SnapToRegionBoundary)));
|
||||
|
||||
set_size_request_to_display_given_text (snap_type_selector, snap_type_strings, 30, 2);
|
||||
set_size_request_to_display_given_text (snap_type_selector, snap_type_strings, _combo_pad_string, 2);
|
||||
|
||||
}
|
||||
|
||||
@ -3473,7 +3475,7 @@ Editor::build_zoom_focus_menu ()
|
||||
zoom_focus_selector.AddMenuElem (MenuElem ( zoom_focus_strings[(int)ZoomFocusMouse], sigc::bind (sigc::mem_fun(*this, &Editor::zoom_focus_selection_done), (ZoomFocus) ZoomFocusMouse)));
|
||||
zoom_focus_selector.AddMenuElem (MenuElem ( zoom_focus_strings[(int)ZoomFocusEdit], sigc::bind (sigc::mem_fun(*this, &Editor::zoom_focus_selection_done), (ZoomFocus) ZoomFocusEdit)));
|
||||
|
||||
set_size_request_to_display_given_text (zoom_focus_selector, longest (zoom_focus_strings), 30, 2);
|
||||
set_size_request_to_display_given_text (zoom_focus_selector, zoom_focus_strings, _combo_pad_string, 2);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -80,6 +80,8 @@ MixerStrip* MixerStrip::_entered_mixer_strip;
|
||||
|
||||
PBD::Signal1<void,MixerStrip*> MixerStrip::CatchDeletion;
|
||||
|
||||
static const int _button_vpad = 2;
|
||||
|
||||
MixerStrip::MixerStrip (Mixer_UI& mx, Session* sess, bool in_mixer)
|
||||
: AxisView(sess)
|
||||
, RouteUI (sess)
|
||||
@ -167,10 +169,12 @@ MixerStrip::init ()
|
||||
input_button.set_name ("mixer strip button");
|
||||
input_button.set_size_request (-1, 20);
|
||||
input_button_box.pack_start (input_button, true, true);
|
||||
Gtkmm2ext::set_height_request_to_display_any_text (input_button, _button_vpad);
|
||||
|
||||
output_button.set_text (_("Output"));
|
||||
output_button.set_name ("mixer strip button");
|
||||
Gtkmm2ext::set_size_request_to_display_given_text (output_button, longest_label.c_str(), 4, 4);
|
||||
Gtkmm2ext::set_height_request_to_display_any_text (output_button, _button_vpad);
|
||||
|
||||
ARDOUR_UI::instance()->set_tip (&meter_point_button, _("Click to select metering point"), "");
|
||||
meter_point_button.set_name ("mixer strip button");
|
||||
@ -178,7 +182,7 @@ MixerStrip::init ()
|
||||
/* TRANSLATORS: this string should be longest of the strings
|
||||
used to describe meter points. In english, it's "input".
|
||||
*/
|
||||
set_size_request_to_display_given_text (meter_point_button, _("tupni"), 5, 5);
|
||||
set_size_request_to_display_given_text_width (meter_point_button, _("tupni"), 2, _button_vpad);
|
||||
|
||||
bottom_button_table.attach (meter_point_button, 2, 3, 0, 1);
|
||||
|
||||
@ -276,15 +280,16 @@ MixerStrip::init ()
|
||||
name_button.set_text (""); /* back to empty */
|
||||
name_button.layout()->set_ellipsize (Pango::ELLIPSIZE_END);
|
||||
name_button.signal_size_allocate().connect (sigc::mem_fun (*this, &MixerStrip::name_button_resized));
|
||||
Gtkmm2ext::set_size_request_to_display_given_text (name_button, longest_label.c_str(), 2, 2);
|
||||
name_button.set_size_request (-1, 20);
|
||||
Gtkmm2ext::set_height_request_to_display_any_text (name_button, _button_vpad);
|
||||
|
||||
ARDOUR_UI::instance()->set_tip (&group_button, _("Mix group"), "");
|
||||
group_button.set_name ("mixer strip button");
|
||||
Gtkmm2ext::set_size_request_to_display_given_text (group_button, "Grp", 2, 2);
|
||||
Gtkmm2ext::set_size_request_to_display_given_text_width (group_button, "Grp", 2, _button_vpad);
|
||||
|
||||
_comment_button.set_name (X_("mixer strip button"));
|
||||
_comment_button.signal_clicked.connect (sigc::mem_fun (*this, &RouteUI::toggle_comment_editor));
|
||||
Gtkmm2ext::set_size_request_to_display_given_text_width (_comment_button, "Cmt", 2, _button_vpad);
|
||||
|
||||
global_vpacker.set_border_width (0);
|
||||
global_vpacker.set_spacing (0);
|
||||
@ -733,7 +738,7 @@ MixerStrip::set_width_enum (Width w, void* owner)
|
||||
}
|
||||
|
||||
|
||||
Gtkmm2ext::set_size_request_to_display_given_text (name_button, longest_label.c_str(), 2, 2);
|
||||
Gtkmm2ext::set_size_request_to_display_given_text_width (name_button, longest_label.c_str(), 2, _button_vpad);
|
||||
set_size_request (-1, -1);
|
||||
break;
|
||||
|
||||
@ -756,7 +761,7 @@ MixerStrip::set_width_enum (Width w, void* owner)
|
||||
panners.short_astate_string(_route->panner()->automation_state()));
|
||||
}
|
||||
|
||||
Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
|
||||
Gtkmm2ext::set_size_request_to_display_given_text_width (name_button, "long", 2, _button_vpad);
|
||||
set_size_request (max (50, gpm.get_gm_width()), -1);
|
||||
break;
|
||||
}
|
||||
@ -1438,6 +1443,9 @@ MixerStrip::setup_comment_button ()
|
||||
ARDOUR_UI::instance()->set_tip (
|
||||
_comment_button, _route->comment().empty() ? _("Click to Add/Edit Comments") : _route->comment()
|
||||
);
|
||||
|
||||
Gtkmm2ext::set_size_request_to_display_given_text_width (
|
||||
_comment_button, _comment_button.get_text().c_str(), 2, _button_vpad);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -1638,6 +1646,9 @@ MixerStrip::name_changed ()
|
||||
break;
|
||||
}
|
||||
|
||||
Gtkmm2ext::set_size_request_to_display_given_text_width (
|
||||
name_button, name_button.get_text().c_str(), 2, _button_vpad);
|
||||
|
||||
ARDOUR_UI::instance()->set_tip (name_button, _route->name());
|
||||
}
|
||||
|
||||
@ -2043,6 +2054,22 @@ MixerStrip::set_button_names ()
|
||||
} else {
|
||||
meter_point_button.set_text ("");
|
||||
}
|
||||
|
||||
// Update size request of changed buttons
|
||||
Gtkmm2ext::set_size_request_to_display_given_text_width (
|
||||
*rec_enable_button, rec_enable_button->get_text().c_str(), 2, _button_vpad);
|
||||
Gtkmm2ext::set_size_request_to_display_given_text_width (
|
||||
*mute_button, mute_button->get_text().c_str(), 2, _button_vpad);
|
||||
Gtkmm2ext::set_size_request_to_display_given_text_width (
|
||||
*monitor_input_button, monitor_input_button->get_text().c_str(), 2, _button_vpad);
|
||||
Gtkmm2ext::set_size_request_to_display_given_text_width (
|
||||
*monitor_disk_button, monitor_disk_button->get_text().c_str(), 2, _button_vpad);
|
||||
Gtkmm2ext::set_size_request_to_display_given_text_width (
|
||||
*solo_button, solo_button->get_text().c_str(), 2, _button_vpad);
|
||||
Gtkmm2ext::set_size_request_to_display_given_text_width (
|
||||
*solo_isolated_led, solo_isolated_led->get_text().c_str(), 2, _button_vpad);
|
||||
Gtkmm2ext::set_size_request_to_display_given_text_width (
|
||||
*solo_safe_led, solo_safe_led->get_text().c_str(), 2, _button_vpad);
|
||||
}
|
||||
|
||||
PluginSelector*
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <gtkmm2ext/bindable_button.h>
|
||||
#include <gtkmm2ext/barcontroller.h>
|
||||
#include <gtkmm2ext/gtk_ui.h>
|
||||
#include <gtkmm2ext/utils.h>
|
||||
|
||||
#include "ardour/route_group.h"
|
||||
#include "ardour/dB.h"
|
||||
@ -65,6 +66,8 @@ uint32_t RouteUI::_max_invert_buttons = 3;
|
||||
PBD::Signal1<void, boost::shared_ptr<Route> > RouteUI::BusSendDisplayChanged;
|
||||
boost::weak_ptr<Route> RouteUI::_showing_sends_to;
|
||||
|
||||
static const int _button_vpad = 2;
|
||||
|
||||
RouteUI::RouteUI (ARDOUR::Session* sess)
|
||||
: AxisView(sess)
|
||||
, mute_menu(0)
|
||||
@ -1935,6 +1938,7 @@ RouteUI::setup_invert_buttons ()
|
||||
for (uint32_t i = 0; i < to_add; ++i) {
|
||||
ArdourButton* b = manage (new ArdourButton);
|
||||
b->set_size_request(20,20);
|
||||
Gtkmm2ext::set_height_request_to_display_any_text (*b, _button_vpad);
|
||||
b->signal_button_press_event().connect (sigc::mem_fun (*this, &RouteUI::invert_press));
|
||||
b->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::invert_release), i));
|
||||
|
||||
|
@ -65,6 +65,13 @@ namespace Gtkmm2ext {
|
||||
gint hpadding,
|
||||
gint vpadding);
|
||||
|
||||
LIBGTKMM2EXT_API void set_size_request_to_display_given_text_width (Gtk::Widget& w,
|
||||
const gchar* htext,
|
||||
gint hpadding,
|
||||
gint vpadding);
|
||||
|
||||
LIBGTKMM2EXT_API void set_height_request_to_display_any_text (Gtk::Widget& w, gint vpadding);
|
||||
|
||||
LIBGTKMM2EXT_API void set_size_request_to_display_given_text (Gtk::Widget &w,
|
||||
std::string const & text,
|
||||
gint hpadding,
|
||||
@ -73,6 +80,10 @@ namespace Gtkmm2ext {
|
||||
const std::vector<std::string>&,
|
||||
gint hpadding,
|
||||
gint vpadding);
|
||||
LIBGTKMM2EXT_API void set_size_request_to_display_given_text (Gtk::Widget &w,
|
||||
const std::vector<std::string>&,
|
||||
const std::string& hpadding,
|
||||
gint vpadding);
|
||||
|
||||
|
||||
LIBGTKMM2EXT_API Glib::RefPtr<Gdk::Pixbuf> pixbuf_from_string (const std::string& name,
|
||||
|
@ -76,6 +76,40 @@ Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w, const gchar *
|
||||
w.set_size_request(width + hpadding, height + vpadding);
|
||||
}
|
||||
|
||||
/** Set width request to display given text, and height to display anything.
|
||||
This is useful for setting many widgets to the same height for consistency. */
|
||||
void
|
||||
Gtkmm2ext::set_size_request_to_display_given_text_width (Gtk::Widget& w,
|
||||
const gchar* htext,
|
||||
gint hpadding,
|
||||
gint vpadding)
|
||||
{
|
||||
static const gchar* vtext = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
w.ensure_style ();
|
||||
|
||||
int hwidth, hheight;
|
||||
get_pixel_size (w.create_pango_layout (htext), hwidth, hheight);
|
||||
|
||||
int vwidth, vheight;
|
||||
get_pixel_size (w.create_pango_layout (vtext), vwidth, vheight);
|
||||
|
||||
w.set_size_request(hwidth + hpadding, vheight + vpadding);
|
||||
}
|
||||
|
||||
void
|
||||
Gtkmm2ext::set_height_request_to_display_any_text (Gtk::Widget& w, gint vpadding)
|
||||
{
|
||||
static const gchar* vtext = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
w.ensure_style ();
|
||||
|
||||
int width, height;
|
||||
get_pixel_size (w.create_pango_layout (vtext), width, height);
|
||||
|
||||
w.set_size_request(-1, height + vpadding);
|
||||
}
|
||||
|
||||
void
|
||||
Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w, std::string const & text,
|
||||
gint hpadding, gint vpadding)
|
||||
@ -125,6 +159,33 @@ Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w,
|
||||
w.set_size_request(width_max + hpadding, height_max + vpadding);
|
||||
}
|
||||
|
||||
/** This version specifies horizontal padding in text to avoid assumptions
|
||||
about font size. Should be used anywhere padding is used to avoid text,
|
||||
like combo boxes. */
|
||||
void
|
||||
Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget& w,
|
||||
const std::vector<std::string>& strings,
|
||||
const std::string& hpadding,
|
||||
gint vpadding)
|
||||
{
|
||||
int width_max = 0;
|
||||
int height_max = 0;
|
||||
w.ensure_style ();
|
||||
|
||||
for (vector<string>::const_iterator i = strings.begin(); i != strings.end(); ++i) {
|
||||
int width, height;
|
||||
get_pixel_size (w.create_pango_layout (*i), width, height);
|
||||
width_max = max(width_max,width);
|
||||
height_max = max(height_max, height);
|
||||
}
|
||||
|
||||
int pad_width;
|
||||
int pad_height;
|
||||
get_pixel_size (w.create_pango_layout (hpadding), pad_width, pad_height);
|
||||
|
||||
w.set_size_request(width_max + pad_width, height_max + vpadding);
|
||||
}
|
||||
|
||||
static inline guint8
|
||||
demultiply_alpha (guint8 src,
|
||||
guint8 alpha)
|
||||
|
Loading…
Reference in New Issue
Block a user