[jokosher-devel] Workspace reworking [PATCH]



I've recently been doing some re-engineering of the workspace code.
This is quite a big update so I've posted a patch here first so you
folks can check it out.

What it does:

* The duplicate RecordingView is now removed. CompactMixView and
RecordingView are completely separate and there is only one instance
of each. The duplicate made debugging very confusing not to mention
all the extra signal processing going on.
* A new class Workspace which is just a gtk.VPaned containing
RecordingView and CompactMixView in separate panes.
* The workspace switch buttons now behave as toggle buttons and each
view can be toggled on/off. When the CompactMixView is showing then
the RecordingView switches to the small waveform mode.

I think these changes make the workspace code simpler and more
flexible and complement Laszlo's new gobject signal stuff. Some things
like toggling the solo/mute buttons in mixview don't work but then
they don't at the minute in SVN version.

Anyway try it out.

John
Index: InstrumentViewer.py
===================================================================
--- InstrumentViewer.py	(revision 1425)
+++ InstrumentViewer.py	(working copy)
@@ -140,46 +140,44 @@
 		self.muteImgDisabled = Utils.GetIconThatMayBeMissing("stock_volume", gtk.ICON_SIZE_BUTTON, False)
 		self.muteImgEnabled = Utils.GetIconThatMayBeMissing("stock_volume-mute", gtk.ICON_SIZE_BUTTON, False)
 		
-		if not (self.small):
-			self.recTip = gtk.Tooltips()
-			self.recButton = gtk.ToggleButton("")
-			self.recTip.set_tip(self.recButton, self.recTipEnabled, None)
-			self.recButton.connect("toggled", self.OnArm)
-			
-			self.muteButton = gtk.ToggleButton("")
-			self.muteButton.connect("toggled", self.OnMute)
-			self.muteTip = gtk.Tooltips()
-			self.muteTip.set_tip(self.muteButton, self.muteTipDisabled, None)
-			
-			self.soloButton = gtk.ToggleButton("")
-			self.soloTip = gtk.Tooltips()
-			self.soloTip.set_tip(self.soloButton, self.soloTipDisabled, None)
-			self.soloButton.connect("toggled", self.OnSolo)
-			
-			self.propsButton = gtk.Button()
-			procimg = gtk.Image()
-			procimg.set_from_file(os.path.join(Globals.IMAGE_PATH, "icon_effectsapply.png"))
-			self.propsButton.set_image(procimg)
+		self.recTip = gtk.Tooltips()
+		self.recButton = gtk.ToggleButton("")
+		self.recTip.set_tip(self.recButton, self.recTipEnabled, None)
+		self.recButton.connect("toggled", self.OnArm)
+		
+		self.muteButton = gtk.ToggleButton("")
+		self.muteButton.connect("toggled", self.OnMute)
+		self.muteTip = gtk.Tooltips()
+		self.muteTip.set_tip(self.muteButton, self.muteTipDisabled, None)
+		
+		self.soloButton = gtk.ToggleButton("")
+		self.soloTip = gtk.Tooltips()
+		self.soloTip.set_tip(self.soloButton, self.soloTipDisabled, None)
+		self.soloButton.connect("toggled", self.OnSolo)
+		
+		self.propsButton = gtk.Button()
+		procimg = gtk.Image()
+		procimg.set_from_file(os.path.join(Globals.IMAGE_PATH, "icon_effectsapply.png"))
+		self.propsButton.set_image(procimg)
 
