Conclusively fixed selector bar positioning bugs :)
This commit is contained in:
parent
a80ef8740c
commit
718e142557
33
GlossMgr.py
33
GlossMgr.py
|
@ -4,6 +4,7 @@ from Spinner import Spinner
|
||||||
import pygtk
|
import pygtk
|
||||||
import gtk
|
import gtk
|
||||||
import pango
|
import pango
|
||||||
|
import copy
|
||||||
|
|
||||||
class GlossMgr:
|
class GlossMgr:
|
||||||
|
|
||||||
|
@ -34,7 +35,8 @@ class GlossMgr:
|
||||||
self.currentMenu = newMenu
|
self.currentMenu = newMenu
|
||||||
self.menuHistory.append(newMenu)
|
self.menuHistory.append(newMenu)
|
||||||
self.currentMenu.getItemGroup().show_all()
|
self.currentMenu.getItemGroup().show_all()
|
||||||
self.currentMenu.getMenuGroup().show_all()
|
self.currentMenu.show_all()
|
||||||
|
self.currentMenu.show()
|
||||||
self.selector_bar.set_menu(self.currentMenu)
|
self.selector_bar.set_menu(self.currentMenu)
|
||||||
|
|
||||||
def get_selector_bar(self):
|
def get_selector_bar(self):
|
||||||
|
@ -193,18 +195,29 @@ class MenuSelector(clutter.Texture):
|
||||||
|
|
||||||
|
|
||||||
def selectItem(self, selectee, timeline):
|
def selectItem(self, selectee, timeline):
|
||||||
(x, y) = selectee.get_abs_position()
|
|
||||||
|
|
||||||
|
#This whole clone label thing is a HORRIBLE hack but is there to compensate for the movement caused by scaling using GRAVITY_WEST
|
||||||
|
#Essentially a clone of the selectee is made and scaled to its final position to retrieve the final abs_position coords
|
||||||
|
cloneLabel = clutter.Label()
|
||||||
|
cloneLabel.set_text(selectee.get_text())
|
||||||
|
cloneLabel.set_font_name(selectee.get_font_name())
|
||||||
|
(scale_x, scale_y) = selectee.get_scale()
|
||||||
|
cloneLabel.set_scale_with_gravity(scale_x, scale_y, clutter.GRAVITY_WEST)
|
||||||
|
selectee.get_parent().add(cloneLabel)
|
||||||
|
cloneLabel.set_position(selectee.get_x(), selectee.get_y())
|
||||||
|
|
||||||
|
#Now that all the cloning is done, find out what the scale is to become and set it on the clone
|
||||||
|
scale = selectee.currentZoom
|
||||||
|
cloneLabel.set_scale_with_gravity(scale, scale, clutter.GRAVITY_WEST)
|
||||||
|
|
||||||
|
#Now get the end position of the clone
|
||||||
|
(x, y) = cloneLabel.get_abs_position()
|
||||||
|
|
||||||
|
#Do some minor adjustments for centering etc
|
||||||
x = x + self.x_offset
|
x = x + self.x_offset
|
||||||
|
y = y - int( (self.get_height()-selectee.get_height())/2 )
|
||||||
|
|
||||||
#Check if we're going up or down
|
#Move the bar
|
||||||
if y > self.get_y():
|
|
||||||
#Going down
|
|
||||||
y = int(y - selectee.get_menu().get_item_gap()/2)
|
|
||||||
else:
|
|
||||||
#Going up
|
|
||||||
y = int(y - selectee.get_menu().get_item_gap()/2)
|
|
||||||
|
|
||||||
self.move_to(x, y, timeline)
|
self.move_to(x, y, timeline)
|
||||||
|
|
||||||
def move_to(self, x, y, timeline):
|
def move_to(self, x, y, timeline):
|
||||||
|
|
44
Menu.py
44
Menu.py
|
@ -5,13 +5,14 @@ import pango
|
||||||
import time
|
import time
|
||||||
from ReflectionTexture import Texture_Reflection
|
from ReflectionTexture import Texture_Reflection
|
||||||
|
|
||||||
class Menu:
|
class Menu(clutter.Group):
|
||||||
item_gap = 10 #Distance between items
|
item_gap = 10 #Distance between items
|
||||||
font = ""
|
font = ""
|
||||||
zoomLevel = 0.5
|
zoomLevel = 0.5
|
||||||
opacityStep = 120
|
opacityStep = 120
|
||||||
|
|
||||||
def __init__ (self, glossMgr):
|
def __init__ (self, glossMgr):
|
||||||
|
clutter.Group.__init__(self)
|
||||||
self.glossMgr = glossMgr
|
self.glossMgr = glossMgr
|
||||||
self.stage = self.glossMgr.get_stage()
|
self.stage = self.glossMgr.get_stage()
|
||||||
self.glossMgr.themeMgr.setup_menu("main", self)
|
self.glossMgr.themeMgr.setup_menu("main", self)
|
||||||
|
@ -23,14 +24,15 @@ class Menu:
|
||||||
self.displaySize = self.displayMax - self.displayMin
|
self.displaySize = self.displayMax - self.displayMin
|
||||||
self.displayPosition = (0, 0)
|
self.displayPosition = (0, 0)
|
||||||
self.itemGroup = clutter.Group()
|
self.itemGroup = clutter.Group()
|
||||||
self.menuGroup = clutter.Group()
|
#self.menuGroup = clutter.Group()
|
||||||
self.stage.add(self.itemGroup)
|
self.stage.add(self.itemGroup)
|
||||||
self.stage.add(self.menuGroup)
|
#self.stage.add(self.menuGroup)
|
||||||
#self.hasTimeline = False
|
#self.hasTimeline = False
|
||||||
self.timeline = clutter.Timeline(15, 75) #This timeline is used on any movements that occur when changing items
|
self.timeline = clutter.Timeline(15, 75) #This timeline is used on any movements that occur when changing items
|
||||||
self.timeline_completed=True
|
self.timeline_completed=True
|
||||||
self.glossMgr.addMenu(self)
|
self.glossMgr.addMenu(self)
|
||||||
#self.itemGroup.hide_all()
|
#self.itemGroup.hide_all()
|
||||||
|
self.stage.add(self)
|
||||||
|
|
||||||
def addItem(self, itemLabel, imagePath):
|
def addItem(self, itemLabel, imagePath):
|
||||||
if len(self.menuItems) == 0:
|
if len(self.menuItems) == 0:
|
||||||
|
@ -127,7 +129,7 @@ class Menu:
|
||||||
for i in range(len(self.menuItems)):
|
for i in range(len(self.menuItems)):
|
||||||
if i == self.selected:
|
if i == self.selected:
|
||||||
self.menuItems[i].scaleLabel(0, self.timeline)
|
self.menuItems[i].scaleLabel(0, self.timeline)
|
||||||
elif (i == self.selected-1) and (i >= self.displayMin+1):
|
elif (i == self.selected-1) and (i >= self.displayMin):
|
||||||
self.menuItems[i].scaleLabel(1, self.timeline)
|
self.menuItems[i].scaleLabel(1, self.timeline)
|
||||||
elif (i == self.selected+1) and (i <= self.displayMax-1):
|
elif (i == self.selected+1) and (i <= self.displayMax-1):
|
||||||
self.menuItems[i].scaleLabel(1, self.timeline)
|
self.menuItems[i].scaleLabel(1, self.timeline)
|
||||||
|
@ -171,23 +173,17 @@ class Menu:
|
||||||
|
|
||||||
#This horrible loop does all the scaling
|
#This horrible loop does all the scaling
|
||||||
#This includes, the selected item and the ones on either side of it
|
#This includes, the selected item and the ones on either side of it
|
||||||
for i in range(len(self.menuItems)-1):
|
for i in range(len(self.menuItems)):
|
||||||
#print str(i)
|
#print str(i)
|
||||||
if i == self.selected:
|
if i == self.selected:
|
||||||
self.menuItems[i].scaleLabel(0, self.timeline)
|
self.menuItems[i].scaleLabel(0, self.timeline)
|
||||||
elif (i == self.selected-1) and (i >= self.displayMin+1):
|
elif (i == self.selected-1) and (i >= self.displayMin):
|
||||||
self.menuItems[i].scaleLabel(1, self.timeline)
|
self.menuItems[i].scaleLabel(1, self.timeline)
|
||||||
elif (i == self.selected+1) and (i <= self.displayMax-1):
|
elif (i == self.selected+1) and (i <= self.displayMax-1):
|
||||||
self.menuItems[i].scaleLabel(1, self.timeline)
|
self.menuItems[i].scaleLabel(1, self.timeline)
|
||||||
else:
|
else:
|
||||||
self.menuItems[i].scaleLabel(2, self.timeline)
|
self.menuItems[i].scaleLabel(2, self.timeline)
|
||||||
|
|
||||||
#This is a hack but it seems to fix a wierd bug (If rmeoving this, remove the -1 from the for loop above
|
|
||||||
if (self.selected == (len(self.menuItems)-2) ):
|
|
||||||
self.menuItems[len(self.menuItems)-1].scaleLabel(1, self.timeline)
|
|
||||||
if (self.selected == (len(self.menuItems)-3) ):
|
|
||||||
self.menuItems[len(self.menuItems)-1].scaleLabel(2, self.timeline)
|
|
||||||
|
|
||||||
#Check we're at the top of the viewable list
|
#Check we're at the top of the viewable list
|
||||||
if self.selected < (self.displayMin):
|
if self.selected < (self.displayMin):
|
||||||
#If yes, move the menu, leave the selection bar where is
|
#If yes, move the menu, leave the selection bar where is
|
||||||
|
@ -281,6 +277,7 @@ class ListItem (clutter.Label):
|
||||||
def __init__ (self, menu, itemLabel, y, imagePath):
|
def __init__ (self, menu, itemLabel, y, imagePath):
|
||||||
clutter.Label.__init__ (self)
|
clutter.Label.__init__ (self)
|
||||||
glossMgr = menu.getGlossMgr()
|
glossMgr = menu.getGlossMgr()
|
||||||
|
self.menu = menu
|
||||||
self.stage = glossMgr.get_stage()
|
self.stage = glossMgr.get_stage()
|
||||||
|
|
||||||
self.itemTexturesGroup = clutter.Group()
|
self.itemTexturesGroup = clutter.Group()
|
||||||
|
@ -290,12 +287,11 @@ class ListItem (clutter.Label):
|
||||||
self.color = clutter.Color(0xff, 0xff, 0xff, 0xdd)
|
self.color = clutter.Color(0xff, 0xff, 0xff, 0xdd)
|
||||||
self.set_color(self.color)
|
self.set_color(self.color)
|
||||||
self.currentOpacity = 255
|
self.currentOpacity = 255
|
||||||
self.menu = menu
|
|
||||||
self.data = itemLabel #By default the items data is simply its label
|
self.data = itemLabel #By default the items data is simply its label
|
||||||
#The width is the length of the selector bar minus its offset
|
#The width is the length of the selector bar minus its offset
|
||||||
width = glossMgr.get_selector_bar().get_width() + glossMgr.get_selector_bar().get_x_offset()
|
width = glossMgr.get_selector_bar().get_width() + glossMgr.get_selector_bar().get_x_offset()
|
||||||
self.set_width(width)
|
self.set_width(width)
|
||||||
#Pango ellipses seem to be having problems, disabling for now
|
|
||||||
self.set_ellipsize(pango.ELLIPSIZE_END)
|
self.set_ellipsize(pango.ELLIPSIZE_END)
|
||||||
#Text is actually scaled down in 'regular' position so that it doesn't get jaggies when zoomed in
|
#Text is actually scaled down in 'regular' position so that it doesn't get jaggies when zoomed in
|
||||||
self.set_scale(self.zoomLevel, self.zoomLevel)
|
self.set_scale(self.zoomLevel, self.zoomLevel)
|
||||||
|
@ -308,9 +304,9 @@ class ListItem (clutter.Label):
|
||||||
if not (imagePath == "" or imagePath is None):
|
if not (imagePath == "" or imagePath is None):
|
||||||
self.addImage(imagePath, True)
|
self.addImage(imagePath, True)
|
||||||
|
|
||||||
#Add textures group and hide it
|
#Add textures group and mark whether or not the textures are currently on the stage
|
||||||
self.menu.getMenuGroup().add(self.itemTexturesGroup)
|
self.itemTexturesGroup.show_all()
|
||||||
self.itemTexturesGroup.hide_all()
|
self.onStage = False
|
||||||
|
|
||||||
def scaleLabel(self, level, timeline):
|
def scaleLabel(self, level, timeline):
|
||||||
|
|
||||||
|
@ -320,15 +316,23 @@ class ListItem (clutter.Label):
|
||||||
if level==0:
|
if level==0:
|
||||||
zoomTo = self.menu.zoomStep0 #self.zoomLevel * 1.5
|
zoomTo = self.menu.zoomStep0 #self.zoomLevel * 1.5
|
||||||
opacityTo = self.menu.opacityStep0
|
opacityTo = self.menu.opacityStep0
|
||||||
self.itemTexturesGroup.show_all()
|
self.menu.add(self.itemTexturesGroup)
|
||||||
|
self.onStage = True
|
||||||
|
#self.itemTexturesGroup.show_all()
|
||||||
if level==1:
|
if level==1:
|
||||||
zoomTo = self.zoomLevel * self.menu.zoomStep1
|
zoomTo = self.zoomLevel * self.menu.zoomStep1
|
||||||
opacityTo = self.menu.opacityStep1
|
opacityTo = self.menu.opacityStep1
|
||||||
self.itemTexturesGroup.hide_all()
|
if self.onStage:
|
||||||
|
self.menu.remove(self.itemTexturesGroup)
|
||||||
|
self.onStage = False
|
||||||
|
#self.itemTexturesGroup.hide_all()
|
||||||
if level==2:
|
if level==2:
|
||||||
zoomTo = self.zoomLevel * self.menu.zoomStep2
|
zoomTo = self.zoomLevel * self.menu.zoomStep2
|
||||||
opacityTo = self.menu.opacityStep2
|
opacityTo = self.menu.opacityStep2
|
||||||
self.itemTexturesGroup.hide_all()
|
if self.onStage:
|
||||||
|
self.menu.remove(self.itemTexturesGroup)
|
||||||
|
self.onStage = False
|
||||||
|
#self.itemTexturesGroup.hide_all()
|
||||||
|
|
||||||
if zoomTo == self.currentZoom:
|
if zoomTo == self.currentZoom:
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in New Issue