more theming and layout tweaks. new faders that pre-light. fixed some spacing around mixer buttons. tweaked some colors (returned mutes to yellow). removed group button at bottom of mixer strip and replaced it with fader automation mode.

git-svn-id: svn://localhost/ardour2/branches/3.0@13617 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Ben Loftis 2012-12-07 22:38:49 +00:00
parent 526a1a71fe
commit 5249f82603
13 changed files with 241 additions and 140 deletions

View File

@ -201,7 +201,7 @@ style "default" = "medium_text"
style "track_controls_inactive"
{
bg[NORMAL] = { 0.60, 0.60, 0.66 }
bg[NORMAL] = { 0.60, 0.20, 0.26 }
bg[ACTIVE] = { 0.60, 0.60, 0.66 }
bg[INSENSITIVE] = { 0.60, 0.60, 0.66 }
bg[SELECTED] = { 0.60, 0.60, 0.66 }

View File

@ -149,8 +149,8 @@
<Option name="button border" value="000000f0"/>
<Option name="processor prefader: fill start" value="873c3cff"/>
<Option name="processor prefader: fill end" value="542525ff"/>
<Option name="processor prefader: fill start active" value="873c3cff"/>
<Option name="processor prefader: fill end active" value="542525ff"/>
<Option name="processor prefader: fill start active" value="774c4cff"/>
<Option name="processor prefader: fill end active" value="603535ff"/>
<Option name="processor prefader: led" value="26550eff"/>
<Option name="processor prefader: led active" value="78cb4eff"/>
<Option name="processor prefader: text" value="aaaaa3ff"/>
@ -158,15 +158,15 @@
<Option name="processor fader: fill start" value="5d90b0ff"/>
<Option name="processor fader: fill end" value="154c6eff"/>
<Option name="processor fader: fill start active" value="5d90b0ff"/>
<Option name="processor fader: fill end active" value="154d6fff"/>
<Option name="processor fader: fill end active" value="256d8fff"/>
<Option name="processor fader: led" value="26550eff"/>
<Option name="processor fader: led active" value="78cb4eff"/>
<Option name="processor fader: text" value="aaaaa3ff"/>
<Option name="processor fader: text active" value="eeeeecff"/>
<Option name="processor postfader: fill start" value="415947ff"/>
<Option name="processor postfader: fill end" value="202d23ff"/>
<Option name="processor postfader: fill start active" value="415947ff"/>
<Option name="processor postfader: fill end active" value="202d23ff"/>
<Option name="processor postfader: fill start" value="354537ff"/>
<Option name="processor postfader: fill end" value="202823ff"/>
<Option name="processor postfader: fill start active" value="466452ff"/>
<Option name="processor postfader: fill end active" value="254528ff"/>
<Option name="processor postfader: led" value="26550eff"/>
<Option name="processor postfader: led active" value="78cb4eff"/>
<Option name="processor postfader: text" value="aaaaa3ff"/>
@ -180,7 +180,7 @@
<Option name="processor control button: text" value="ffffffff"/>
<Option name="processor control button: text active" value="ffffffff"/>
<Option name="monitor button: fill start" value="5f5a58ff"/>
<Option name="monitor button: fill end" value="3f3a38ff"/>
<Option name="monitor button: fill end" value="4f4a48ff"/>
<Option name="monitor button: fill start active" value="553500ff"/>
<Option name="monitor button: fill end active" value="e58505ff"/>
<Option name="monitor button: led" value="660000ff"/>
@ -204,7 +204,7 @@
<Option name="solo safe: text" value="c7c7d8ff"/>
<Option name="solo safe: text active" value="c8c8d9ff"/>
<Option name="monitor section cut: fill start" value="5f5a58ff"/>
<Option name="monitor section cut: fill end" value="3f3a38ff"/>
<Option name="monitor section cut: fill end" value="4f4a48ff"/>
<Option name="monitor section cut: fill start active" value="5f4943ff"/>
<Option name="monitor section cut: fill end active" value="ffa500ff"/>
<Option name="monitor section cut: led" value="473812ff"/>
@ -212,14 +212,14 @@
<Option name="monitor section cut: text" value="c7c7d8ff"/>
<Option name="monitor section cut: text active" value="000000ff"/>
<Option name="monitor section dim: fill start" value="5f5a58ff"/>
<Option name="monitor section dim: fill end" value="3f3a38ff"/>
<Option name="monitor section dim: fill end" value="4f4a48ff"/>
<Option name="monitor section dim: fill start active" value="553500ff"/>
<Option name="monitor section dim: fill end active" value="e58505ff"/>
<Option name="monitor section dim: led active" value="78cb4eff"/>
<Option name="monitor section dim: text" value="c8c8d9ff"/>
<Option name="monitor section dim: text active" value="c8c8d9ff"/>
<Option name="monitor section solo: fill start" value="5f5a58ff"/>
<Option name="monitor section solo: fill end" value="3f3a38ff"/>
<Option name="monitor section solo: fill end" value="4f4a48ff"/>
<Option name="monitor section solo: fill start active" value="104506ff"/>
<Option name="monitor section solo: fill end active" value="4dbb00ff"/>
<Option name="monitor section solo: led" value="473812ff"/>
@ -227,7 +227,7 @@
<Option name="monitor section solo: text" value="00000000"/>
<Option name="monitor section solo: text active" value="00000000"/>
<Option name="monitor section invert: fill start" value="5f5a58ff"/>
<Option name="monitor section invert: fill end" value="3f3a38ff"/>
<Option name="monitor section invert: fill end" value="4f4a48ff"/>
<Option name="monitor section invert: fill start active" value="222260ff"/>
<Option name="monitor section invert: fill end active" value="4242d0ff"/>
<Option name="monitor section invert: led" value="473812ff"/>
@ -235,7 +235,7 @@
<Option name="monitor section invert: text" value="00000000"/>
<Option name="monitor section invert: text active" value="00000000"/>
<Option name="monitor section mono: fill start" value="5f5a58ff"/>
<Option name="monitor section mono: fill end" value="3f3a38ff"/>
<Option name="monitor section mono: fill end" value="4f4a48ff"/>
<Option name="monitor section mono: fill start active" value="222260ff"/>
<Option name="monitor section mono: fill end active" value="3232c0ff"/>
<Option name="monitor section mono: led" value="473812ff"/>
@ -301,10 +301,10 @@
<Option name="mute button: fill start" value="565659ff"/>
<Option name="mute button: fill end" value="484853ff"/>
<Option name="mute button: fill start active" value="5f4943ff"/>
<Option name="mute button: fill end active" value="ffa500ff"/>
<Option name="mute button: fill end active" value="ffff00ff"/>
<Option name="mute button: led" value="00000000"/>
<Option name="mute button: led active" value="00000000"/>
<Option name="mute button: text" value="bfbfbfff"/>
<Option name="mute button: text" value="bfbfafff"/>
<Option name="mute button: text active" value="191919ff"/>
<Option name="solo button: fill start" value="565659ff"/>
<Option name="solo button: fill end" value="484853ff"/>
@ -312,7 +312,7 @@
<Option name="solo button: fill end active" value="4dbb00ff"/>
<Option name="solo button: led" value="00000000"/>
<Option name="solo button: led active" value="00000000"/>
<Option name="solo button: text" value="bfbfbfff"/>
<Option name="solo button: text" value="afbfafff"/>
<Option name="solo button: text active" value="191919ff"/>
<Option name="invert button: fill start" value="565659ff"/>
<Option name="invert button: fill end" value="484853ff"/>
@ -408,8 +408,8 @@
<Option name="route button: fill end active" value="121212ff"/>
<Option name="route button: led" value="4f3300ff"/>
<Option name="route button: led active" value="ffa500ff"/>
<Option name="route button: text" value="c7c7d8ff"/>
<Option name="route button: text active" value="c8c8d9ff"/>
<Option name="route button: text" value="bfbfbfff"/>
<Option name="route button: text active" value="191919ff"/>
<Option name="mixer strip button: fill start" value="565659ff"/>
<Option name="mixer strip button: fill end" value="484853ff"/>
<Option name="mixer strip button: fill start active" value="5f4943ff"/>

View File

@ -224,6 +224,7 @@ widget "*ParameterValueDisplay" style:highest "medium_bold_entry"
widget "*PluginUIClickBox" style:highest "medium_bold_entry"
widget "*PluginUIClickBox*" style:highest "medium_bold_entry"
widget "*PluginSlider" style:highest "plugin_slider"
widget "*GainFader" style:highest "plugin_slider"
widget "*MixerTrackCommentArea" style:highest "option_entry"
widget "*MixerPanZone" style:highest "pan_zone"
widget "*LHSList" style:highest "treeview_display"

View File

@ -79,7 +79,7 @@ EditorRegions::EditorRegions (Editor* e)
{
_display.set_size_request (100, -1);
_display.set_rules_hint (true);
_display.set_name ("LHSList");
_display.set_name ("EditGroupList");
/* Try to prevent single mouse presses from initiating edits.
This relies on a hack in gtktreeview.c:gtk_treeview_button_press()

View File

@ -223,7 +223,7 @@ EditorRoutes::EditorRoutes (Editor* e)
_display.get_selection()->set_mode (SELECTION_SINGLE);
_display.get_selection()->set_select_function (sigc::mem_fun (*this, &EditorRoutes::selection_filter));
_display.set_reorderable (true);
_display.set_name (X_("LHSList"));
_display.set_name (X_("EditGroupList"));
_display.set_rules_hint (true);
_display.set_size_request (100, -1);
_display.add_object_drag (_columns.route.index(), "routes");

View File

@ -135,8 +135,8 @@ GainMeterBase::GainMeterBase (Session* s,
peak_display.set_label (_("-inf"));
peak_display.unset_flags (Gtk::CAN_FOCUS);
gain_automation_style_button.set_name ("MixerAutomationModeButton");
gain_automation_state_button.set_name ("MixerAutomationPlaybackButton");
gain_automation_style_button.set_name ("mixer strip button");
gain_automation_state_button.set_name ("mixer strip button");
ARDOUR_UI::instance()->set_tip (gain_automation_state_button, _("Fader automation mode"));
ARDOUR_UI::instance()->set_tip (gain_automation_style_button, _("Fader automation type"));
@ -163,6 +163,16 @@ GainMeterBase::GainMeterBase (Session* s,
UI::instance()->theme_changed.connect (sigc::mem_fun(*this, &GainMeterBase::on_theme_changed));
ColorsChanged.connect (sigc::bind(sigc::mem_fun (*this, &GainMeterBase::color_handler), false));
DPIReset.connect (sigc::bind(sigc::mem_fun (*this, &GainMeterBase::color_handler), true));
// PBD::ScopedConnection _config_connection;
// Config->ParameterChanged.connect ( _config_connection, MISSING_INVALIDATOR, boost::bind(&GainMeterBase::set_flat_buttons, this, _1), gui_context() );
}
void
GainMeterBase::set_flat_buttons ()
{
printf("set_flat_butt\n");
// gain_slider->set_flat_buttons( ARDOUR_UI::config()->flat_buttons.get() );
}
GainMeterBase::~GainMeterBase ()
@ -771,10 +781,10 @@ GainMeterBase::gain_automation_style_changed ()
{
switch (_width) {
case Wide:
gain_automation_style_button.set_label (astyle_string(_amp->gain_control()->alist()->automation_style()));
gain_automation_style_button.set_text (astyle_string(_amp->gain_control()->alist()->automation_style()));
break;
case Narrow:
gain_automation_style_button.set_label (short_astyle_string(_amp->gain_control()->alist()->automation_style()));
gain_automation_style_button.set_text (short_astyle_string(_amp->gain_control()->alist()->automation_style()));
break;
}
}
@ -788,10 +798,10 @@ GainMeterBase::gain_automation_state_changed ()
switch (_width) {
case Wide:
gain_automation_state_button.set_label (astate_string(_amp->gain_control()->alist()->automation_state()));
gain_automation_state_button.set_text (astate_string(_amp->gain_control()->alist()->automation_state()));
break;
case Narrow:
gain_automation_state_button.set_label (short_astate_string(_amp->gain_control()->alist()->automation_state()));
gain_automation_state_button.set_text (short_astate_string(_amp->gain_control()->alist()->automation_state()));
break;
}
@ -861,13 +871,13 @@ GainMeter::GainMeter (Session* s, int fader_length)
, gain_display_box(true, 0)
, hbox(true, 2)
{
gain_display_box.pack_start (gain_display, true, true);
// gain_display_box.pack_start (gain_display, true, true);
meter_metric_area.set_name ("AudioTrackMetrics");
set_size_request_to_display_given_text (meter_metric_area, "-127", 0, 0);
gain_automation_style_button.set_name ("MixerAutomationModeButton");
gain_automation_state_button.set_name ("MixerAutomationPlaybackButton");
gain_automation_style_button.set_name ("mixer strip button");
gain_automation_state_button.set_name ("mixer strip button");
ARDOUR_UI::instance()->set_tip (gain_automation_state_button, _("Fader automation mode"));
ARDOUR_UI::instance()->set_tip (gain_automation_style_button, _("Fader automation type"));
@ -908,13 +918,13 @@ GainMeter::set_controls (boost::shared_ptr<Route> r,
hbox.remove (meter_alignment);
}
if (peak_display.get_parent()) {
gain_display_box.remove (peak_display);
}
// if (peak_display.get_parent()) {
// gain_display_box.remove (peak_display);
// }
if (gain_automation_state_button.get_parent()) {
fader_vbox->remove (gain_automation_state_button);
}
// if (gain_automation_state_button.get_parent()) {
// fader_vbox->remove (gain_automation_state_button);
// }
GainMeterBase::set_controls (r, meter, amp);
@ -932,12 +942,12 @@ GainMeter::set_controls (boost::shared_ptr<Route> r,
pack some route-dependent stuff.
*/
gain_display_box.pack_end (peak_display, true, true);
// gain_display_box.pack_end (peak_display, true, true);
hbox.pack_start (meter_alignment, true, true);
if (r && !r->is_hidden()) {
fader_vbox->pack_start (gain_automation_state_button, false, false, 0);
}
// if (r && !r->is_hidden()) {
// fader_vbox->pack_start (gain_automation_state_button, false, false, 0);
// }
setup_meters ();
hbox.show_all ();

View File

@ -38,6 +38,8 @@
#include "ardour/types.h"
#include "ardour/session_handle.h"
#include "ardour_button.h"
#include "gtkmm2ext/click_box.h"
#include "gtkmm2ext/focus_entry.h"
#include "gtkmm2ext/slider_controller.h"
@ -81,6 +83,8 @@ class GainMeterBase : virtual public sigc::trackable, ARDOUR::SessionHandlePtr
void set_meter_strip_name (const char * name);
void set_fader_name (const char * name);
void set_flat_buttons ();
virtual void setup_meters (int len=0);
boost::shared_ptr<PBD::Controllable> get_controllable();
@ -114,8 +118,8 @@ class GainMeterBase : virtual public sigc::trackable, ARDOUR::SessionHandlePtr
sigc::connection gain_watching;
Gtk::Button gain_automation_style_button;
Gtk::ToggleButton gain_automation_state_button;
ArdourButton gain_automation_style_button;
ArdourButton gain_automation_state_button;
Gtk::Menu gain_astate_menu;
Gtk::Menu gain_astyle_menu;

View File

@ -242,7 +242,8 @@ MixerStrip::init ()
bottom_button_table.set_spacings (2);
bottom_button_table.set_homogeneous (true);
bottom_button_table.attach (group_button, 0, 1, 0, 1);
// bottom_button_table.attach (group_button, 0, 1, 0, 1);
bottom_button_table.attach (gpm.gain_automation_state_button, 0, 1, 0, 1);
name_button.set_name ("mixer strip button");
name_button.set_text (" "); /* non empty text, forces creation of the layout */
@ -399,6 +400,14 @@ MixerStrip::set_route (boost::shared_ptr<Route> rt)
revert_to_default_display ();
if (gpm.gain_display.get_parent()) {
middle_button_table.remove (gpm.gain_display);
}
if (gpm.peak_display.get_parent()) {
middle_button_table.remove (gpm.peak_display);
}
if (solo_button->get_parent()) {
middle_button_table.remove (*solo_button);
}
@ -538,6 +547,8 @@ MixerStrip::set_route (boost::shared_ptr<Route> rt)
}
gpm.reset_peak_display ();
gpm.gain_display.show ();
gpm.peak_display.show ();
width_button.show();
width_hide_box.show();
@ -554,6 +565,7 @@ MixerStrip::set_route (boost::shared_ptr<Route> rt)
name_button.show();
_comment_button.show();
group_button.show();
gpm.gain_automation_state_button.show();
parameter_changed ("mixer-strip-visibility");
@ -593,14 +605,24 @@ MixerStrip::set_width_enum (Width w, void* owner)
switch (w) {
case Wide:
if (!gpm.peak_display.get_parent()) {
middle_button_table.attach (gpm.peak_display,1,2,1,2);
}
if (gpm.gain_display.get_parent()) {
middle_button_table.remove (gpm.gain_display);
}
if (!gpm.gain_display.get_parent()) {
middle_button_table.attach (gpm.gain_display,0,1,1,2);
}
if (show_sends_button) {
show_sends_button->set_text (_("Aux\nSends"));
show_sends_button->layout()->set_alignment (Pango::ALIGN_CENTER);
}
((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
gpm.gain_automation_style_button.set_text (
gpm.astyle_string(gain_automation->automation_style()));
((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
gpm.gain_automation_state_button.set_text (
gpm.astate_string(gain_automation->automation_state()));
if (_route->panner()) {
@ -618,6 +640,17 @@ MixerStrip::set_width_enum (Width w, void* owner)
break;
case Narrow:
if (gpm.peak_display.get_parent()) {
middle_button_table.remove (gpm.peak_display);
}
if (gpm.gain_display.get_parent()) {
middle_button_table.remove (gpm.gain_display);
}
if (!gpm.gain_display.get_parent()) {
middle_button_table.attach (gpm.gain_display,0,2,1,2);
}
if (show_sends_button) {
show_sends_button->set_text (_("Snd"));
}

View File

@ -123,7 +123,7 @@ Mixer_UI::Mixer_UI ()
group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
group_display.get_column (0)->set_expand(true);
group_display.get_column (1)->set_expand(false);
group_display.set_name ("LHSList");
group_display.set_name ("EditGroupList");
group_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
group_display.set_reorderable (true);
group_display.set_headers_visible (true);
@ -1791,7 +1791,7 @@ Mixer_UI::setup_track_display ()
track_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
track_display.get_column (0)->set_expand(true);
track_display.get_column (1)->set_expand(false);
track_display.set_name (X_("LHSList"));
track_display.set_name (X_("EditGroupList"));
track_display.get_selection()->set_mode (Gtk::SELECTION_NONE);
track_display.set_reorderable (true);
track_display.set_headers_visible (true);

View File

@ -117,7 +117,7 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session* sess, Canvas& c
, playlist_action_menu (0)
, mode_menu (0)
, color_mode_menu (0)
, gm (sess, slider, slider_desensitised, true, 115)
, gm (sess, slider, slider_desensitised, true, 125)
, _ignore_set_layer_display (false)
{
}
@ -205,11 +205,11 @@ RouteTimeAxisView::set_route (boost::shared_ptr<Route> rt)
}
controls_table.attach (route_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
Gtk::VBox* pad = manage (new Gtk::VBox);
pad->pack_start (gm.get_gain_slider(), false, false);
pad->pack_start (*manage (new Gtk::Label), true, true);
pad->show_all ();
controls_table.attach (*pad, 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
// Gtk::VBox* pad = manage (new Gtk::VBox);
// pad->pack_start (gm.get_gain_slider(), false, false);
// pad->pack_start (*manage (new Gtk::Label), true, true);
// pad->show_all ();
controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 3, 0);
ARDOUR_UI::instance()->set_tip(*solo_button,_("Solo"));
ARDOUR_UI::instance()->set_tip(*mute_button,_("Mute"));
@ -261,7 +261,7 @@ RouteTimeAxisView::set_route (boost::shared_ptr<Route> rt)
route_group_menu = new RouteGroupMenu (_session, plist);
gm.get_gain_slider().signal_scroll_event().connect(sigc::mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
gm.get_gain_slider().set_name ("TrackGainFader");
gm.get_gain_slider().set_name ("GainFader");
gm.get_level_meter().signal_scroll_event().connect (sigc::mem_fun (*this, &RouteTimeAxisView::controls_ebox_scroll), false);

View File

@ -285,8 +285,8 @@ BarController::create_patterns ()
float rheight = darea.get_height()-2;
cairo_pattern_t* pat = cairo_pattern_create_linear (0.0, 0.0, 0.0, rheight);
cairo_pattern_add_color_stop_rgba (pat, 0, r*0.3,g*0.3,b*0.3, 1.0);
cairo_pattern_add_color_stop_rgba (pat, 1, r, g, b, 1.0);
cairo_pattern_add_color_stop_rgba (pat, 0, r*0.8,g*0.8,b*0.8, 1.0);
cairo_pattern_add_color_stop_rgba (pat, 1, r*0.6,g*0.6,b*0.6, 1.0);
Cairo::RefPtr<Cairo::Pattern> p (new Cairo::Pattern (pat, false));
pattern = p;
cairo_pattern_destroy(pat);
@ -439,44 +439,26 @@ BarController::expose (GdkEventExpose* /*event*/)
w = darea.get_width() - 2;
h = darea.get_height() - 2;
x2 = (gint) floor (w * (0.1+0.9*fract));
x2 = (gint) floor (w * fract);
y2 = h;
radius = 4;
if (x2 < 8) x2 = 8;
/* border */
/* border */
c = get_style()->get_bg (get_state());
r = c.get_red_p ();
g = c.get_green_p ();
b = c.get_blue_p ();
context->set_source_rgb (0,0,0);
rounded_rectangle (context, 0, 0, darea.get_width(), darea.get_height() , radius);
context->fill ();
context->set_source_rgb (0,0,0);
cairo_rectangle (context->cobj(), 0, 0, darea.get_width(), darea.get_height());
context->fill ();
/* draw active box */
c = get_style()->get_fg (get_state());
r = c.get_red_p ();
g = c.get_green_p ();
b = c.get_blue_p ();
context->set_source (pattern);
rounded_rectangle (context, 1, 1, x2, y2, radius-1.5);
context->fill ();
context->set_source (shine_pattern);
rounded_rectangle (context, 2, 3, x2-2, y2-8, radius-2);
context->fill ();
/* draw inactive box */
// c = get_style()->get_fg (STATE_INSENSITIVE);
// r = c.get_red_p ();
// g = c.get_green_p ();
// b = c.get_blue_p ();
// context->set_source_rgb (r, g, b);
// rounded_rectangle (context, 1 + x2, 1 + y1, w - x2, y2);
// context->fill ();
context->set_source (pattern);
rounded_rectangle (context, 1, 1, x2, y2, radius-1.5);
context->fill ();
// context->set_source (shine_pattern);
// rounded_rectangle (context, 2, 3, x2-2, y2-8, radius-2);
// context->fill ();
break;
case RightToLeft:

View File

@ -40,12 +40,11 @@ class PixFader : public Gtk::DrawingArea
void set_default_value (float);
void create_patterns ();
protected:
Gtk::Adjustment& adjustment;
void on_size_request (GtkRequisition*);
void on_size_allocate (Gtk::Allocation& alloc);
bool on_expose_event (GdkEventExpose*);
bool on_button_press_event (GdkEventButton*);
@ -72,9 +71,6 @@ class PixFader : public Gtk::DrawingArea
Cairo::RefPtr<Cairo::ImageSurface> belt_surface[STATES];
Glib::RefPtr<Gdk::Pixbuf> pixbuf[STATES];
Cairo::RefPtr<Cairo::Pattern> pattern;
Cairo::RefPtr<Cairo::Pattern> shine_pattern;
int span, girth;
int _orien;
float left_r;
@ -86,6 +82,12 @@ class PixFader : public Gtk::DrawingArea
GdkRectangle view;
void create_patterns();
cairo_pattern_t* pattern;
cairo_pattern_t* shine_pattern;
bool _hovering;
GdkWindow* grab_window;
double grab_loc;
double grab_start;

View File

@ -23,11 +23,15 @@
#include "gtkmm2ext/pixfader.h"
#include "gtkmm2ext/keyboard.h"
#include "gtkmm2ext/rgb_macros.h"
#include "gtkmm2ext/utils.h"
using namespace Gtkmm2ext;
using namespace Gtk;
using namespace std;
#define CORNER_RADIUS 4
#define FADER_RESERVE (2*CORNER_RADIUS)
PixFader::PixFader (
Glib::RefPtr<Gdk::Pixbuf> belt,
Glib::RefPtr<Gdk::Pixbuf> belt_desensitised,
@ -41,6 +45,10 @@ PixFader::PixFader (
pixbuf[NORMAL] = belt;
pixbuf[DESENSITISED] = belt_desensitised;
pattern = 0;
shine_pattern = 0;
_hovering = false;
dragging = false;
default_value = adjustment.get_value();
last_drawn = -1;
@ -49,9 +57,9 @@ PixFader::PixFader (
view.y = 0;
if (orientation == VERT) {
view.width = girth = pixbuf[0]->get_width();
view.width = girth = 24;
} else {
view.height = girth = pixbuf[0]->get_height();
view.height = girth = 24;
}
set_fader_length (fader_length);
@ -103,66 +111,93 @@ PixFader::set_border_colors (uint32_t left, uint32_t right)
right_b = b/255.0;
}
void
PixFader::create_patterns ()
{
Gdk::Color c = get_style()->get_fg (get_state());
float r, g, b;
r = c.get_red_p ();
g = c.get_green_p ();
b = c.get_blue_p ();
if (_orien == VERT) {
pattern = cairo_pattern_create_linear (0.0, 0.0, get_width(), 0);
cairo_pattern_add_color_stop_rgba (pattern, 0, r*0.8,g*0.8,b*0.8, 1.0);
cairo_pattern_add_color_stop_rgba (pattern, 1, r*0.6,g*0.6,b*0.6, 1.0);
shine_pattern = cairo_pattern_create_linear (0.0, 0.0, 15, 0);
cairo_pattern_add_color_stop_rgba (shine_pattern, 0, 1,1,1,0.0);
cairo_pattern_add_color_stop_rgba (shine_pattern, 0.2, 1,1,1,0.3);
cairo_pattern_add_color_stop_rgba (shine_pattern, 0.5, 1,1,1,0.0);
cairo_pattern_add_color_stop_rgba (shine_pattern, 1, 1,1,1,0.0);
} else {
float rheight = get_height();
pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, rheight);
cairo_pattern_add_color_stop_rgba (pattern, 0, r*0.8,g*0.8,b*0.8, 1.0);
cairo_pattern_add_color_stop_rgba (pattern, 1, r*0.6,g*0.6,b*0.6, 1.0);
shine_pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, rheight);
cairo_pattern_add_color_stop_rgba (shine_pattern, 0, 1,1,1,0.0);
cairo_pattern_add_color_stop_rgba (shine_pattern, 0.2, 1,1,1,0.3);
cairo_pattern_add_color_stop_rgba (shine_pattern, 0.5, 1,1,1,0.0);
cairo_pattern_add_color_stop_rgba (shine_pattern, 1, 1,1,1,0.0);
}
}
bool
PixFader::on_expose_event (GdkEventExpose* ev)
{
int const pi = get_sensitive() ? NORMAL : DESENSITISED;
Cairo::RefPtr<Cairo::Context> context = get_window()->create_cairo_context();
int srcx, srcy;
int const ds = display_span ();
int offset_into_pixbuf = (int) floor (span / ((float) span / ds));
Cairo::RefPtr<Cairo::Context> context = get_window()->create_cairo_context();
cairo_t* cr = context->cobj();
/* account for fader lengths that are shorter than the fader pixbuf */
if (_orien == VERT) {
offset_into_pixbuf += pixbuf[pi]->get_height() / 2 - view.height;
} else {
offset_into_pixbuf += pixbuf[pi]->get_width() / 2 - view.width;
if (!pattern) {
create_patterns();
}
context->rectangle (ev->area.x, ev->area.y, ev->area.width, ev->area.height);
context->clip ();
if (_orien == VERT) {
srcx = 0;
srcy = offset_into_pixbuf;
} else {
srcx = offset_into_pixbuf;
srcy = 0;
}
// int const pi = get_sensitive() ? NORMAL : DESENSITISED;
int ds = display_span ();
/* fader */
float w = get_width();
float h = get_height();
float radius = CORNER_RADIUS;
context->save();
context->set_source (belt_surface[pi], -srcx, -srcy);
context->rectangle (0, 0, get_width(), get_height());
context->clip ();
context->paint();
context->restore();
/* black border */
/* bounding box lines (2 colors for nicer visuals) */
/* top and left side */
cairo_set_source_rgb (cr, 0,0,0);
cairo_rectangle (cr, 0, 0, w, h);
cairo_fill (cr);
context->set_line_width (1);
context->set_source_rgb (left_r, left_g, left_b);
context->move_to (view.width - 1, 0); /* upper right */
context->line_to (0, 0); /* upper left */
context->line_to (0, view.height - 1);/* lower left */
context->stroke ();
/* draw active box */
/* bottom & right side */
if (_orien == VERT) {
if (ds > h - FADER_RESERVE)
ds = h - FADER_RESERVE;
context->set_line_width (1);
context->set_source_rgb (right_r, right_g, right_b);
context->move_to (0, view.height - 0.5); /* lower left */
context->line_to (view.width - 0.5, view.height - 0.5); /* lower right */
context->line_to (view.width - 0.5, 0); /* upper right */
context->stroke ();
cairo_set_source (cr, pattern);
Gtkmm2ext::rounded_rectangle (cr, 1, 1+ds, w-2, h-(1+ds)-1, radius-1.5);
cairo_fill (cr);
// cairo_set_source (cr, shine_pattern);
// Gtkmm2ext::rounded_rectangle (cr, 2, ds, w-4, h-(1+ds)-1, radius-1.5);
// cairo_fill (cr);
} else {
if (ds < FADER_RESERVE)
ds = FADER_RESERVE;
cairo_set_source (cr, pattern);
Gtkmm2ext::rounded_rectangle (cr, 1, 1, ds-1, h-2, radius-1.5);
cairo_fill (cr);
// cairo_set_source (cr, shine_pattern);
// Gtkmm2ext::rounded_rectangle (cr, 2, 3, ds-1, 15, radius-1.5);
// cairo_fill (cr);
}
/* always draw the unity-position line */
if (_orien == VERT) {
context->set_line_width (1);
context->set_source_rgb (0.0, 1.0, 0.0);
@ -173,10 +208,18 @@ PixFader::on_expose_event (GdkEventExpose* ev)
context->set_line_width (1);
context->set_source_rgb (0.0, 1.0, 0.0);
context->move_to (unity_loc, 1);
context->line_to (unity_loc, girth - 1);
context->line_to (unity_loc, girth);
context->stroke ();
}
// if (Config->get_widget_prelight()) { //pixfader does not have access to config
if (_hovering) {
Gtkmm2ext::rounded_rectangle (cr, 0, 0, get_width(), get_height(), 3);
cairo_set_source_rgba (cr, 0.905, 0.917, 0.925, 0.2);
cairo_fill (cr);
}
// }
last_drawn = ds;
return true;
@ -189,6 +232,21 @@ PixFader::on_size_request (GtkRequisition* req)
req->height = view.height;
}
void
PixFader::on_size_allocate (Gtk::Allocation& alloc)
{
DrawingArea::on_size_allocate(alloc);
if (_orien == VERT) {
view.height = span = alloc.get_height();
} else {
view.width = span = alloc.get_width();
}
update_unity_position ();
queue_draw ();
}
bool
PixFader::on_button_press_event (GdkEventButton* ev)
{
@ -370,7 +428,14 @@ int
PixFader::display_span ()
{
float fract = (adjustment.get_value () - adjustment.get_lower()) / ((adjustment.get_upper() - adjustment.get_lower()));
return (_orien != VERT) ? (int)floor (span * (1.0 - fract)) : (int)floor (span * fract);
int ds;
if (_orien == VERT) {
ds = (int)floor ( span * (1.0 - fract));
} else {
ds = (int)floor (span * fract);
}
return ds;
}
void
@ -402,14 +467,18 @@ PixFader::update_unity_position ()
bool
PixFader::on_enter_notify_event (GdkEventCrossing*)
{
_hovering = true;
Keyboard::magic_widget_grab_focus ();
queue_draw ();
return false;
}
bool
PixFader::on_leave_notify_event (GdkEventCrossing*)
{
_hovering = false;
Keyboard::magic_widget_drop_focus();
queue_draw ();
return false;
}