def __init__(self, **kwargs): self.hover_color = (0.6, 0.6, 1, 1) self.default_color = 1,1,1,1 self.icon = None self.__callback = None self.is_hovering = False self.fade_time = .25 self.set_style("Button", kwargs) Widget.__init__(self, **kwargs)
def __init__(self, **kwargs): self.hover_color = (0.6, 0.6, 1, 1) self.default_color = 1, 1, 1, 1 self.icon = None self.__callback = None self.is_hovering = False self.fade_time = .25 self.set_style("Button", kwargs) Widget.__init__(self, **kwargs)
def render(self): planes = ( (ctypes.c_double*4)(-1.0, 0, 0.0, self.x+self.shape.width), (ctypes.c_double*4)(0, 2, 0.0, -self.y*2), (ctypes.c_double*4)(2, 0, 0.0, max(-self.x-self.shape.width,0)), (ctypes.c_double*4)(0, -1, 0.0, self.y+self.shape.height), ) enums = [GL_CLIP_PLANE1, GL_CLIP_PLANE2, GL_CLIP_PLANE3, GL_CLIP_PLANE4] for i,p in enumerate(planes): glClipPlane(enums[i], p) glEnable(enums[i]) Widget.render(self) for i,p in enumerate(planes): glDisable(enums[i])
def _icon(self, icon): self.icon = Widget(texture=icon, shape=self.shape) self.icon.xy = self.attrgetter("xy") self.icon.alpha = self.attrgetter("alpha") self.icon.scale_x = self.attrgetter("scale_x") self.icon.scale_y = self.attrgetter("scale_y") self.add(self.icon)
def render(self): planes = ( (ctypes.c_double * 4)(-1.0, 0, 0.0, self.x + self.shape.width), (ctypes.c_double * 4)(0, 2, 0.0, -self.y * 2), (ctypes.c_double * 4)(2, 0, 0.0, max(-self.x - self.shape.width, 0)), (ctypes.c_double * 4)(0, -1, 0.0, self.y + self.shape.height), ) enums = [ GL_CLIP_PLANE1, GL_CLIP_PLANE2, GL_CLIP_PLANE3, GL_CLIP_PLANE4 ] for i, p in enumerate(planes): glClipPlane(enums[i], p) glEnable(enums[i]) Widget.render(self) for i, p in enumerate(planes): glDisable(enums[i])
def __init__(self, **kwargs): self.drag_button = None self.scroll_range_x = (0,0) self.scroll_range_y = (0,0) self.set_style("Pan", kwargs) Widget.__init__(self, **kwargs) self.bounds = "rect" # We assign ``rx`` and ``ry`` to get our scroll widget to use relative # positioning. self.scroll = Widget(bounds="always", rx=0, ry=0) Widget.add(self, self.scroll) self.add = self.scroll.add self.remove = self.scroll.remove self.__hovering = False self.__down = False
def __init__(self, **kwargs): self.drag_button = None self.scroll_range_x = (0, 0) self.scroll_range_y = (0, 0) self.set_style("Pan", kwargs) Widget.__init__(self, **kwargs) self.bounds = "rect" # We assign ``rx`` and ``ry`` to get our scroll widget to use relative # positioning. self.scroll = Widget(bounds="always", rx=0, ry=0) Widget.add(self, self.scroll) self.add = self.scroll.add self.remove = self.scroll.remove self.__hovering = False self.__down = False
def __init__(self, **kwargs): self.inwidgets = [] self.set_style("ScrollBox", kwargs) Widget.__init__(self, **kwargs) self.bounds = "rect" nshape = rabbyt.Quad(self.shape) l = nshape.left nshape.width -= 20 nshape.left = l self.pan = Pan(texture=self.get_style("ScrollBox.Pan"), shape=nshape, rx=0, ry=0) Widget.add(self, self.pan) self.scroll_bar = ScrollBar( pan_to_scroll=self.pan, texture=self.get_style("ScrollBox.ScrollBar"), shape=(0, self.shape.height, 20, 0), rx=self.shape.width - 20, ry=0) Widget.add(self, self.scroll_bar)
def __init__(self, pan_to_scroll, **kwargs): self.pan_to_scroll = pan_to_scroll self.set_style("ScrollBar", kwargs) Pan.__init__(self, drag_button=mouse.LEFT, **kwargs) self.scroll_range_y = (-self.shape.height + 40, 0) self.block = Widget(texture=self.get_style("ScrollBar.block"), shape=(0, 40, 20, 0), rx=0, ry=self.shape.height - 40) self.add(self.block)
def __init__(self, **kwargs): self.inwidgets = [] self.set_style("ScrollBox", kwargs) Widget.__init__(self, **kwargs) self.bounds = "rect" nshape = rabbyt.Quad(self.shape) l = nshape.left nshape.width -= 20 nshape.left = l self.pan = Pan(texture=self.get_style("ScrollBox.Pan"), shape=nshape, rx=0, ry=0) Widget.add(self, self.pan) self.scroll_bar = ScrollBar(pan_to_scroll=self.pan, texture=self.get_style("ScrollBox.ScrollBar"), shape=(0,self.shape.height,20,0), rx=self.shape.width-20, ry=0) Widget.add(self, self.scroll_bar)
def __init__(self, **kwargs): Widget.__init__(self, **kwargs) EventDispatcher.__init__(self) if not self.bounds: self.bounds = "always" self.is_focused = True
def do_blur(self): Widget.do_blur(self) if self.is_hovering: self.do_fade(self.rgba, self.default_color) self.is_hovering = False