-			self.propsButton.connect("clicked", self.OnInstrumentEffects)
-			self.propsTip = gtk.Tooltips()
-			self.propsTip.set_tip(self.propsButton, _("Instrument Effects"), None)
-			
-			self.controlsBox.add(self.recButton)
-			self.controlsBox.add(self.muteButton)
-			self.controlsBox.add(self.soloButton)
-			self.controlsBox.add(self.propsButton)
-			
-			self.instrument.connect("solo", self.OnInstrumentSolo)
-			self.instrument.connect("arm", self.OnInstrumentArm)
-			self.instrument.connect("mute", self.OnInstrumentMute)
-			
-			#initialize the images on the buttons
-			for i in (self.OnInstrumentArm, self.OnInstrumentMute, self.OnInstrumentSolo):
-				i(self.instrument)
-		else:
-			self.separator = gtk.HSeparator()
-			self.headerBox.pack_end(self.separator, False, True)
+		self.propsButton.connect("clicked", self.OnInstrumentEffects)
+		self.propsTip = gtk.Tooltips()
+		self.propsTip.set_tip(self.propsButton, _("Instrument Effects"), None)
+		
+		self.controlsBox.add(self.recButton)
+		self.controlsBox.add(self.muteButton)
+		self.controlsBox.add(self.soloButton)
+		self.controlsBox.add(self.propsButton)
+		
+		self.instrument.connect("solo", self.OnInstrumentSolo)
+		self.instrument.connect("arm", self.OnInstrumentArm)
+		self.instrument.connect("mute", self.OnInstrumentMute)
+		
+		#initialize the images on the buttons
+		for i in (self.OnInstrumentArm, self.OnInstrumentMute, self.OnInstrumentSolo):
+			i(self.instrument)
+		self.separator = gtk.HSeparator()
+		self.headerBox.pack_end(self.separator, False, True)
 		self.instrument.isSelected = False
 		
 		# Begin Drag and Drop code
@@ -201,6 +199,10 @@
 		
 		#set the appropriate colour if the instrument it already selected.
 		self.OnInstrumentSelected()
+		self.show_all()
+		self.labelbox.show()
+		if self.small:
+			self.controlsBox.hide()
 
 	#_____________________________________________________________________
 
@@ -483,7 +485,7 @@
 
 	#______________________________________________________________________
 
-	def OnInstrumentEffects(self, widget, mouse=None):
+	def OnInstrumentEffects(self, widget, mouse):
 		"""
 		Creates and shows the instrument effects dialog
 		
@@ -491,6 +493,7 @@
 			widget -- reserved for GTK callbacks, don't use it explicitly.
 			mouse -- reserved for GTK callbacks, don't use it explicitly.
 		"""
