r7027 - bigboard/trunk/bigboard
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r7027 - bigboard/trunk/bigboard
- Date: Tue, 11 Dec 2007 16:11:48 -0600 (CST)
Author: hp
Date: 2007-12-11 16:11:48 -0600 (Tue, 11 Dec 2007)
New Revision: 7027
Modified:
bigboard/trunk/bigboard/scroll_ribbon.py
Log:
implement hiding/showing the scroll buttons in the scroll ribbon as appropriate
Modified: bigboard/trunk/bigboard/scroll_ribbon.py
===================================================================
--- bigboard/trunk/bigboard/scroll_ribbon.py 2007-12-11 22:02:04 UTC (rev 7026)
+++ bigboard/trunk/bigboard/scroll_ribbon.py 2007-12-11 22:11:48 UTC (rev 7027)
@@ -26,10 +26,10 @@
self.__box.emit_request_changed()
def __on_up_clicked(self, button):
- self.scroll_by(-5)
+ self.scroll_by(5)
def __on_down_clicked(self, button):
- self.scroll_by(5)
+ self.scroll_by(-5)
def add(self, child):
if self.__box == None:
@@ -107,21 +107,9 @@
(up_min, up_natural) = self.__get_height_request(self.__up_button, width)
(down_min, down_natural) = self.__get_height_request(self.__down_button, width)
- box_child = self.__box.find_box_child(self.__up_button)
- box_child.x = 0
- box_child.y = 0
- box_child.allocate(box_child.x, box_child.y, width, up_natural, origin_changed)
+ (child_min, child_natural) = (0, 0)
- box_child = self.__box.find_box_child(self.__down_button)
- box_child.x = 0
- box_child.y = height - down_natural
- box_child.allocate(box_child.x, box_child.y, width, down_natural, origin_changed)
-
- self.viewport.x = 0
- self.viewport.y = up_natural
- self.viewport.width = width
- self.viewport.height = height - down_natural - up_natural
-
+ contents_child = None
## this only works with a single child right now, despite the loop.
## add a box, put stuff in the box, if you want two children.
for box_child in self.__box.get_layout_children():
@@ -130,30 +118,60 @@
if box_child.is_contents:
(child_min, child_natural) = box_child.get_height_request(width)
-
- # min offset has bottom of child aligned with bottom of viewport,
- # but if there's too much space for child, child is always top-aligned
- min_offset = self.viewport.height - child_natural
- if min_offset > 0:
- min_offset = 0
+ contents_child = box_child
- # max offset has top of child aligned with top of viewport
- max_offset = 0
+ ## decide if we need any buttons
+ if child_natural <= height:
+ # no buttons
+ up_natural = 0
+ down_natural = 0
- offset = max(self.__offset, min_offset)
- offset = min(offset, max_offset)
+ self.viewport.x = 0
+ self.viewport.y = up_natural
+ self.viewport.width = width
+ self.viewport.height = height - down_natural - up_natural
- ## save this new offset
- self.__offset = offset
+ # min offset has bottom of child aligned with bottom of viewport,
+ # but if there's too much space for child, child is always top-aligned
+ min_offset = self.viewport.height - child_natural
+ if min_offset > 0:
+ min_offset = 0
+
+ # max offset has top of child aligned with top of viewport
+ max_offset = 0
+
+ offset = max(self.__offset, min_offset)
+ offset = min(offset, max_offset)
- # we always allocate the child its full height; then we
- # don't draw the parts outside the viewport
- box_child.x = 0
- box_child.y = self.viewport.y + self.__offset
- box_child.allocate(box_child.x, box_child.y, width,
- child_natural, origin_changed)
+ ## save this new offset
+ self.__offset = offset
+ ## nuke the top button if needed
+ if self.__offset == 0:
+ self.viewport.height = self.viewport.height + up_natural
+ self.viewport.y = self.viewport.y - up_natural
+ up_natural = 0
+ ## now allocate
+ box_child = self.__box.find_box_child(self.__up_button)
+ box_child.x = 0
+ box_child.y = 0
+ box_child.allocate(box_child.x, box_child.y, width, up_natural, origin_changed)
+
+ box_child = self.__box.find_box_child(self.__down_button)
+ box_child.x = 0
+ box_child.y = height - down_natural
+ box_child.allocate(box_child.x, box_child.y, width, down_natural, origin_changed)
+
+ if contents_child:
+ # we always allocate the child its full height; then we
+ # don't draw the parts outside the viewport
+ contents_child.x = 0
+ contents_child.y = self.viewport.y + self.__offset
+ contents_child.allocate(contents_child.x, contents_child.y, width,
+ child_natural, origin_changed)
+
+
gobject.type_register(ScrollRibbonLayout)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]