end
end
-def autoscroll_if_needed(button)
+def autoscroll_if_needed(button, center)
xpos_left = button.allocation.x
xpos_right = button.allocation.x + button.allocation.width
hadj = $imagesline_sw.hadjustment
current_minx_visible = hadj.value
current_maxx_visible = hadj.value + hadj.page_size
- if xpos_left < current_minx_visible
- #- autoscroll left
- newval = hadj.value - (current_minx_visible - xpos_left)
- hadj.value = newval
- button.queue_draw #- TOREMOVE: the visual focus is displayed incorrectly
- elsif xpos_right > current_maxx_visible
- #- autoscroll right
- newval = hadj.value + (xpos_right - current_maxx_visible)
- if newval > hadj.upper - hadj.page_size
- newval = hadj.upper - hadj.page_size
+ if ! center
+ if xpos_left < current_minx_visible
+ #- autoscroll left
+ newval = hadj.value - (current_minx_visible - xpos_left)
+ hadj.value = newval
+ elsif xpos_right > current_maxx_visible
+ #- autoscroll right
+ newval = hadj.value + (xpos_right - current_maxx_visible)
+ if newval > hadj.upper - hadj.page_size
+ newval = hadj.upper - hadj.page_size
+ end
+ hadj.value = newval
end
- hadj.value = newval
- button.queue_draw #- TOREMOVE: the visual focus is displayed incorrectly
+ else
+ hadj.value = clamp((xpos_left + xpos_right) / 2 - hadj.page_size / 2, 0, hadj.upper - hadj.page_size)
end
end
end
if event.keyval == Gdk::Keyval::GDK_space
shown = $mainview.get_shown_entry
- shown and autoscroll_if_needed(shown.button)
+ shown and autoscroll_if_needed(shown.button, true)
end
else
if shown != entry
shown and shown.alignment.set(0.5, 1, 0, 0)
entry.alignment.set(0.5, 0, 0, 0)
- autoscroll_if_needed(entry.button)
+ autoscroll_if_needed(entry.button, false)
$mainview.set_shown_entry(entry)
end
}
<span foreground='darkblue'>Space</span>: clear any label on current image
<span foreground='darkblue'>Control-z</span>: undo
<span foreground='darkblue'>Control-r</span>: redo
-<span foreground='darkblue'>Control-Space</span>: autoscroll thumbnails to view current item
+<span foreground='darkblue'>Control-Space</span>: recenter thumbnails on current item
Any alphabetical key will assign (or popup for) the associated label on current image.
")), { :pos_centered => true, :not_transient => true })