Commit bd084d05 authored by Jens Georg's avatar Jens Georg

Merge branch 'image-scrubbing-squashed' into 'master'

Image scrubbing

See merge request !4
parents 0d8a1f08 cd78ba08
......@@ -345,6 +345,18 @@ public abstract class CheckerboardItem : ThumbnailView {
return is_cursor;
}
public virtual void handle_mouse_motion(int x, int y, int height, int width) {
}
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);
......@@ -762,6 +774,7 @@ public abstract class CheckerboardItem : ThumbnailView {
notify_view_altered();
}
public void unbrighten() {
// "should", "can", "didn't already"
if (brightened == null || pixbuf == null)
......@@ -1276,6 +1289,11 @@ public class CheckerboardLayout : Gtk.DrawingArea {
}
public bool handle_mouse_motion(CheckerboardItem item, int x, int y, Gdk.ModifierType mask) {
int dx = x - item.allocation.x;
int dy = y - item.allocation.y;
item.handle_mouse_motion(dx, dy, item.allocation.height, item.allocation.width);
if (!item.has_tags || is_drag_select_active())
return false;
int tag_index = internal_handle_tag_mouse_event(item, x, y);
......
......@@ -1219,7 +1219,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;
......@@ -1443,8 +1443,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;
}
}
......@@ -1712,13 +1712,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
......@@ -1726,8 +1726,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;
}
......
......@@ -146,6 +146,10 @@ class EventDirectoryItem : CheckerboardItem {
protected override void thumbnail_altered() {
MediaSource media = event.get_primary_source();
set_paul_lynde(media);
}
private void set_paul_lynde(MediaSource media) {
// get new center square
paul_lynde = get_paul_lynde_rect(media);
......@@ -158,11 +162,23 @@ class EventDirectoryItem : CheckerboardItem {
} else {
clear_image(Dimensions.for_rectangle(paul_lynde));
}
base.thumbnail_altered();
}
protected override void paint_shadow(Cairo.Context ctx, Dimensions dimensions, Gdk.Point origin,
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 steppedX = x - (x % 15);
int element_index = (int) Math.round( (double) steppedX / width * (event.get_media_count() - 1) );
unowned MediaSource media = event.get_media().to_array()[element_index];
set_paul_lynde(media);
}
protected override void paint_shadow(Cairo.Context ctx, Dimensions dimensions, Gdk.Point origin,
int radius, float initial_alpha) {
Dimensions altered = Dimensions(dimensions.width - 25, dimensions.height - 25);
base.paint_shadow(ctx, altered, origin, 36, initial_alpha);
......
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