+		Globals.debug("props button pressed")
 		if not self.effectsDialog:
 			self.effectsDialog = InstrumentEffectsDialog.InstrumentEffectsDialog(
 					self.instrument,
@@ -667,5 +670,26 @@
 		    
 	#______________________________________________________________________
 
+	def ChangeSize(self, small):
+		"""
+		Changes the size of the instrument viewer
+		
+		Parameters:
+			small -- True if the instrument viewer is to be small.
+		"""
+		self.small = small
+		self.eventLane.ChangeSize(small)
+		if self.small:
+			pb = self.instrument.pixbuf.scale_simple(20, 20, gtk.gdk.INTERP_BILINEAR)
+			self.image.set_from_pixbuf(pb)
+			self.controlsBox.hide()
+			self.separator.show()
+		else:
+			self.image.set_from_pixbuf(self.instrument.pixbuf)
+			self.controlsBox.show()
+			self.separator.hide()
 
+	#____________________________________________________________________	
+
+
 	#=========================================================================	
Index: Workspace.py
===================================================================
--- Workspace.py	(revision 0)
+++ Workspace.py	(revision 0)
@@ -0,0 +1,81 @@
+#
+#	THIS FILE IS PART OF THE JOKOSHER PROJECT AND LICENSED UNDER THE GPL. SEE
+#	THE 'COPYING' FILE FOR DETAILS
+#
+#	Workspace.py
+#	
+#	A sub-class of gtk.VPaned containing the the varous views of the project
+#
+#-------------------------------------------------------------------------------
+
+import gtk
+import gobject
+import RecordingView
+import CompactMixView
+
+#=========================================================================
+
+class Workspace(gtk.VPaned):
+	"""
+	This class implements the workspace view.
+	"""
+	
+	#_____________________________________________________________________
+	
+	def __init__(self, project, mainview):
+		"""
+		Creates a new instance of Workspace.
+		
+		Parameters:
+			project -- the active Project.
+			mainview -- reference to the MainApp Jokosher window.
+		"""
+		gtk.VPaned.__init__(self)
+		self.project = project
+		self.mainview = mainview
+		self.small = False
+		self.recordingView = RecordingView.RecordingView(project, mainview, self.small)
+		self.mixView = CompactMixView.CompactMixView(project, mainview)
+		self.add(self.recordingView)
+		self.add(self.mixView)
+		self.mixView.hide()
+		self.show()
+	#_____________________________________________________________________
+
+	def ToggleRecording(self):
+		"""
+		Toggles the recording view on/off.
+		"""
+		if self.mainview.recordingButton.get_active():
+			self.recordingView.show()
+			self.mainview.contextTooltips.set_tip(
+						self.mainview.recordingButton,
+						self.mainview.recordingViewEnabledTip)
+		else:
+			self.recordingView.hide()
+			self.mainview.contextTooltips.set_tip(
+						self.mainview.recordingButton,
+						self.mainview.recordingViewDisabledTip)
+#____________________________________________________________________	
+
+	
+	def ToggleCompactMix(self):
+		"""
+		Toggles compact mix view on/off.
+		"""
+		if self.mainview.compactMixButton.get_active():
+			self.recordingView.ChangeSize(True)
+			self.mixView.show()
+			self.mainview.contextTooltips.set_tip(
+						self.mainview.compactMixButton,
+						self.mainview.mixingViewEnabledTip)
+		else:
+			self.recordingView.ChangeSize(False)
+			self.mixView.hide()
+			self.mainview.contextTooltips.set_tip(
+						self.mainview.compactMixButton,
+						self.mainview.mixingViewDisabledTip)
+	#____________________________________________________________________	
+
+#=========================================================================
+		
Index: CompactMixView.py
===================================================================
--- CompactMixView.py	(revision 1425)
+++ CompactMixView.py	(working copy)
@@ -39,6 +39,8 @@
 		gtk.Frame.__init__(self)
 		self.project = project
 		self.mainview = mainview
+		self.small = True
+		self.mix = False
 		self.mixerStripList = []
 		self.minimisedButtonList = []
 		self.lanes = []
@@ -47,19 +49,12 @@
 		
 		self.vbox = gtk.VBox()
 		self.add(self.vbox)
-		self.vpaned = gtk.VPaned()
-		self.vbox.pack_start(self.vpaned, True, True)
-		self.projectview = RecordingView.RecordingView(project, mainview, self, True)
-		self.vpaned.add(self.projectview)
 		self.hbox = gtk.HBox()
-		self.vpaned.add(self.hbox)
+		self.vbox.pack_start(self.hbox, True, True)
 		
 		self.mastermixer = MasterMixerStrip(self.project, self, self.mainview)
 		self.hbox.pack_end(self.mastermixer, False, False)
-		
-		self.show_all()
-		self.UpdateTimeout = False
-		
+
 		self.project.connect("instrument::added", self.OnInstrumentAdded)
 		self.project.connect("instrument::reordered", self.OnInstrumentReordered)
 		self.project.connect("instrument::removed", self.OnInstrumentRemoved)
@@ -67,6 +62,8 @@
 		#initialize the instrument widgets
 		for instr in self.project.instruments:
 			self.OnInstrumentAdded(self.project, instr)
+		self.show_all()
+		self.UpdateTimeout = False
 		
 	#_____________________________________________________________________
 
@@ -251,7 +248,7 @@
 			return False
 	
 	#_____________________________________________________________________
-		
+	
 	def StartUpdateTimeout(self):
 		""" 
 		Initiates the OnUpdateTimeout - called from MainApp.play()
Index: EventLaneViewer.py
===================================================================
--- EventLaneViewer.py	(revision 1425)
+++ EventLaneViewer.py	(working copy)
@@ -477,5 +477,20 @@
 		"""
 		self.highlightCursor = None
 		self.queue_draw()
+		
+	#_____________________________________________________________________
 	
+	def ChangeSize(self, small):
+		"""
+		Changes the size of the event lane.
+		
+		Parameters:
+			small - True if the event lane is to be small.
+		"""
+		self.small = small
+		for eventViewer in self.fixed.get_children():
+			eventViewer.ChangeSize(small)
+			
+	#____________________________________________________________________	
+
 #=========================================================================
Index: EventViewer.py
===================================================================
--- EventViewer.py	(revision 1425)
+++ EventViewer.py	(working copy)
@@ -116,11 +116,13 @@
 		self.SetAccessibleName()
 		self.set_property("can-focus", True)
 		
-		# source is an offscreen canvas to hold our waveform image
-		self.source = cairo.ImageSurface(cairo.FORMAT_ARGB32, 0, 0)
+		# sourceSmall/Large are offscreen canvases to hold our waveform images
+		self.sourceSmall = cairo.ImageSurface(cairo.FORMAT_ARGB32, 0, 0)
+		self.sourceLarge = cairo.ImageSurface(cairo.FORMAT_ARGB32, 0, 0)
 		
-		# rectangle of cached draw area
-		self.cachedDrawArea = gtk.gdk.Rectangle(0, 0, 0, 0)
+		# rectangle of cached draw areas
+		self.cachedDrawAreaSmall = gtk.gdk.Rectangle(0, 0, 0, 0)
+		self.cachedDrawAreaLarge = gtk.gdk.Rectangle(0, 0, 0, 0)
 
 		# Monitor the things this object cares about
 		self.project.connect("zoom", self.OnProjectZoom)
@@ -187,18 +189,29 @@
 		Returns:
 			False -- stop propagating the GTK signal. *CHECK*
 		"""
-		cache = self.cachedDrawArea
+		if self.small:
+			cache = self.cachedDrawAreaSmall
+			source = self.sourceSmall
+		else:
+			cache = self.cachedDrawAreaLarge
+			source = self.sourceLarge
 		area = event.area
 		
 		#check if the expose area is within the already cached rectangle
 		if area.x < cache.x or (area.x + area.width > cache.x + cache.width) or self.redrawWaveform:
 			self.DrawWaveform(event.area)
+			if self.small:
+				cache = self.cachedDrawAreaSmall
+				source = self.sourceSmall
+			else:
+				cache = self.cachedDrawAreaLarge
+				source = self.sourceLarge
 		
 		# Get a cairo surface for this drawing op
 		context = widget.window.cairo_create()
 
 		# Give it our waveform image as a source
-		context.set_source_surface(self.source, self.cachedDrawArea.x, self.cachedDrawArea.y)	
+		context.set_source_surface(source, cache.x, cache.y)	
 
 		# Blit our waveform across
 		context.paint()
@@ -318,9 +331,18 @@
 		if rect.x + rect.width > allocArea.width:
 			rect.width = allocArea.width - rect.x
 			
-		self.source = cairo.ImageSurface(cairo.FORMAT_ARGB32, rect.width, rect.height)
+		#set area to record where the cached surface goes
+		if self.small:
+			self.cachedDrawAreaSmall = rect
+			self.sourceSmall = cairo.ImageSurface(cairo.FORMAT_ARGB32, 
+												rect.width, rect.height)
+			context = cairo.Context(self.sourceSmall)
+		else:
+			self.cachedDrawAreaLarge = rect
+			self.sourceLarge = cairo.ImageSurface(cairo.FORMAT_ARGB32, 
+												rect.width, rect.height)
+			context = cairo.Context(self.sourceLarge)
 		
-		context = cairo.Context(self.source)
 		context.set_line_width(2)
 		context.set_antialias(cairo.ANTIALIAS_SUBPIXEL)
 
@@ -428,8 +450,6 @@
 				#Draw event name
 				context.show_text(self.event.name)
 		
-		#set area to record where the cached surface goes
-		self.cachedDrawArea = rect
 		self.redrawWaveform = False
 
 	#_____________________________________________________________________
@@ -449,7 +469,8 @@
 		self.event.disconnect_by_func(self.OnEventWaveform)
 		
 		#delete the cached images
-		del self.source
+		del self.sourceSmall
+		del self.sourceLarge
 		del self.cancelImg
 		self.destroy()
 	
@@ -1079,12 +1100,13 @@
 		if not (self.small):
 			requisition.height = 77
 		else:
-			rect = self.get_allocation()
-			
-			if rect.height < 30:
-				requisition.height = 30
-			else:
-				requisition.height = rect.height
+			requisition.height = 30
+#			rect = self.get_allocation()
+#			
+#			if rect.height < 30:
+#				requisition.height = 30
+#			else:
+#				requisition.height = rect.height
 
 	#_____________________________________________________________________
 	
@@ -1120,6 +1142,7 @@
 		"""
 		Callback function for when the length of the event changes.
 		"""
+		print "eventlength"
 		self.redrawWaveform = True
 		self.SetAccessibleName()
 		self.queue_resize()
@@ -1367,4 +1390,18 @@
 		
 	#_____________________________________________________________________
 
+	def ChangeSize(self, small):
+		"""
+		Changes size of event viewer.
+		
+		Parameters:
+			small -- True if the event viewer is to change to small
+		"""
+		self.small = small
+		self.queue_resize()
+		self.queue_draw()
+			
+	#____________________________________________________________________	
+
+
 #=========================================================================
Index: TimeLineBar.py
===================================================================
--- TimeLineBar.py	(revision 1425)
+++ TimeLineBar.py	(working copy)
@@ -145,10 +145,8 @@
 		"""
 		if not self.Updating:
 			instrumentviews=[]
-			if self.mainview.recording:
-				instrumentviews+=self.mainview.recording.views
-			if self.mainview.compactmix:
-				instrumentviews+=self.mainview.compactmix.projectview.views
+			if self.mainview.workspace:
+				instrumentviews+=self.mainview.workspace.recordingView.views
 
 			self.Updating = True
 			maxwidth=self.headerhbox.size_request()[0]
Index: RecordingView.py
===================================================================
--- RecordingView.py	(revision 1425)
+++ RecordingView.py	(working copy)
@@ -22,9 +22,6 @@
 	"""
 	This class encapsulates a visual layout of a project comprising
 	instrument tracks, timeline, and horizontal scrollbars.
-	Despite its name, it also appears under the mixing view contained
-	in a CompactMixView object, where it represents the same
-	information with shorter instrument tracks.
 	"""
 	
 	""" GTK widget name """
@@ -51,25 +48,19 @@
 
 	#_____________________________________________________________________
 
-	def __init__(self, project, mainview, mixView=None, small=False):
+	def __init__(self, project, mainview, small=False):
 		"""
 		Creates a new instance of RecordingView.
 		
 		Parameters:
 			project -- the currently active Project.
 			mainview -- the main Jokosher window (MainApp).
-			mixView -- the CompactMixView object that holds this instance of
-						RecordingView, if the mixing view is the currently 
-						active one.
-						If the recording view is the active one, then this
-						should be set to None.
 			small -- set to True if we want small edit views (i.e. for the mixing view).
 		"""
 		gtk.Frame.__init__(self)
 
 		self.project = project
 		self.mainview = mainview
-		self.mixView = mixView
 		self.small = small
 		self.timelinebar = TimeLineBar.TimeLineBar(self.project, self, mainview)
 		
@@ -103,38 +94,36 @@
 		
 		self.lastzoom = 0
 		
-		#recording view contains zoom buttons
-		if not self.mixView:
-			self.zoomSlider = gtk.HScale()
-			self.zoomSlider.set_size_request(70, -1)
-			
-			self.zoomSlider.set_range(self.ZOOM_MIN_SCALE, self.ZOOM_MAX_SCALE)
-			self.zoomSlider.set_increments(0.2, 0.2)
-			self.zoomSlider.set_draw_value(False)
-			self.zoomSlider.set_value(self.project.viewScale)
-			self.zoomtip = gtk.Tooltips()
-			self.zoomtip.set_tip(self.zoomSlider, _("Zoom the timeline - Right-Click to reset to the default level"), None)
-			
-			self.zoomSlider.connect("value-changed", self.OnZoom)
-			self.zoomSlider.connect("button-press-event", self.OnZoomReset)
-			
-			inbutton = gtk.Button()
-			inimg = gtk.image_new_from_stock(gtk.STOCK_ZOOM_IN, gtk.ICON_SIZE_BUTTON)
-			inbutton.set_image(inimg)
-			inbutton.set_relief(gtk.RELIEF_NONE)
-			self.zoomtip.set_tip(inbutton, _("Zoom in timeline"), None)
-			inbutton.connect("clicked", self.OnZoomIn)
-			
-			outbutton = gtk.Button()
-			outimg = gtk.image_new_from_stock(gtk.STOCK_ZOOM_OUT, gtk.ICON_SIZE_BUTTON)
-			outbutton.set_image(outimg)
-			outbutton.set_relief(gtk.RELIEF_NONE)
-			self.zoomtip.set_tip(outbutton, _("Zoom out timeline"), None)
-			outbutton.connect("clicked", self.OnZoomOut)
+		self.zoomSlider = gtk.HScale()
+		self.zoomSlider.set_size_request(70, -1)
+		
+		self.zoomSlider.set_range(self.ZOOM_MIN_SCALE, self.ZOOM_MAX_SCALE)
+		self.zoomSlider.set_increments(0.2, 0.2)
+		self.zoomSlider.set_draw_value(False)
+		self.zoomSlider.set_value(self.project.viewScale)
+		self.zoomtip = gtk.Tooltips()
+		self.zoomtip.set_tip(self.zoomSlider, _("Zoom the timeline - Right-Click to reset to the default level"), None)
+		
+		self.zoomSlider.connect("value-changed", self.OnZoom)
+		self.zoomSlider.connect("button-press-event", self.OnZoomReset)
+		
+		self.inbutton = gtk.Button()
+		inimg = gtk.image_new_from_stock(gtk.STOCK_ZOOM_IN, gtk.ICON_SIZE_BUTTON)
+		self.inbutton.set_image(inimg)
+		self.inbutton.set_relief(gtk.RELIEF_NONE)
+		self.zoomtip.set_tip(self.inbutton, _("Zoom in timeline"), None)
+		self.inbutton.connect("clicked", self.OnZoomIn)
+		
+		self.outbutton = gtk.Button()
+		outimg = gtk.image_new_from_stock(gtk.STOCK_ZOOM_OUT, gtk.ICON_SIZE_BUTTON)
+		self.outbutton.set_image(outimg)
+		self.outbutton.set_relief(gtk.RELIEF_NONE)
+		self.zoomtip.set_tip(self.outbutton, _("Zoom out timeline"), None)
+		self.outbutton.connect("clicked", self.OnZoomOut)
 
-			self.hb.pack_start( outbutton, False, False)
-			self.hb.pack_start( self.zoomSlider, False, False)
-			self.hb.pack_start( inbutton, False, False)
+		self.hb.pack_start( self.outbutton, False, False)
+		self.hb.pack_start( self.zoomSlider, False, False)
+		self.hb.pack_start( self.inbutton, False, False)
 		
 		self.extraScrollTime = 25
 		self.centreViewOnPosition = False
@@ -165,6 +154,12 @@
 			self.OnInstrumentAdded(project, instr)
 			
 		self.show_all()
+		self.show_all()
+		if self.small:
+			self.inbutton.hide()
+			self.outbutton.hide()
+			self.zoomSlider.hide()
+		
 	#_____________________________________________________________________
 
 	def OnExpose(self, widget, event):
@@ -212,13 +207,12 @@
 		elif self.project.viewStart + self.scrollRange.page_size > length:
 			self.SetViewPosition(length - self.scrollRange.page_size)
 		
-		if not self.mixView:
-			#check the min zoom value (based on project length)
-			pixelSize = self.allocation.width - Globals.INSTRUMENT_HEADER_WIDTH - 4	# four pixels to account for borders
-			minScale = pixelSize / length
-			self.zoomSlider.set_range(minScale, self.ZOOM_MAX_SCALE)
-			if self.zoomSlider.get_value() < minScale:
-				self.zoomSlider.set_value(minScale)
+		#check the min zoom value (based on project length)
+		pixelSize = self.allocation.width - Globals.INSTRUMENT_HEADER_WIDTH - 4	# four pixels to account for borders
+		minScale = pixelSize / length
+		self.zoomSlider.set_range(minScale, self.ZOOM_MAX_SCALE)
+		if self.zoomSlider.get_value() < minScale:
+			self.zoomSlider.set_value(minScale)
 		
 	#_____________________________________________________________________
 
@@ -511,4 +505,30 @@
 		return True
 	
 	#_____________________________________________________________________
+	
+	def ChangeSize(self, small):
+		"""
+		Alters the size of the instrument lanes and removes the zoom buttons.
+		
+		Parameters:
+			small -- True if changing to small. Otherwise False.
+		"""
+		#if the requested size has not changed then quit
+		if small == self.small:
+			return
+		self.small = small
+		children = self.instrumentBox.get_children()
+		for instrView in children:
+			instrView.ChangeSize(small)
+		if self.small:
+			self.inbutton.hide()
+			self.outbutton.hide()
+			self.zoomSlider.hide()
+		else:
+			self.inbutton.show()
+			self.outbutton.show()
+			self.zoomSlider.show()
+			
+	#____________________________________________________________________	
+
 #=========================================================================
Index: JokosherApp.py
===================================================================
--- JokosherApp.py	(revision 1425)
+++ JokosherApp.py	(working copy)
@@ -21,7 +21,7 @@
 import gettext
 _ = gettext.gettext
 
-import AddInstrumentDialog, TimeView, CompactMixView
+import AddInstrumentDialog, TimeView, Workspace
 import PreferencesDialog, ExtensionManagerDialog, RecordingView, NewProjectDialog
 import ProjectManager, Globals, WelcomeDialog, AlsaDevices
 import InstrumentConnectionsDialog, StatusBar
@@ -62,10 +62,10 @@
 		self.recTipDisabled = _("Arm an instrument, then click here to begin recording")
 		self.recStopTipEnabled = _("Stop recording")
 		self.recStopTipDisabled = _("Stop playback")
-		self.recordingViewEnabledTip = _("Currently working in the Recording workspace")
-		self.recordingViewDisabledTip = _("Switch to the Recording workspace")
-		self.mixingViewEnabledTip = _("Currently working in the Mixing workspace")
-		self.mixingViewDisabledTip = _("Switch to the Mixing workspace")
+		self.recordingViewEnabledTip = _("Hide Recording workspace")
+		self.recordingViewDisabledTip = _("Show Recording workspace")
+		self.mixingViewEnabledTip = _("Hide Mixing workspace")
+		self.mixingViewDisabledTip = _("Show Mixing workspace")
 		
 		gtk.glade.bindtextdomain(Globals.LOCALE_APP, Globals.LOCALE_PATH)
 		gtk.glade.textdomain(Globals.LOCALE_APP)
@@ -156,11 +156,10 @@
 		self.lastopenedproject = None
 		
 		self.project = None
-		self.recording = None
 		self.headerhbox = None
 		self.timeview = None
 		self.tvtoolitem = None #wrapper for putting timeview in toolbar
-		self.compactmix = None
+		self.workspace = None
 		self.instrNameEntry = None #the gtk.Entry when editing an instrument name
 		self.main_vbox = self.wTree.get_widget("main_vbox")
 		
@@ -170,7 +169,10 @@
 		# Initialise some useful vars
 		self.mode = None
 		self.settingButtons = True
-		self.recordingButton.set_active(True)
+		if not self.recordingButton.get_active():
+			self.recordingButton.set_active(True)
+		if self.compactMixButton.get_active():
+			self.compactMixButton.set_active(False)
 		self.settingButtons = False
 		self.isRecording = False
 		self.isPlaying = False
@@ -280,47 +282,6 @@
 		if self.project == None:
 			WelcomeDialog.WelcomeDialog(self)
 
-	#_____________________________________________________________________	
-
-	def OnChangeView(self, view, mode):
-		"""
-		Updates the state of the recording and the compact mix buttons. It also might 
-		need to force a redraw of the timeline when changing views as it may have been
-		zoomed or scrolled while hidden.
-		
-		Parameters:
-			view -- reference to the view the main window has changed to.
-			mode -- mode corresponding to the view the main window has changed to:
-					MainApp.MODE_RECORDING = recording view
-					MainApp.MODE_COMPACT_MIX = mixing view
-		"""
-		if not self.settingButtons:
-			self.settingButtons = True
-			self.recordingButton.set_active(mode == self.MODE_RECORDING)
-			self.compactMixButton.set_active(mode == self.MODE_COMPACT_MIX)
-			self.settingButtons = False
-			
-			if view:
-				children = self.main_vbox.get_children()
-				if self.recording in children:
-					self.main_vbox.remove(self.recording)
-					# synchronise scrollbars
-					self.compactmix.projectview.scrollRange.value = self.recording.scrollRange.value
-				elif self.compactmix in children:
-					self.main_vbox.remove(self.compactmix)
-					# synchronise scrollbars
-					self.recording.scrollRange.value = self.compactmix.projectview.scrollRange.value
-				
-				self.main_vbox.pack_end(view, True, True)
-				self.mode = mode
-				# need to force a redraw of timeline when changing
-				# views (may have been zoom or scroll while hidden)
-				if mode == self.MODE_COMPACT_MIX:
-					view.projectview.timelinebar.timeline.DrawLine()
-				else:
-					view.timelinebar.timeline.DrawLine()
-				self.window.show_all()
-
 	#_____________________________________________________________________
 	
 	def OnRecordingView(self, window=None):
@@ -330,10 +291,8 @@
 		Parameters:
 			window -- Window object calling this method.
 		"""
-		if hasattr(self, "recording"):
-			self.OnChangeView(self.recording, self.MODE_RECORDING)
-			self.contextTooltips.set_tip(self.recordingButton, self.recordingViewEnabledTip, None)
-			self.contextTooltips.set_tip(self.compactMixButton, self.mixingViewDisabledTip, None)
+		if self.workspace:
+			self.workspace.ToggleRecording()
 
 	#_____________________________________________________________________
 	
@@ -344,10 +303,8 @@
 		Parameters:
 			window -- Window object calling this method.
 		"""
-		if hasattr(self, "compactmix"):
-			self.OnChangeView(self.compactmix, self.MODE_COMPACT_MIX)
-			self.contextTooltips.set_tip(self.recordingButton, self.recordingViewDisabledTip, None)
-			self.contextTooltips.set_tip(self.compactMixButton, self.mixingViewEnabledTip, None)		
+		if self.workspace:
+			self.workspace.ToggleCompactMix()
 				
 	#_____________________________________________________________________
 	
@@ -967,7 +924,7 @@
 		self.record.set_sensitive(not self.isPlaying)
 		
 		controls = (self.play, self.reverse, self.forward, self.editmenu, self.projectMenu, self.instrumentMenu, 
-				self.recording.timelinebar.headerhbox, self.compactmix.projectview.timelinebar.headerhbox, 
+				self.workspace.recordingView.timelinebar.headerhbox, 
 				self.addInstrumentButton, self.addAudioFileButton)
 		for widget in controls:
 			widget.set_sensitive(not self.isRecording)
@@ -985,7 +942,7 @@
 			self.record.set_tooltip(self.contextTooltips, self.recTipDisabled, None)
 			self.stop.set_tooltip(self.contextTooltips, self.recStopTipDisabled, None)
 		
-		self.compactmix.StartUpdateTimeout()
+		self.workspace.mixView.StartUpdateTimeout()
 	
 	#_____________________________________________________________________
 	
@@ -1327,10 +1284,8 @@
 		For example, buttons are enabled/disabled whether there's a project currently open or not. 
 		"""
 		children = self.main_vbox.get_children()
-		if self.recording in children:
-			self.main_vbox.remove(self.recording)
-		elif self.compactmix in children:
-			self.main_vbox.remove(self.compactmix)
+		if self.workspace in children:
+			self.main_vbox.remove(self.workspace)
 		
 		if self.headerhbox in children:
 			self.main_vbox.remove(self.headerhbox)
@@ -1349,43 +1304,47 @@
 			for c in ctrls:
 				c.set_sensitive(True)
 			
+			
 			#set undo/redo if there is saved undo history
 			self.OnProjectUndo()
 				
 			# Create our custom widgets
 			self.timeview = TimeView.TimeView(self.project)
-			self.compactmix = CompactMixView.CompactMixView(self.project, self)
-			self.recording = RecordingView.RecordingView(self.project, self)
+			self.workspace = Workspace.Workspace(self.project, self)
 			
 			# Add them to the main window
-			self.main_vbox.pack_start(self.recording, True, True)
+			self.main_vbox.pack_start(self.workspace, True, True)
 			
 			self.tvtoolitem = gtk.ToolItem()
 			self.tvtoolitem.add(self.timeview)
 			self.wTree.get_widget("MainToolbar").insert(self.tvtoolitem, -1)
 			
-			self.OnRecordingView()
+			#reset toggle buttons
+			self.settingButtons = True
+			self.recordingButton.set_active(True)
+			self.compactMixButton.set_active(False)
+			self.settingButtons = False
 			
 		else:
+			#reset toggle buttons when the project is unloaded
+			self.settingButtons = True
+			if not self.recordingButton.get_active():
+				self.recordingButton.set_active(True)
+			if self.compactMixButton.get_active():
+				self.compactMixButton.set_active(False)
+			self.settingButtons = False
+
 			for c in ctrls:
 				c.set_sensitive(False)
 			
-			#untoggle all toggle buttons when the project is unloaded
-			self.settingButtons = True
-			for t in (self.recordingButton, self.compactMixButton):
-				t.set_active(False)
-			self.settingButtons = False
-				
+			
 			# Set window title with no project name
 			self.window.set_title(_('Jokosher'))
 			
 			# Destroy our custom widgets
-			if self.recording:
-				self.recording.destroy()
-				self.recording = None
-			if self.compactmix:
-				self.compactmix.destroy()
-				self.compactmix = None
+			if self.workspace:
+				self.workspace.destroy()
+				self.workspace = None
 			if self.tvtoolitem:
 				self.tvtoolitem.destroy()
 				self.tvtoolitem = None
@@ -1803,7 +1762,7 @@
 				break
 		
 		if instrID != None:
-			for id, instrViewer in self.recording.views:
+			for id, instrViewer in self.workspace.recordingView.views:
 				if instrID == id:
 					instrViewer.eventLane.CreateEventFromFile()
 		


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]