[shotwell: 2/5] reset to primary image when mouse leaves the eventdirectoryitem
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell: 2/5] reset to primary image when mouse leaves the eventdirectoryitem
- Date: Mon, 9 Jul 2018 20:20:12 +0000 (UTC)
commit c05969607aab6811ad79f7b26e3e93f125384077
Author: Carsten Csiky (csicar) <carsten csiky gmail com>
Date: Wed Feb 28 19:12:44 2018 +0100
reset to primary image when mouse leaves the eventdirectoryitem
renamed hgithlighted to current_hovered_item and call unbrighten from
handle_mouse_leave
src/CheckerboardLayout.vala | 9 +++++++++
src/Page.vala | 18 +++++++++---------
src/events/EventDirectoryItem.vala | 6 +++++-
3 files changed, 23 insertions(+), 10 deletions(-)
---
diff --git a/src/CheckerboardLayout.vala b/src/CheckerboardLayout.vala
index 5b5d0921..18955c9c 100644
--- a/src/CheckerboardLayout.vala
+++ b/src/CheckerboardLayout.vala
@@ -344,6 +344,14 @@ public abstract class CheckerboardItem : ThumbnailView {
}
+ public virtual void handle_mouse_leave() {
+ unbrighten();
+ }
+
+ public virtual void handle_mouse_enter() {
+ brighten();
+ }
+
protected override void notify_membership_changed(DataCollection? collection) {
bool title_visible = (bool) get_collection_property(PROP_SHOW_TITLES, true);
bool comment_visible = (bool) get_collection_property(PROP_SHOW_COMMENTS, true);
@@ -770,6 +778,7 @@ public abstract class CheckerboardItem : ThumbnailView {
notify_view_altered();
}
+
public void unbrighten() {
// "should", "can", "didn't already"
if (brightened == null || pixbuf == null)
diff --git a/src/Page.vala b/src/Page.vala
index ea8606e0..9980a436 100644
--- a/src/Page.vala
+++ b/src/Page.vala
@@ -1222,7 +1222,7 @@ public abstract class CheckerboardPage : Page {
private Gtk.Viewport viewport = new Gtk.Viewport(null, null);
protected CheckerboardItem anchor = null;
protected CheckerboardItem cursor = null;
- private CheckerboardItem highlighted = null;
+ private CheckerboardItem current_hovered_item = null;
private bool autoscroll_scheduled = false;
private CheckerboardItem activated_item = null;
private Gee.ArrayList<CheckerboardItem> previously_selected = null;
@@ -1446,8 +1446,8 @@ public abstract class CheckerboardPage : Page {
if (cursor == item)
cursor = null;
- if (highlighted == item)
- highlighted = null;
+ if (current_hovered_item == item)
+ current_hovered_item = null;
}
}
@@ -1715,13 +1715,13 @@ public abstract class CheckerboardPage : Page {
// if hovering over the last hovered item, or both are null (nothing highlighted and
// hovering over empty space), do nothing
- if (item == highlighted)
+ if (item == current_hovered_item)
return true;
// either something new is highlighted or now hovering over empty space, so dim old item
- if (highlighted != null) {
- highlighted.unbrighten();
- highlighted = null;
+ if (current_hovered_item != null) {
+ current_hovered_item.handle_mouse_leave();
+ current_hovered_item = null;
}
// if over empty space, done
@@ -1729,8 +1729,8 @@ public abstract class CheckerboardPage : Page {
return true;
// brighten the new item
- item.brighten();
- highlighted = item;
+ current_hovered_item = item;
+ current_hovered_item.handle_mouse_enter();
return true;
}
diff --git a/src/events/EventDirectoryItem.vala b/src/events/EventDirectoryItem.vala
index 84343dd3..d943af84 100644
--- a/src/events/EventDirectoryItem.vala
+++ b/src/events/EventDirectoryItem.vala
@@ -166,10 +166,14 @@ class EventDirectoryItem : CheckerboardItem {
base.thumbnail_altered();
}
+ public override void handle_mouse_leave() {
+ base.handle_mouse_leave();
+ set_paul_lynde(event.get_primary_source());
+ }
+
public override void handle_mouse_motion(int x, int y, int height, int width) {
int element_index = (int) Math.round( (double) x / width * (event.get_media_count() - 1) );
unowned MediaSource media = event.get_media().to_array()[element_index];
-
set_paul_lynde(media);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]