[shotwell: 1/5] added scrubbing funktionality to directory items



commit d50f68d026749fea520786e366a396b777f558a4
Author: Carsten Csiky (csicar) <carsten csiky gmail com>
Date:   Sun Feb 25 19:28:49 2018 +0100

    added scrubbing funktionality to directory items

 src/CheckerboardLayout.vala        |  9 +++++++++
 src/events/EventDirectoryItem.vala | 15 +++++++++++++--
 2 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/src/CheckerboardLayout.vala b/src/CheckerboardLayout.vala
index d5086172..5b5d0921 100644
--- a/src/CheckerboardLayout.vala
+++ b/src/CheckerboardLayout.vala
@@ -340,6 +340,10 @@ public abstract class CheckerboardItem : ThumbnailView {
         return is_cursor;
     }
     
+    public virtual void handle_mouse_motion(int x, int y, int height, int width) {
+
+    }
+
     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);
@@ -1277,6 +1281,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);
diff --git a/src/events/EventDirectoryItem.vala b/src/events/EventDirectoryItem.vala
index f75a8e08..84343dd3 100644
--- a/src/events/EventDirectoryItem.vala
+++ b/src/events/EventDirectoryItem.vala
@@ -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,18 @@ 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_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);
+    }
+
+    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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]