Make processor box send faders adjust their size correctly.

git-svn-id: svn://localhost/ardour2/branches/3.0@6280 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2009-12-04 17:45:11 +00:00
parent 4a836618f3
commit 12c9728530
15 changed files with 104 additions and 48 deletions

View file

@ -76,7 +76,8 @@ GainMeter::setup_slider_pix ()
GainMeterBase::GainMeterBase (Session& s,
const Glib::RefPtr<Gdk::Pixbuf>& pix,
bool horizontal)
bool horizontal,
int fader_length)
: _session (s)
// 0.781787 is the value needed for gain to be set to 0.
, gain_adjustment (0.781787, 0.0, 1.0, 0.01, 0.1)
@ -95,12 +96,14 @@ GainMeterBase::GainMeterBase (Session& s,
_width = Wide;
if (horizontal) {
gain_slider = manage (new HSliderController (pix,
gain_slider = manage (new HSliderController (pix,
&gain_adjustment,
fader_length,
false));
} else {
gain_slider = manage (new VSliderController (pix,
&gain_adjustment,
fader_length,
false));
}
@ -794,8 +797,8 @@ GainMeterBase::on_theme_changed()
style_changed = true;
}
GainMeter::GainMeter (Session& s)
: GainMeterBase (s, slider, false)
GainMeter::GainMeter (Session& s, int fader_length)
: GainMeterBase (s, slider, false, fader_length)
{
gain_display_box.set_homogeneous (true);
gain_display_box.set_spacing (2);

View file

@ -62,7 +62,7 @@ class GainMeterBase : virtual public sigc::trackable
{
public:
GainMeterBase (ARDOUR::Session&, const Glib::RefPtr<Gdk::Pixbuf>& pix,
bool horizontal);
bool horizontal, int);
virtual ~GainMeterBase ();
virtual void set_controls (boost::shared_ptr<ARDOUR::Route> route,
@ -180,7 +180,7 @@ class GainMeterBase : virtual public sigc::trackable
class GainMeter : public GainMeterBase, public Gtk::VBox
{
public:
GainMeter (ARDOUR::Session&);
GainMeter (ARDOUR::Session&, int);
~GainMeter () {}
virtual void set_controls (boost::shared_ptr<ARDOUR::Route> route,

View file

@ -80,7 +80,7 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, bool in_mixer)
,_mixer(mx)
, _mixer_owned (in_mixer)
, processor_box (sess, sigc::mem_fun(*this, &MixerStrip::plugin_selector), mx.selection(), this, in_mixer)
, gpm (sess)
, gpm (sess, 250)
, panners (sess)
, _mono_button (_("Mono"))
, button_table (3, 2)
@ -106,7 +106,7 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, boost::shared_ptr<Route> rt
,_mixer(mx)
, _mixer_owned (in_mixer)
, processor_box (sess, sigc::mem_fun(*this, &MixerStrip::plugin_selector), mx.selection(), this, in_mixer)
, gpm (sess)
, gpm (sess, 250)
, panners (sess)
, button_table (3, 2)
, middle_button_table (1, 2)
@ -134,6 +134,9 @@ MixerStrip::init ()
_width_owner = 0;
spacer = 0;
/* the length of this string determines the width of the mixer strip when it is set to `wide' */
longest_label = "longest label";
Gtk::Image* img;
img = manage (new Gtk::Image (::get_icon("strip_width")));
@ -151,14 +154,15 @@ MixerStrip::init ()
input_button.add (input_label);
input_button.set_name ("MixerIOButton");
input_label.set_name ("MixerIOButtonLabel");
Gtkmm2ext::set_size_request_to_display_given_text (input_button, "longest label", 4, 4);
Gtkmm2ext::set_size_request_to_display_given_text (input_button, longest_label.c_str(), 4, 4);
output_label.set_text (_("Output"));
ARDOUR_UI::instance()->set_tip (&output_button, _("Button 1 to choose outputs from a port matrix, button 3 to select inputs from a menu"), "");
output_button.add (output_label);
output_button.set_name ("MixerIOButton");
output_label.set_name ("MixerIOButtonLabel");
Gtkmm2ext::set_size_request_to_display_given_text (output_button, "longest label", 4, 4);
Gtkmm2ext::set_size_request_to_display_given_text (output_button, longest_label.c_str(), 4, 4);
ARDOUR_UI::instance()->set_tip (&meter_point_button, _("Select metering point"), "");
meter_point_button.add (meter_point_label);
@ -197,7 +201,7 @@ MixerStrip::init ()
name_button.add (name_label);
name_button.set_name ("MixerNameButton");
Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
Gtkmm2ext::set_size_request_to_display_given_text (name_button, longest_label.c_str(), 2, 2);
name_label.set_name ("MixerNameButtonLabel");
ARDOUR_UI::instance()->set_tip (&group_button, _("Mix group"), "");
@ -526,7 +530,6 @@ MixerStrip::set_width_enum (Width w, void* owner)
gpm.set_width (w);
panners.set_width (w);
processor_box.set_width (w);
boost::shared_ptr<AutomationList> gain_automation = _route->gain_control()->alist();
@ -597,10 +600,13 @@ 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, "longest label", 2, 2);
Gtkmm2ext::set_size_request_to_display_given_text (name_button, longest_label.c_str(), 2, 2);
set_size_request (max (50, gpm.get_gm_width()), -1);
break;
}
processor_box.set_width (w);
update_input_display ();
update_output_display ();
route_group_changed (0);

View file

@ -165,6 +165,8 @@ class MixerStrip : public RouteUI, public Gtk::EventBox
Gtk::Button output_button;
Gtk::Label output_label;
std::string longest_label;
sigc::connection newplug_connection;
gint mark_update_safe ();

View file

@ -136,7 +136,7 @@ ProcessorEntry::processor () const
}
void
ProcessorEntry::set_width (Width w)
ProcessorEntry::set_enum_width (Width w)
{
_width = w;
}
@ -223,7 +223,7 @@ SendProcessorEntry::SendProcessorEntry (boost::shared_ptr<Send> s, Width w)
: ProcessorEntry (s, w),
_send (s),
_adjustment (0, 0, 1, 0.01, 0.1),
_fader (_slider, &_adjustment, false),
_fader (_slider, &_adjustment, 0, false),
_ignore_gain_change (false)
{
_fader.set_controllable (_send->amp()->gain_control ());
@ -265,7 +265,11 @@ SendProcessorEntry::gain_adjusted ()
_send->amp()->set_gain (slider_position_to_gain (_adjustment.get_value()), this);
}
void
SendProcessorEntry::set_pixel_width (int p)
{
_fader.set_fader_length (p);
}
ProcessorBox::ProcessorBox (ARDOUR::Session& sess, sigc::slot<PluginSelector*> get_plugin_selector,
RouteRedirectSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
@ -386,7 +390,7 @@ ProcessorBox::set_width (Width w)
list<ProcessorEntry*> children = processor_display.children ();
for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
(*i)->set_width (w);
(*i)->set_enum_width (w);
}
redisplay_processors ();
@ -960,11 +964,14 @@ ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
}
boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
ProcessorEntry* e = 0;
if (send) {
processor_display.add_child (new SendProcessorEntry (send, _width));
e = new SendProcessorEntry (send, _width);
} else {
processor_display.add_child (new ProcessorEntry (processor, _width));
e = new ProcessorEntry (processor, _width);
}
e->set_pixel_width (get_allocation().get_width());
processor_display.add_child (e);
}
@ -1802,3 +1809,13 @@ ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
return string_compose(_("%1: %2 (by %3)"), _route->name(), pi->name(), maker);
}
void
ProcessorBox::on_size_allocate (Allocation& a)
{
HBox::on_size_allocate (a);
list<ProcessorEntry*> children = processor_display.children ();
for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
(*i)->set_pixel_width (a.get_width ());
}
}

