mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 06:44:57 +01:00
allow ardour button to handle focused keyboard events
This commit is contained in:
parent
e977b659af
commit
bb2970e5e9
2 changed files with 45 additions and 0 deletions
|
|
@ -86,6 +86,7 @@ ArdourButton::ArdourButton (Element e)
|
|||
, _fixed_diameter (true)
|
||||
, _distinct_led_click (false)
|
||||
, _hovering (false)
|
||||
, _focused (false)
|
||||
{
|
||||
ColorsChanged.connect (sigc::mem_fun (*this, &ArdourButton::color_handler));
|
||||
}
|
||||
|
|
@ -122,6 +123,7 @@ ArdourButton::ArdourButton (const std::string& str, Element e)
|
|||
, _fixed_diameter (true)
|
||||
, _distinct_led_click (false)
|
||||
, _hovering (false)
|
||||
, _focused (false)
|
||||
{
|
||||
set_text (str);
|
||||
}
|
||||
|
|
@ -447,6 +449,14 @@ ArdourButton::render (cairo_t* cr, cairo_rectangle_t *)
|
|||
cairo_fill (cr);
|
||||
}
|
||||
}
|
||||
if (_focused) {
|
||||
rounded_function (cr, 0, 0, get_width(), get_height(), _corner_radius);
|
||||
cairo_set_source_rgba (cr, 0.905, 0.917, 0.925, 0.5);
|
||||
double dashes = 1;
|
||||
cairo_set_dash (cr, &dashes, 1, 0);
|
||||
cairo_stroke (cr);
|
||||
cairo_set_dash (cr, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -921,6 +931,37 @@ ArdourButton::set_visual_state (Gtkmm2ext::VisualState s)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ArdourButton::on_focus_in_event (GdkEventFocus* ev)
|
||||
{
|
||||
_focused = true;
|
||||
queue_draw ();
|
||||
return CairoWidget::on_focus_in_event (ev);
|
||||
}
|
||||
|
||||
bool
|
||||
ArdourButton::on_focus_out_event (GdkEventFocus* ev)
|
||||
{
|
||||
_focused = false;
|
||||
queue_draw ();
|
||||
return CairoWidget::on_focus_out_event (ev);
|
||||
}
|
||||
|
||||
bool
|
||||
ArdourButton::on_key_release_event (GdkEventKey *ev) {
|
||||
if (_focused &&
|
||||
(ev->keyval == GDK_KEY_space || ev->keyval == GDK_Return))
|
||||
{
|
||||
signal_clicked();
|
||||
if (_action) {
|
||||
_action->activate ();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return CairoWidget::on_key_release_event (ev);
|
||||
}
|
||||
|
||||
bool
|
||||
ArdourButton::on_enter_notify_event (GdkEventCrossing* ev)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -108,6 +108,9 @@ class ArdourButton : public CairoWidget , public Gtkmm2ext::Activatable
|
|||
void on_name_changed ();
|
||||
bool on_enter_notify_event (GdkEventCrossing*);
|
||||
bool on_leave_notify_event (GdkEventCrossing*);
|
||||
bool on_focus_in_event (GdkEventFocus*);
|
||||
bool on_focus_out_event (GdkEventFocus*);
|
||||
bool on_key_release_event (GdkEventKey *);
|
||||
|
||||
void controllable_changed ();
|
||||
PBD::ScopedConnection watch_connection;
|
||||
|
|
@ -168,6 +171,7 @@ class ArdourButton : public CairoWidget , public Gtkmm2ext::Activatable
|
|||
bool _fixed_diameter;
|
||||
bool _distinct_led_click;
|
||||
bool _hovering;
|
||||
bool _focused;
|
||||
|
||||
static bool _flat_buttons;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue