def __init__(self, text, color, listener, signaltype, ): self.canvas= pygame.Surface( ( self.WIDTH, self.HEIGTH ) ) self.color= color self.color2= Gcolor.darken(self.color, 0.2) self.highlight_color= self.color.mix(self.color.WHITE, 0.5) self.text_color= Gcolor.darken( self.highlight_color, 0.1) self.color= color.get() self.label= self.FONT.render(text, True, self.text_color) self.signaltype= signaltype self.listener= listener self.draw();
def __init__(self, color, valuerange, labels, trackablegraph, sender): self.listeners=[] self.gWIDTH= self.WIDTH-4*self.TAB self.gHEIGTH= self.HEIGTH- 4*self.TAB self.color= color self.graph_color= self.color.darken(0.05) self.line_color= self.color.chill(0.8) self.line_thickness= 1 self.support_line_color= self.color.darken(0.3) self.highlight_color= self.color.mix(self.color.WHITE, 0.5) self.text_color= Gcolor.darken( self.highlight_color, 0.1) self.color= self.color.get() #self.header= self.FONT.render(text, True, self.text_color) self.xlabel= self.FONT.render(labels[0], True, self.text_color) self.ylabel= self.FONT.render(labels[1], True, self.text_color) self.ylabel= pygame.transform.rotate(self.ylabel, 90) self.canvas= pygame.Surface( ( self.WIDTH, self.HEIGTH ) ) self.graph= pygame.Surface( ( self.gWIDTH, self.gHEIGTH ) ) self.min_value= valuerange[0] self.max_value= valuerange[1] self.trackablegraph= trackablegraph self.values= trackablegraph.content self.gjoin(sender) self.draw()
def __init__(self, text, color): self.HEIGTH self.canvas= pygame.Surface( ( self.WIDTH, self.HEIGTH) ) self.color= color self.text_color= Gcolor.darken( self.color.mix(self.color.WHITE, 0.5), 0.1) draw.rect(self.canvas, self.color.get(), ( (0, 0), (self.WIDTH, self.HEIGTH) )) self.canvas.blit( self.FONT.render(text, True, self.text_color), (self.TAB, 0) )
def __init__(self, text, color): self.HEIGTH self.canvas= pygame.Surface( ( self.WIDTH, self.HEIGTH) ) self.color= color self.text_color= Gcolor.darken( self.color.mix(self.color.WHITE, 0.5), 0.1) pygame.draw.rect(self.canvas, self.color.get(), ( (0, 0), (self.WIDTH, self.HEIGTH) )) self.canvas.blit( self.FONT.render(text, True, self.text_color), (self.TAB, 0) )
def update(self): for i in range(len(self.widget_list)): if self.widget_list[i]: self.widget_list[i].update() self.canvas.blit(self.widget_list[i].canvas, (0, i*widget.BASE_HEIGTH)) for i in range(len(self.widget_list)): if self.widget_list[i] and i !=0: pygame.draw.aaline(self.canvas, Gcolor.darken(self.color.illuminate(), 0.4), (widget.Widget.TAB, widget.Widget.BASE_HEIGTH*i), (widget.Widget.WIDTH - 2*widget.Widget.TAB, widget.Widget.BASE_HEIGTH*i), True)
def __init__(self, text, color, sender): self.canvas= pygame.Surface( ( self.WIDTH, self.HEIGTH ) ) self.color= color self.highlight_color= self.color.mix(self.color.WHITE, 0.5) self.text_color= Gcolor.darken( self.highlight_color, 0.1) self.header= self.FONT.render(text, True, self.text_color) self.content= "" sender.set_listener(self)
def __init__(self, text, color, canvas): self.color= color self.canvas= canvas self.text=text #draw strap pygame.draw.rect(self.canvas, Gcolor.darken(self.color.burn( 0.9), 0.5), ( (0, 0), (Banner.STRAP_WIDTH, Banner.HEIGTH) ) ) #draw main pygame.draw.rect(self.canvas, self.color.get(), ( (Banner.STRAP_WIDTH, 0), (Banner.WIDTH-Banner.STRAP_WIDTH, Banner.HEIGTH) ) ) self.canvas.blit(self.text, (Banner.STRAP_WIDTH*2, 0) )
def update(self): for i in range(len(self.widget_list)): if self.widget_list[i]: self.widget_list[i].update() self.canvas.blit(self.widget_list[i].canvas, (0, i * widget.BASE_HEIGTH)) for i in range(len(self.widget_list)): if self.widget_list[i] and i != 0: pygame.draw.aaline( self.canvas, Gcolor.darken(self.color.illuminate(), 0.4), (widget.Widget.TAB, widget.Widget.BASE_HEIGTH * i), (widget.Widget.WIDTH - 2 * widget.Widget.TAB, widget.Widget.BASE_HEIGTH * i), True)
def __init__(self, text, color, canvas): self.color = color self.canvas = canvas self.text = text #draw strap pygame.draw.rect(self.canvas, Gcolor.darken(self.color.burn(0.9), 0.5), ((0, 0), (Banner.STRAP_WIDTH, Banner.HEIGTH))) #draw main pygame.draw.rect(self.canvas, self.color.get(), ((Banner.STRAP_WIDTH, 0), (Banner.WIDTH - Banner.STRAP_WIDTH, Banner.HEIGTH))) self.canvas.blit(self.text, (Banner.STRAP_WIDTH * 2, 0))
def __init__(self, text, color, scrollist, return_index, signaltype, listener): self.canvas= pygame.Surface( ( self.WIDTH, self.HEIGTH ) ) self.color= color self.highlight_color= self.color.mix(self.color.WHITE, 0.5) self.text_color= Gcolor.darken( self.highlight_color, 0.1) self.header= self.FONT.render(text, True, self.text_color) self.scrollist= scrollist self.return_index= return_index # self.signaltype= signaltype self.send= listener.read_signal self.tick= 0 self.nogoodnameyet()
def __init__(self, canvas, ptype, color, index, listener): self.canvas= canvas self.ptype= ptype self.color= color self.text_color= Gcolor.darken( self.color.mix(self.color.WHITE, 0.5), 0.1 ) self.text= self.FONT.render(ptype, True, self.text_color) self.index= index self.listener= listener widget_list=[ widget.Label(self.ptype, self.color) ] if self.ptype == "Camera": from celestial_cluster import CelestialCluster from perspective import Perspective widget_list+= [ widget.Scrollbar("Lock on", self.color, CelestialCluster.cluster, False, gsignal.ACTION, Perspective) ] elif self.ptype == "Graph": from celestial_cluster import CelestialCluster widget_list+= [ widget.Scrollbar("Measure", self.color, CelestialCluster.word_list, True, gsignal.WATCH0, CelestialCluster) , widget.Scrollbar("Between", self.color, CelestialCluster.cluster, False, gsignal.WATCH1, CelestialCluster) , widget.Scrollbar("And", self.color, CelestialCluster.cluster, False, gsignal.WATCH2, CelestialCluster) , widget.DynamicGraph( self.color, CelestialCluster) , None , None , None , None ] elif self.ptype == "Erase": from celestial_cluster import CelestialCluster widget1= widget.BoundButton("Confirm", self.color, CelestialCluster, gsignal.DELETE, ) widget2= widget.Scrollbar("Erase", self.color, CelestialCluster.cluster, False, gsignal.ACTION, widget1) widget_list+= [ widget2, widget1 ] #if self.ptype == "Create": # widget_list+= [ self.banner= Banner(self.text, self.color, pygame.Surface((Banner.WIDTH, Banner.HEIGTH) ) ) self.body= Body( self.text, self.text_color, self.color, widget_list) self.active= False self.mouse_over= False self.busy= False self.tick= 0 self.tick2= 0
def __init__(self, text, color, scrollist, return_index, signaltype, listener): self.canvas = pygame.Surface((self.WIDTH, self.HEIGTH)) self.color = color self.highlight_color = self.color.mix(self.color.WHITE, 0.5) self.text_color = Gcolor.darken(self.highlight_color, 0.1) self.header = self.FONT.render(text, True, self.text_color) self.scrollist = scrollist self.return_index = return_index # self.signaltype = signaltype self.send = listener.read_signal self.tick = 0 self.nogoodnameyet()
def __init__(self, color, sender): self.canvas= pygame.Surface( ( self.WIDTH, self.HEIGTH ) ) self.color= color self.graph_color= self.color.darken(0.05) self.line_color= self.color.chill(0.8) self.line_thickness= 1 self.support_line_color= self.color.darken(0.3) self.highlight_color= self.color.mix(self.color.WHITE, 0.5) self.text_color= Gcolor.darken( self.highlight_color, 0.1) self.color= self.color.get() #self.header= self.FONT.render(text, True, self.text_color) self.gWIDTH= self.WIDTH-4*self.TAB self.gHEIGTH= self.HEIGTH- 4*self.TAB self.min_value= 0 self.max_value= 0 self.min_is_set= False self.max_is_set= False sender.set_listener(self)
def __init__(self, text, color, trackablelist, return_index, listener, signal=gsignal.SELECT): #self.listeners= [] #self.gjoin(listener) self.listener= listener self.canvas= pygame.Surface( ( self.WIDTH, self.HEIGTH ) ) self.color= color self.highlight_color= self.color.mix(self.color.WHITE, 0.5) self.text_color= Gcolor.darken( self.highlight_color, 0.1) self.header= self.FONT.render(text, True, self.text_color) self.trackablelist= trackablelist self.tick= trackablelist.iterator self.return_index= return_index self.signal= signal self.target=None self.retarget() self.draw()
def __init__(self, color, valuerange, labels, sender): self.listeners= [] self.canvas= pygame.Surface( ( self.WIDTH, self.HEIGTH ) ) self.color= color self.graph_color= self.color.darken(0.05) self.line_color= self.color.chill(0.8) self.line_thickness= 1 self.support_line_color= self.color.darken(0.3) self.highlight_color= self.color.mix(self.color.WHITE, 0.5) self.text_color= Gcolor.darken( self.highlight_color, 0.1) self.color= self.color.get() #self.header= self.FONT.render(text, True, self.text_color) self.gWIDTH= self.WIDTH-4*self.TAB self.gHEIGTH= self.HEIGTH- 4*self.TAB self.min_value= 0 self.max_value= 0 self.min_is_set= False self.max_is_set= False if (valuerange!= None): self.min_value= valuerange[0] self.max_value= valuerange[1] self.min_is_set= True self.max_is_set= True self.content=None self.xlabel= self.FONT.render(labels[0], True, self.text_color) self.ylabel= self.FONT.render(labels[1], True, self.text_color) self.ylabel= pygame.transform.rotate(self.ylabel, 90) #TODO: consertar essa gambiarra de listener2 self.gjoin(sender) self.draw()
def __init__(self, canvas, name, color, index, display, trackables): self.listeners = [] self.canvas = canvas self.name = name self.color = color self.text_color = Gcolor.darken(self.color.mix(self.color.WHITE, 0.5), 0.1) self.text = self.FONT.render(name, True, self.text_color) self.index = index self.display = self.gjoin(display) widget_list = [widget.Label(self.name, self.color)] ''' if self.ptype == "Camera": widget_list+= [ widget.Scrollbar("Lock on", self.color, trackable[1], False, gsignal.ACTION, trackable) ] ''' #TODO: consertar esta desgraça de gambiarra que estou fazendo: Panel.DEBUGAUDIOTRACK = trackables self.active = False self.mouse_over = False self.busy = False self.tick = 0 self.tick2 = 0 if self.name == "Audio": widget_list += [ widget.Scrollbar("Track:", self.color, Panel.DEBUGAUDIOTRACK.tracknames, True, Panel.DEBUGAUDIOTRACK), widget.StaticGraph(self.color, [-1, 1], ["Tempo", "Intensidade"], Panel.DEBUGAUDIOTRACK.trackablegraph, Panel.DEBUGAUDIOTRACK), None, None, None, None, widget.Scrollbar("Display:", self.color, Panel.DEBUGAUDIOTRACK.displaymode, True, Panel.DEBUGAUDIOTRACK, signal=gsignal.SELECT2), widget.BoundButton('Play', self.color, Panel.DEBUGAUDIOTRACK, gsignal.ACTION) ] if self.name == "Recording": widget_list += [ widget.DynamicGraph2(self.color, [-1, 1], ["Tempo", "Intensidade"], Panel.DEBUGAUDIOTRACK), None, None, None, None, widget.BoundButton('Record', self.color, Panel.DEBUGAUDIOTRACK, gsignal.ACTION2), widget.Scrollbar("Display:", self.color, Panel.DEBUGAUDIOTRACK.displaymode, True, Panel.DEBUGAUDIOTRACK, signal=gsignal.SELECT2), widget.BoundButton('Save', self.color, Panel.DEBUGAUDIOTRACK, gsignal.SAVE) ] if self.name == "Modulation": widget_list += [ widget.Scrollbar("Track:", self.color, Panel.DEBUGAUDIOTRACK.tracknames, True, Panel.DEBUGAUDIOTRACK), widget.StaticGraph(self.color, [-1, 1], ["Tempo", "Intensidade"], Panel.DEBUGAUDIOTRACK.trackablegraph, Panel.DEBUGAUDIOTRACK), None, None, None, None, widget.Scrollbar("Display:", self.color, Panel.DEBUGAUDIOTRACK.displaymode, True, Panel.DEBUGAUDIOTRACK, signal=gsignal.SELECT2), widget.Scrollbar("Set as:", self.color, gsignal.Trackable(["Signal", "Carrier"]), True, Panel.DEBUGAUDIOTRACK, signal=gsignal.SELECT4), widget.BoundButton('Save', self.color, Panel.DEBUGAUDIOTRACK, gsignal.ACTION3) ] if self.name == "Demodulation": widget_list += [ widget.Scrollbar("Track:", self.color, Panel.DEBUGAUDIOTRACK.tracknames, True, Panel.DEBUGAUDIOTRACK), widget.StaticGraph(self.color, [-1, 1], ["Tempo", "Intensidade"], Panel.DEBUGAUDIOTRACK.trackablegraph, Panel.DEBUGAUDIOTRACK), None, None, None, None, widget.Scrollbar("Display:", self.color, Panel.DEBUGAUDIOTRACK.displaymode, True, Panel.DEBUGAUDIOTRACK, signal=gsignal.SELECT2), widget.Scrollbar("Break in: ", self.color, Panel.DEBUGAUDIOTRACK.breakin, True, Panel.DEBUGAUDIOTRACK, signal=gsignal.NOACT), widget.BoundButton('Save', self.color, Panel.DEBUGAUDIOTRACK, gsignal.ACTION5) ] if self.name == "Add Waves": widget_list += [ widget.Scrollbar("Track:", self.color, Panel.DEBUGAUDIOTRACK.tracknames, True, Panel.DEBUGAUDIOTRACK), widget.StaticGraph(self.color, [-1, 1], ["Tempo", "Intensidade"], Panel.DEBUGAUDIOTRACK.trackablegraph, Panel.DEBUGAUDIOTRACK), None, None, None, None, widget.Scrollbar("Display:", self.color, Panel.DEBUGAUDIOTRACK.displaymode, True, Panel.DEBUGAUDIOTRACK, signal=gsignal.SELECT2), widget.Scrollbar("Set as:", self.color, gsignal.Trackable( ["First Signal", "Second Signal"]), True, Panel.DEBUGAUDIOTRACK, signal=gsignal.SELECT4), widget.BoundButton('Save', self.color, Panel.DEBUGAUDIOTRACK, gsignal.ACTION4) ] ''' if self.ptype == "Erase": widget1= widget.BoundButton("Confirm", self.color, tracable, gsignal.DELETE, ) widget2= widget.Scrollbar("Erase", self.color, trackable[0], False, gsignal.ACTION, widget1) widget_list+= [ widget2, widget1 ] ''' #if self.ptype == "Create": # widget_list+= [ self.banner = Banner(self.text, self.color, pygame.Surface((Banner.WIDTH, Banner.HEIGTH))) self.body = self.gjoin( Body(self.text, self.text_color, self.color, widget_list))
def init(): Sidebar.MENU= [ Panel(Sidebar.CANVAS.subsurface( (0, 0), (Panel.WIDTH, Panel.HEIGTH) ), "Camera", Gcolor( Gcolor.darken( Gcolor.chill(Gcolor.EARTH, 0.7), 0.7) ), 0, Sidebar) , Panel(Sidebar.CANVAS.subsurface( (0, 0), (Panel.WIDTH, Panel.HEIGTH) ), "Create", Gcolor( Gcolor.darken( Gcolor.chill(Gcolor.VENUS, 0.7), 0.7) ), 1, Sidebar) , Panel(Sidebar.CANVAS.subsurface( (0, 0), (Panel.WIDTH, Panel.HEIGTH) ), "Erase", Gcolor( Gcolor.darken( Gcolor.chill(Gcolor.MARS, 0.7), 0.7) ), 2, Sidebar) , Panel(Sidebar.CANVAS.subsurface( (0, 0), (Panel.WIDTH, Panel.HEIGTH) ), "Graph", Gcolor( Gcolor.darken( Gcolor.chill(Gcolor.URANUS, 0.7), 0.7) ), 3, Sidebar) , Panel(Sidebar.CANVAS.subsurface( (0, 0), (Panel.WIDTH, Panel.HEIGTH) ), "Time", Gcolor( Gcolor.darken( Gcolor.chill(Gcolor.SATURN, 0.7), 0.7) ), 4, Sidebar) , Panel(Sidebar.CANVAS.subsurface( (0, 0), (Panel.WIDTH, Panel.HEIGTH) ), "Save", Gcolor( Gcolor.darken( Gcolor.chill(Gcolor.NEPTUNE, 0.7), 0.7) ), 5, Sidebar) ]
def init(): #TODO:depois tirar o audiotrack daqui audio.AudioTrack.init() Sidebar.MENU= [ #Panel(Sidebar.CANVAS.subsurface( (0, 0), (Panel.WIDTH, Panel.HEIGTH) ), "Camera", Gcolor( Gcolor.darken( Gcolor.chill(Gcolor.EARTH, 0.7), 0.7) ), 0, Sidebar) , #Panel(Sidebar.CANVAS.subsurface( (0, 0), (Panel.WIDTH, Panel.HEIGTH) ), "Create", Gcolor( Gcolor.darken( Gcolor.chill(Gcolor.VENUS, 0.7), 0.7) ), 1, Sidebar) , #Panel(Sidebar.CANVAS.subsurface( (0, 0), (Panel.WIDTH, Panel.HEIGTH) ), "Erase", Gcolor( Gcolor.darken( Gcolor.chill(Gcolor.MARS, 0.7), 0.7) ), 2, Sidebar) , Panel(Sidebar.CANVAS.subsurface( (0, 0), (Panel.WIDTH, Panel.HEIGTH) ), "Audio", Gcolor( Gcolor.darken( Gcolor.chill(Gcolor.URANUS, 0.7), 0.7) ), 0, Sidebar, audio.AudioTrack) , Panel(Sidebar.CANVAS.subsurface( (0, 0), (Panel.WIDTH, Panel.HEIGTH) ), "Modulation", Gcolor( Gcolor.darken( Gcolor.chill(Gcolor.VENUS, 0.7), 0.7) ), 1, Sidebar, audio.AudioTrack) , Panel(Sidebar.CANVAS.subsurface( (0, 0), (Panel.WIDTH, Panel.HEIGTH) ), "Demodulation", Gcolor( Gcolor.darken( Gcolor.chill(Gcolor.SATURN, 0.7), 0.7) ), 2, Sidebar, audio.AudioTrack) , Panel(Sidebar.CANVAS.subsurface( (0, 0), (Panel.WIDTH, Panel.HEIGTH) ), "Add Waves", Gcolor( Gcolor.darken( Gcolor.chill(Gcolor.EARTH, 0.7), 0.7) ), 3, Sidebar, audio.AudioTrack) , Panel(Sidebar.CANVAS.subsurface( (0, 0), (Panel.WIDTH, Panel.HEIGTH) ), "Recording", Gcolor( Gcolor.darken( Gcolor.chill(Gcolor.MARS, 0.7), 0.7) ), 4, Sidebar, audio.AudioTrack) ]
def __init__(self, canvas, ptype, color, index, listener): self.canvas = canvas self.ptype = ptype self.color = color self.text_color = Gcolor.darken(self.color.mix(self.color.WHITE, 0.5), 0.1) self.text = self.FONT.render(ptype, True, self.text_color) self.index = index self.listener = listener widget_list = [widget.Label(self.ptype, self.color)] if self.ptype == "Camera": from celestial_cluster import CelestialCluster from perspective import Perspective widget_list += [ widget.Scrollbar("Lock on", self.color, CelestialCluster.cluster, False, gsignal.ACTION, Perspective) ] elif self.ptype == "Graph": from celestial_cluster import CelestialCluster widget_list += [ widget.Scrollbar("Measure", self.color, CelestialCluster.word_list, True, gsignal.WATCH0, CelestialCluster), widget.Scrollbar("Between", self.color, CelestialCluster.cluster, False, gsignal.WATCH1, CelestialCluster), widget.Scrollbar("And", self.color, CelestialCluster.cluster, False, gsignal.WATCH2, CelestialCluster), widget.DynamicGraph(self.color, CelestialCluster), None, None, None, None ] elif self.ptype == "Erase": from celestial_cluster import CelestialCluster widget1 = widget.BoundButton( "Confirm", self.color, CelestialCluster, gsignal.DELETE, ) widget2 = widget.Scrollbar("Erase", self.color, CelestialCluster.cluster, False, gsignal.ACTION, widget1) widget_list += [widget2, widget1] #if self.ptype == "Create": # widget_list+= [ self.banner = Banner(self.text, self.color, pygame.Surface((Banner.WIDTH, Banner.HEIGTH))) self.body = Body(self.text, self.text_color, self.color, widget_list) self.active = False self.mouse_over = False self.busy = False self.tick = 0 self.tick2 = 0