View file

@ -76,7 +76,8 @@ public:
Gtk::Widget& widget ();
std::string drag_text () const;
boost::shared_ptr<ARDOUR::Processor> processor () const;
void set_width (Width);
void set_enum_width (Width);
virtual void set_pixel_width (int) {}
protected:
@ -104,6 +105,9 @@ public:
static void setup_slider_pix ();
void set_enum_width (Width, int);
void set_pixel_width (int);
private:
void show_gain ();
void gain_adjusted ();
@ -242,6 +246,7 @@ class ProcessorBox : public Gtk::HBox, public PluginInterestedObject
gint idle_delete_processor (boost::weak_ptr<ARDOUR::Processor>);
void weird_plugin_dialog (ARDOUR::Plugin& p, ARDOUR::Route::ProcessorStreams streams);
void on_size_allocate (Gtk::Allocation &);
static ProcessorBox* _current_processor_box;

View file

@ -697,7 +697,8 @@ public:
_db_slider = manage (new HSliderController (pix,
&_db_adjustment,
false));
false,
115));
parameter_changed ("solo-mute-gain");

View file

@ -37,7 +37,7 @@ using namespace PBD;
ReturnUI::ReturnUI (Gtk::Window* parent, boost::shared_ptr<Return> r, Session& se)
: _return (r)
, _session (se)
, _gpm (se)
, _gpm (se, 250)
{
_gpm.set_controls (boost::shared_ptr<Route>(), r->meter(), r->amp());

View file

@ -112,7 +112,7 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh
, size_button (_("h"))
, automation_button (_("a"))
, visual_button (_("v"))
, gm (sess, slider, true)
, gm (sess, slider, true, 115)
{
set_button_names ();

View file

@ -37,7 +37,7 @@ using namespace PBD;
SendUI::SendUI (Gtk::Window* parent, boost::shared_ptr<Send> s, Session& se)
: _send (s)
, _session (se)
, _gpm (se)
, _gpm (se, 250)
, _panners (se)
{
_panners.set_panner (s->panner());
@ -50,7 +50,7 @@ SendUI::SendUI (Gtk::Window* parent, boost::shared_ptr<Send> s, Session& se)
_vbox.set_border_width (5);
_vbox.pack_start (_hbox, false, false, false);
_vbox.pack_start (_panners, false,false);
_vbox.pack_start (_panners, false, false);
io = manage (new IOSelector (parent, se, s->output()));

View file

@ -594,7 +594,7 @@ SoundFileBrowser::add_gain_meter ()
{
delete gm;
gm = new GainMeter (*session);
gm = new GainMeter (*session, 250);
boost::shared_ptr<Route> r = session->the_auditioner ();

View file

@ -28,10 +28,13 @@
namespace Gtkmm2ext {
class PixFader : public Gtk::DrawingArea {
class PixFader : public Gtk::DrawingArea
{
public:
PixFader (Glib::RefPtr<Gdk::Pixbuf> belt_image, Gtk::Adjustment& adjustment, int orientation);
PixFader (Glib::RefPtr<Gdk::Pixbuf> belt_image, Gtk::Adjustment& adjustment, int orientation, int);
virtual ~PixFader ();
void set_fader_length (int);
protected:
Gtk::Adjustment& adjustment;

View file

@ -39,9 +39,7 @@ namespace Gtkmm2ext {
class SliderController : public Gtkmm2ext::PixFader
{
public:
SliderController (Glib::RefPtr<Gdk::Pixbuf> image,
Gtk::Adjustment* adj, int orientation,
bool with_numeric = true);
SliderController (Glib::RefPtr<Gdk::Pixbuf> image, Gtk::Adjustment* adj, int orientation, int);
virtual ~SliderController () {}
@ -68,7 +66,7 @@ class VSliderController : public SliderController
{
public:
VSliderController (Glib::RefPtr<Gdk::Pixbuf> image,
Gtk::Adjustment *adj,
Gtk::Adjustment *adj, int,
bool with_numeric = true);
};
@ -76,7 +74,7 @@ class HSliderController : public SliderController
{
public:
HSliderController (Glib::RefPtr<Gdk::Pixbuf> image,
Gtk::Adjustment *adj,
Gtk::Adjustment *adj, int,
bool with_numeric = true);
};

View file

@ -35,7 +35,7 @@ int PixFader::fine_scale_modifier = GDK_CONTROL_MASK;
int PixFader::extra_fine_scale_modifier = GDK_MOD1_MASK;
PixFader::PixFader (Glib::RefPtr<Pixbuf> belt, Gtk::Adjustment& adj, int orientation)
PixFader::PixFader (Glib::RefPtr<Pixbuf> belt, Gtk::Adjustment& adj, int orientation, int fader_length)
: adjustment (adj),
pixbuf (belt),
@ -50,13 +50,11 @@ PixFader::PixFader (Glib::RefPtr<Pixbuf> belt, Gtk::Adjustment& adj, int orienta
if (orientation == VERT) {
view.width = girth = pixbuf->get_width();
view.height = span = pixbuf->get_height() / 2;
unity_loc = (int) rint (view.height - (default_value * view.height)) - 1;
} else {
view.width = span = pixbuf->get_width () / 2;
view.height = girth = pixbuf->get_height();
unity_loc = (int) rint (default_value * view.width) - 1;
}
}
set_fader_length (fader_length);
add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK|Gdk::SCROLL_MASK);
@ -72,8 +70,19 @@ bool
PixFader::on_expose_event (GdkEventExpose* ev)
{
GdkRectangle intersection;
int srcx, srcy, ds = display_span ();
int srcx, srcy;
int const ds = display_span ();
int offset_into_pixbuf = (int) floor (span / ((float) span / ds));
/* account for fader lengths that are shorter than the fader pixbuf */
if (_orien == VERT) {
offset_into_pixbuf += pixbuf->get_height() / 2 - view.height;
} else {
offset_into_pixbuf += pixbuf->get_width() / 2 - view.width;
}
Glib::RefPtr<Gdk::GC> fg_gc (get_style()->get_fg_gc(get_state()));
if (gdk_rectangle_intersect (&view, &ev->area, &intersection)) {
@ -308,6 +317,7 @@ PixFader::adjustment_changed ()
}
}
/** @return pixel offset of the current value from the right or bottom of the fader */
int
PixFader::display_span ()
{
@ -315,3 +325,16 @@ PixFader::display_span ()
return (_orien == VERT) ? (int)floor (span * (1.0 - fract)) : (int)floor (span * fract);
}
void
PixFader::set_fader_length (int l)
{
if (_orien == VERT) {
view.height = span = l;
unity_loc = (int) rint (view.height - (default_value * view.height)) - 1;
} else {
view.width = span = l;
unity_loc = (int) rint (default_value * view.width) - 1;
}
queue_draw ();
}

View file

@ -28,11 +28,9 @@
using namespace Gtkmm2ext;
using namespace PBD;
SliderController::SliderController (Glib::RefPtr<Gdk::Pixbuf> image,
Gtk::Adjustment *adj, int orientation,
bool /*with_numeric*/)
SliderController::SliderController (Glib::RefPtr<Gdk::Pixbuf> image, Gtk::Adjustment *adj, int orientation, int fader_length)
: PixFader (image, *adj, orientation),
: PixFader (image, *adj, orientation, fader_length),
spin (*adj, 0, 2)
{
spin.set_name ("SliderControllerValue");
@ -58,10 +56,10 @@ SliderController::on_button_press_event (GdkEventButton *ev)
}
VSliderController::VSliderController (Glib::RefPtr<Gdk::Pixbuf> image,
Gtk::Adjustment *adj,
Gtk::Adjustment *adj, int fader_length,
bool with_numeric)
: SliderController (image, adj, VERT, with_numeric)
: SliderController (image, adj, VERT, fader_length)
{
if (with_numeric) {
spin_frame.add (spin);
@ -73,10 +71,10 @@ VSliderController::VSliderController (Glib::RefPtr<Gdk::Pixbuf> image,
}
HSliderController::HSliderController (Glib::RefPtr<Gdk::Pixbuf> image,
Gtk::Adjustment *adj,
Gtk::Adjustment *adj, int fader_length,
bool with_numeric)
: SliderController (image, adj, HORIZ, with_numeric)
: SliderController (image, adj, HORIZ, fader_length)
{
if (with_numeric) {
spin_frame.add (spin);