reset to primary image when mouse leaves the eventdirectoryitem

renamed hgithlighted to current_hovered_item and call unbrighten from
handle_mouse_leave
parent d50f68d0
......@@ -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)
......
......@@ -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;
}
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment