add a selection materializer
authorgc <gc>
Sun, 22 Jul 2007 21:37:34 +0000 (21:37 +0000)
committergc <gc>
Sun, 22 Jul 2007 21:37:34 +0000 (21:37 +0000)
bin/booh-classifier
data/booh/images/arrow_towards_up.png [new file with mode: 0644]

index 5946142..d5fa14a 100644 (file)
@@ -230,7 +230,7 @@ class Entry
         return @@thumbnails_height
     end
 
-    attr_accessor :path, :type, :angle, :button, :image, :removed, :labeled
+    attr_accessor :path, :type, :angle, :button, :image, :selection_materializer, :removed, :labeled
 
     def initialize(path, type)
         @path = path
@@ -797,10 +797,22 @@ def real_show_entry(entry, tooltips, grab_focus)
             entry.button = Gtk::Button.new.set_image(entry.image)
         end
         tooltips.set_tip(entry.button, File.basename(entry.path).gsub(/\.[^.]+$/, ''), nil)
-        $imagesline.pack_start(entry.button.show_all, false, false)
-        entry.button.signal_connect('clicked') { $mainview.set_shown_entry(entry) }
+        entry.selection_materializer = Gtk::DrawingArea.new.set_size_request($selection_materializer_pixbuf.width, $selection_materializer_pixbuf.height)
+        selection_materializer_drawer = proc {
+            entry.selection_materializer.window.draw_pixbuf(nil, $selection_materializer_pixbuf, 0, 0, 0, 0, -1, -1, Gdk::RGB::DITHER_NONE, -1, -1)
+        }
+        $imagesline.pack_start(Gtk::VBox.new(false, 0).pack_start(entry.button, false, false).
+                                                       pack_start(Gtk::Alignment.new(0.5, 0.5, 0, 0).add(entry.selection_materializer), false, false).show_all, false, false)
+        entry.button.signal_connect('clicked') {
+            if (last_shown = $mainview.get_shown_entry) != entry
+                $mainview.set_shown_entry(entry)
+                selection_materializer_drawer.call
+                last_shown.nil? or last_shown.selection_materializer.window.clear
+            end
+        }
         entry.button.signal_connect('focus-in-event') { entry.button.clicked; autoscroll_if_needed(entry.button) }
         entry.button.signal_connect('key-press-event') { |w, e| thumbnail_keypressed(entry, e) }
+        entry.selection_materializer.signal_connect('expose-event') { $mainview.get_shown_entry == entry and selection_materializer_drawer.call }
         if grab_focus
             entry.button.grab_focus
         end
@@ -1298,6 +1310,8 @@ def create_main_window
     $videoborder_pixbuf = Gdk::Pixbuf.new("#{$FPATH}/images/video_border.png")
     $videoborder_pixmap, = $videoborder_pixbuf.render_pixmap_and_mask(0)
 
+    $selection_materializer_pixbuf = Gdk::Pixbuf.new("#{$FPATH}/images/arrow_towards_up.png")
+
     mb = create_menubar
 
     main_vbox = Gtk::VBox.new(false, 0)
@@ -1313,7 +1327,7 @@ def create_main_window
     main_vbox.pack_start($imagesline_sw, false, false)
     main_vbox.pack_end($statusbar = Gtk::Statusbar.new, false, false)
 
-    $imagesline.set_size_request(-1, Entry.thumbnails_height + $imagesline_sw.hscrollbar.size_request[1])
+    $imagesline.set_size_request(-1, Gtk::Button.new.size_request[1] + Entry.thumbnails_height + $selection_materializer_pixbuf.height)
 
     $main_window = Gtk::Window.new
     $main_window.add(main_vbox)
diff --git a/data/booh/images/arrow_towards_up.png b/data/booh/images/arrow_towards_up.png
new file mode 100644 (file)
index 0000000..a97dcbe
Binary files /dev/null and b/data/booh/images/arrow_towards_up.png differ