[shotwell] Make Histogram keyboard accessible
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell] Make Histogram keyboard accessible
- Date: Fri, 15 Dec 2017 04:24:38 +0000 (UTC)
commit 476ccb26f086585de4b8c2a9bd0dd3c6dd6c5ba4
Author: Jens Georg <mail jensge org>
Date: Fri Dec 15 05:21:03 2017 +0100
Make Histogram keyboard accessible
Histogram can now be used by keyboard as follows:
- Left/Right key will move the manipulator
- Shift will select which manipulator is used. No Shift => left
manipulator, Shift => right manipulator
- Normal increase or decrease is 5. Using CTRL this can be modified to 1
https://bugzilla.gnome.org/show_bug.cgi?id=716431
src/editing_tools/RGBHistogramManipulator.vala | 59 ++++++++++++++++++++++++
1 files changed, 59 insertions(+), 0 deletions(-)
---
diff --git a/src/editing_tools/RGBHistogramManipulator.vala b/src/editing_tools/RGBHistogramManipulator.vala
index 381907c..a3355e4 100644
--- a/src/editing_tools/RGBHistogramManipulator.vala
+++ b/src/editing_tools/RGBHistogramManipulator.vala
@@ -34,6 +34,7 @@ public class RGBHistogramManipulator : Gtk.DrawingArea {
public RGBHistogramManipulator( ) {
set_size_request(CONTROL_WIDTH, CONTROL_HEIGHT);
+ can_focus = true;
if (!paths_setup) {
slider_draw_path.append_type(typeof(Gtk.Scale));
@@ -49,6 +50,8 @@ public class RGBHistogramManipulator : Gtk.DrawingArea {
add_events(Gdk.EventMask.BUTTON_PRESS_MASK);
add_events(Gdk.EventMask.BUTTON_RELEASE_MASK);
add_events(Gdk.EventMask.BUTTON_MOTION_MASK);
+ add_events(Gdk.EventMask.FOCUS_CHANGE_MASK);
+ add_events(Gdk.EventMask.KEY_PRESS_MASK);
button_press_event.connect(on_button_press);
button_release_event.connect(on_button_release);
@@ -141,9 +144,59 @@ public class RGBHistogramManipulator : Gtk.DrawingArea {
force_update();
return true;
}
+
+ public override bool focus_out_event(Gdk.EventFocus event) {
+ if (base.focus_out_event(event)) {
+ return true;
+ }
+
+ queue_draw();
+
+ return false;
+ }
+
+ public override bool key_press_event(Gdk.EventKey event) {
+ if (base.key_press_event(event)) {
+ return true;
+ }
+
+ int delta = 0;
+
+ if (event.keyval == Gdk.Key.Left || event.keyval == Gdk.Key.Up) {
+ delta = -1;
+ }
+
+ if (event.keyval == Gdk.Key.Right || event.keyval == Gdk.Key.Down) {
+ delta = 1;
+ }
+
+ if (!(Gdk.ModifierType.CONTROL_MASK in event.state)) {
+ delta *= 5;
+ }
+
+ if (delta == 0) {
+ return false;
+ }
+
+ if (Gdk.ModifierType.SHIFT_MASK in event.state) {
+ right_nub_position += delta;
+ right_nub_position = right_nub_position.clamp(right_nub_min, 255);
+ } else {
+ left_nub_position += delta;
+ left_nub_position = left_nub_position.clamp(0, left_nub_max);
+
+ }
+
+ nub_position_changed();
+ update_nub_extrema();
+ force_update();
+
+ return true;
+ }
public override bool draw(Cairo.Context ctx) {
Gtk.Border padding = get_style_context().get_padding(Gtk.StateFlags.NORMAL);
+
Gdk.Rectangle area = Gdk.Rectangle();
area.x = padding.left;
@@ -151,6 +204,12 @@ public class RGBHistogramManipulator : Gtk.DrawingArea {
area.width = RGBHistogram.GRAPHIC_WIDTH + padding.right;
area.height = RGBHistogram.GRAPHIC_HEIGHT + padding.bottom;
+ if (has_focus) {
+ get_style_context().render_focus(ctx, area.x, area.y,
+ area.width + NUB_SIZE,
+ area.height + NUB_SIZE + NUB_HALF_WIDTH);
+ }
+
draw_histogram(ctx, area);
draw_nub(ctx, area, left_nub_position);
draw_nub(ctx, area, right_nub_position);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]