From 42ca65d2e583639cdbb0a6af921ddf2dae75af54 Mon Sep 17 00:00:00 2001 From: amartin Date: Sun, 26 Aug 2007 11:40:41 +0000 Subject: Merge branch 'master' of git+ssh://amartin@dev.laptop.org/git/projects/tamtam --- (limited to 'Edit') diff --git a/Edit/EditToolbars.py b/Edit/EditToolbars.py index abd425d..10c47e8 100644 --- a/Edit/EditToolbars.py +++ b/Edit/EditToolbars.py @@ -40,7 +40,7 @@ class mainToolbar(gtk.Toolbar): self.toolbox = toolbox self.edit = edit - + self.tooltips = gtk.Tooltips() #Play button @@ -88,6 +88,8 @@ class mainToolbar(gtk.Toolbar): self.pointerButton = RadioToolButton('edit-pointer', group = None) self.pointerButton.set_palette(self._pointerPalette) self.pointerButton.connect('toggled', self.edit.handleToolClick, 'default') + self.pointerButton.get_child().connect('enter-notify-event', self.edit.blockFocus) + self.pointerButton.get_child().connect('leave-notify-event', self.edit.unblockFocus) self.insert(self.pointerButton, -1) self.pointerButton.show() @@ -96,6 +98,8 @@ class mainToolbar(gtk.Toolbar): self.drawButton = RadioToolButton('edit-pencil', group = self.pointerButton) self.drawButton.set_palette(self._drawPalette) self.drawButton.connect('toggled', self.edit.handleToolClick, 'draw') + self.drawButton.get_child().connect('enter-notify-event', self.edit.blockFocus) + self.drawButton.get_child().connect('leave-notify-event', self.edit.unblockFocus) self.insert(self.drawButton, -1) self.drawButton.show() @@ -104,6 +108,8 @@ class mainToolbar(gtk.Toolbar): self.paintButton = RadioToolButton('edit-brush', group = self.pointerButton) self.paintButton.set_palette(self._paintPalette) self.paintButton.connect('toggled', self.edit.handleToolClick, 'paint') + self.paintButton.get_child().connect('enter-notify-event', self.edit.blockFocus) + self.paintButton.get_child().connect('leave-notify-event', self.edit.unblockFocus) self.insert(self.paintButton, -1) self.paintButton.show() @@ -120,7 +126,8 @@ class mainToolbar(gtk.Toolbar): self._volumeTempoPalette = volumeTempoPalette(_('Volume / Tempo'), self.edit) self.volumeTempoButton = ToggleToolButton('voltemp') self.volumeTempoButton.set_palette(self._volumeTempoPalette) - #self.volumeTempoButton.connect(None) + self.volumeTempoButton.get_child().connect('enter-notify-event', self.edit.blockFocus) + self.volumeTempoButton.get_child().connect('leave-notify-event', self.edit.unblockFocus) self.insert(self.volumeTempoButton, -1) self.volumeTempoButton.show() @@ -178,6 +185,8 @@ class generateToolbar(gtk.Toolbar): self.generationButton = ToggleToolButton('dice') #self.generationButton.connect(None) self.generationButton.set_palette(self._generationPalette) + self.generationButton.get_child().connect('enter-notify-event', self.edit.blockFocus) + self.generationButton.get_child().connect('leave-notify-event', self.edit.unblockFocus) self.insert(self.generationButton, -1) self.generationButton.show() @@ -185,6 +194,8 @@ class generateToolbar(gtk.Toolbar): self._propertiesPalette = propertiesPalette(_('Properties'), self.edit) self.propsButton = ToggleToolButton('props') self.propsButton.set_palette(self._propertiesPalette) + self.propsButton.get_child().connect('enter-notify-event', self.edit.blockFocus) + self.propsButton.get_child().connect('leave-notify-event', self.edit.unblockFocus) self.insert(self.propsButton, -1) self.propsButton.show() diff --git a/Edit/MainWindow.py b/Edit/MainWindow.py index 6235eaf..1be07df 100644 --- a/Edit/MainWindow.py +++ b/Edit/MainWindow.py @@ -17,6 +17,7 @@ from EditToolbars import mainToolbar from EditToolbars import generateToolbar from gettext import gettext as _ from subprocess import Popen +from sugar.graphics.palette import Palette, WidgetInvoker import time import os import commands @@ -145,10 +146,12 @@ class MainWindow( SubActivity ): self.GUI["2instrument1muteButton"].connect("toggled",self.handlemuteButton,0) self.GUI["2instrument1muteButton"].connect("button-press-event",self.handlemuteButtonRightClick,0) self.GUI["2instrument1muteButton"].set_active(True) - self.GUI["2instrument1volBox"].pack_start( self.GUI["2instrument1volumeSlider"], True, True, 0 ) - self.GUI["2instrument1volBox"].pack_start( self.GUI["2instrument1muteButton"], False, False, 5 ) + #self.GUI["2instrument1volBox"].pack_start( self.GUI["2instrument1volumeSlider"], True, True, 0 ) + #self.GUI["2instrument1volBox"].pack_start( self.GUI["2instrument1muteButton"], False, False, 5 ) self.GUI["2instrument1Box"].pack_start( self.GUI["2instrument1volBox"], False, False, 0 ) self.GUI["2instrument1Button"] = InstrumentButton( self, 0, Config.BG_COLOR ) + self.GUI["2instrument1Palette"] = instrumentPalette(_('Track 1 Volume'), 0, self) + self.GUI["2instrument1Button"].set_palette(self.GUI["2instrument1Palette"]) self.GUI["2instrument1Button"].setPrimary( self.GUI["2instrumentIcons"][self.trackInstrument[0].name] ) self.GUI["2instrument1Box"].pack_start( self.GUI["2instrument1Button"], padding = 3 ) self.GUI["2instrumentPanel"].pack_start( self.GUI["2instrument1Box"] ) @@ -167,10 +170,12 @@ class MainWindow( SubActivity ): self.GUI["2instrument2muteButton"].connect("toggled",self.handlemuteButton,1) self.GUI["2instrument2muteButton"].connect("button-press-event",self.handlemuteButtonRightClick,1) self.GUI["2instrument2muteButton"].set_active(True) - self.GUI["2instrument2volBox"].pack_start( self.GUI["2instrument2volumeSlider"], True, True, 0 ) - self.GUI["2instrument2volBox"].pack_start( self.GUI["2instrument2muteButton"], False, False, 5 ) + #self.GUI["2instrument2volBox"].pack_start( self.GUI["2instrument2volumeSlider"], True, True, 0 ) + #self.GUI["2instrument2volBox"].pack_start( self.GUI["2instrument2muteButton"], False, False, 5 ) self.GUI["2instrument2Box"].pack_start( self.GUI["2instrument2volBox"], False, False, 0 ) self.GUI["2instrument2Button"] = InstrumentButton( self, 1, Config.BG_COLOR ) + self.GUI["2instrument2Palette"] = instrumentPalette(_('Track 2 Volume'), 1, self) + self.GUI["2instrument2Button"].set_palette(self.GUI["2instrument2Palette"]) self.GUI["2instrument2Button"].setPrimary( self.GUI["2instrumentIcons"][self.trackInstrument[1].name] ) self.GUI["2instrument2Box"].pack_start( self.GUI["2instrument2Button"], padding = 3 ) self.GUI["2instrumentPanel"].pack_start( self.GUI["2instrument2Box"] ) @@ -189,10 +194,12 @@ class MainWindow( SubActivity ): self.GUI["2instrument3muteButton"].connect("toggled",self.handlemuteButton,2) self.GUI["2instrument3muteButton"].connect("button-press-event",self.handlemuteButtonRightClick,2) self.GUI["2instrument3muteButton"].set_active(True) - self.GUI["2instrument3volBox"].pack_start( self.GUI["2instrument3volumeSlider"], True, True, 0 ) - self.GUI["2instrument3volBox"].pack_start( self.GUI["2instrument3muteButton"], False, False, 5 ) + #self.GUI["2instrument3volBox"].pack_start( self.GUI["2instrument3volumeSlider"], True, True, 0 ) + #self.GUI["2instrument3volBox"].pack_start( self.GUI["2instrument3muteButton"], False, False, 5 ) self.GUI["2instrument3Box"].pack_start( self.GUI["2instrument3volBox"], False, False, 0 ) self.GUI["2instrument3Button"] = InstrumentButton( self, 2, Config.BG_COLOR ) + self.GUI["2instrument3Palette"] = instrumentPalette(_('Track 3 Volume'), 2, self) + self.GUI["2instrument3Button"].set_palette(self.GUI["2instrument3Palette"]) self.GUI["2instrument3Button"].setPrimary( self.GUI["2instrumentIcons"][self.trackInstrument[2].name] ) self.GUI["2instrument3Box"].pack_start( self.GUI["2instrument3Button"], padding = 3 ) self.GUI["2instrumentPanel"].pack_start( self.GUI["2instrument3Box"] ) @@ -211,10 +218,12 @@ class MainWindow( SubActivity ): self.GUI["2instrument4muteButton"].connect("toggled",self.handlemuteButton,3) self.GUI["2instrument4muteButton"].connect("button-press-event",self.handlemuteButtonRightClick,3) self.GUI["2instrument4muteButton"].set_active(True) - self.GUI["2instrument4volBox"].pack_start( self.GUI["2instrument4volumeSlider"], True, True, 0 ) - self.GUI["2instrument4volBox"].pack_start( self.GUI["2instrument4muteButton"], False, False, 5 ) + #self.GUI["2instrument4volBox"].pack_start( self.GUI["2instrument4volumeSlider"], True, True, 0 ) + #self.GUI["2instrument4volBox"].pack_start( self.GUI["2instrument4muteButton"], False, False, 5 ) self.GUI["2instrument4Box"].pack_start( self.GUI["2instrument4volBox"], False, False, 0 ) self.GUI["2instrument4Button"] = InstrumentButton( self, 3, Config.BG_COLOR ) + self.GUI["2instrument4Palette"] = instrumentPalette(_('Track 4 Volume'), 3, self) + self.GUI["2instrument4Button"].set_palette(self.GUI["2instrument4Palette"]) self.GUI["2instrument4Button"].setPrimary( self.GUI["2instrumentIcons"][self.trackInstrument[3].name] ) self.GUI["2instrument4Box"].pack_start( self.GUI["2instrument4Button"], padding = 3 ) self.GUI["2instrumentPanel"].pack_start( self.GUI["2instrument4Box"] ) @@ -233,11 +242,15 @@ class MainWindow( SubActivity ): self.GUI["2drumMuteButton"].connect("toggled",self.handlemuteButton,4) self.GUI["2drumMuteButton"].connect("button-press-event",self.handlemuteButtonRightClick,4) self.GUI["2drumMuteButton"].set_active(True) - self.GUI["2drumVolBox"].pack_start( self.GUI["2drumvolumeSlider"], True, True, 0 ) - self.GUI["2drumVolBox"].pack_start( self.GUI["2drumMuteButton"], False, False, 5 ) + #self.GUI["2drumVolBox"].pack_start( self.GUI["2drumvolumeSlider"], True, True, 0 ) + #self.GUI["2drumVolBox"].pack_start( self.GUI["2drumMuteButton"], False, False, 5 ) self.GUI["2drumBox"].pack_start( self.GUI["2drumVolBox"], False, False, 0 ) self.GUI["2drumButton"] = ImageToggleButton(Config.IMAGE_ROOT + self.trackInstrument[4].name + '.png', Config.IMAGE_ROOT + self.trackInstrument[4].name + '.png') + self.GUI["2drumPalette"] = instrumentPalette(_('Track 5 Volume'), 4, self) + self.GUI["2drumButton"].set_palette(self.GUI["2drumPalette"]) self.GUI["2drumButton"].connect("toggled", self.pickDrum) + self.GUI["2drumButton"].connect('enter-notify-event', self.blockFocus) + self.GUI["2drumButton"].connect('leave-notify-event', self.unblockFocus) self.GUI["2drumBox"].pack_start( self.GUI["2drumButton"] ) self.GUI["2instrumentPanel"].pack_start( self.GUI["2drumBox"] ) self.GUI["2page"].pack_start( self.GUI["2instrumentPanel"], False ) @@ -939,17 +952,29 @@ class MainWindow( SubActivity ): if self.trackActive.count(False) == Config.NUMBER_OF_TRACKS - 1: for i in range(Config.NUMBER_OF_TRACKS): if i == 4: - self.GUI["2drumMuteButton"].set_active(True) + #self.GUI["2drumMuteButton"].set_active(True) + self.GUI["2drumPalette"].muteButton.set_active(True) else: - self.GUI["2instrument" + str(i+1) + "muteButton"].set_active(True) + #self.GUI["2instrument" + str(i+1) + "muteButton"].set_active(True) + self.GUI["2instrument" + str(i+1) + "Palette"].muteButton.set_active(True) else: for i in range(Config.NUMBER_OF_TRACKS): if i != track: if i == 4: - self.GUI["2drumMuteButton"].set_active(False) + #self.GUI["2drumMuteButton"].set_active(False) + self.GUI["2drumPalette"].muteButton.set_active(False) else: - self.GUI["2instrument" + str(i+1) + "muteButton"].set_active(False) + #self.GUI["2instrument" + str(i+1) + "muteButton"].set_active(False) + self.GUI["2instrument" + str(i+1) + "Palette"].muteButton.set_active(False) self.updatePagesPlaying() + + def blockFocus(self, widget = None, data = None): + self.activity.handler_block(self.activity.focusOutHandler) + self.activity.handler_block(self.activity.focusInHandler) + + def unblockFocus(self, widget = None, data = None): + self.activity.handler_unblock(self.activity.focusOutHandler) + self.activity.handler_unblock(self.activity.focusInHandler) #----------------------------------- # generation functions @@ -1865,11 +1890,13 @@ class InstrumentButton( gtk.DrawingArea ): | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.POINTER_MOTION_HINT_MASK - | gtk.gdk.LEAVE_NOTIFY_MASK ) + | gtk.gdk.LEAVE_NOTIFY_MASK + | gtk.gdk.ENTER_NOTIFY_MASK ) self.connect( "size-allocate", self.size_allocate ) self.connect( "button-press-event", self.button_press ) self.connect( "button-release-event", self.button_release ) self.connect( "motion-notify-event", self.motion_notify ) + self.connect( "enter-notify-event", self.enter_notify ) self.connect( "leave-notify-event", self.leave_notify ) self.connect( "expose-event", self.expose ) @@ -1958,6 +1985,14 @@ class InstrumentButton( gtk.DrawingArea ): self.hover = None if self.clicked == None: self.queue_draw() + + self.owner.activity.handler_unblock(self.owner.activity.focusOutHandler) + self.owner.activity.handler_unblock(self.owner.activity.focusInHandler) + + def enter_notify(self, widget, event): + # Block the Focus Out event so that the sound does'nt stop when a Palette is invoked. + self.owner.activity.handler_block(self.owner.activity.focusOutHandler) + self.owner.activity.handler_block(self.owner.activity.focusInHandler) def setPrimary( self, img ): self.primary = img @@ -2014,3 +2049,43 @@ class InstrumentButton( gtk.DrawingArea ): self.gc.foreground = self.color["+/-"] self.window.draw_line( self.gc, self.hotspots[0][0], self.hotspots[0][5], self.hotspots[0][2], self.hotspots[0][5] ) self.window.draw_line( self.gc, self.hotspots[0][4], self.hotspots[0][1], self.hotspots[0][4], self.hotspots[0][3] ) + + def set_palette(self, palette): + self._palette = palette + self._palette.props.invoker = WidgetInvoker(self) + +class instrumentPalette(Palette): + def __init__(self, label, trackID, edit): + Palette.__init__(self, label) + + self.set_property("position", Palette.AT_CURSOR) + + self.trackID = trackID + self.edit = edit + + self.tooltips = gtk.Tooltips() + + self.volumeBox = gtk.HBox() + + self.muteButton = gtk.CheckButton() + self.muteButton.connect("toggled",self.edit.handlemuteButton, self.trackID) + self.muteButton.connect("button-press-event",self.edit.handlemuteButtonRightClick, self.trackID) + self.muteButton.set_active(True) + self.tooltips.set_tip(self.muteButton, _('Left click to mute, right click to solo')) + + if self.trackID < 4: + exec "self.volumeSliderAdj = self.edit.GUI['2instrument%svolumeAdjustment']" % str(self.trackID+1) + else: + self.volumeSliderAdj = self.edit.GUI["2drumvolumeAdjustment"] + self.volumeSliderAdj.connect( "value-changed", self.edit.handleTrackVolume, self.trackID) + self.volumeSlider = gtk.HScale(adjustment = self.volumeSliderAdj) + self.volumeSlider.set_size_request(250, -1) + self.volumeSlider.set_inverted(False) + self.volumeSlider.set_draw_value(False) + + self.volumeBox.pack_start(self.muteButton, padding = 5) + self.volumeBox.pack_start(self.volumeSlider, padding = 5) + self.volumeBox.show_all() + + self.set_content(self.volumeBox) + -- cgit v0.9.1