The active plot is now more visible.
This commit is contained in:
parent
f826931105
commit
e08cc8b816
|
@ -67,7 +67,21 @@ class ViewFrame (gtk.Frame):
|
||||||
self.view_frames = view_frames
|
self.view_frames = view_frames
|
||||||
self.empty_view = EmptyView()
|
self.empty_view = EmptyView()
|
||||||
self._button_event = None
|
self._button_event = None
|
||||||
|
|
||||||
|
## Set up a VBox with a label wrapped in an event box.
|
||||||
|
label = gtk.Label()
|
||||||
|
ebox = gtk.EventBox()
|
||||||
|
ebox.add(label)
|
||||||
|
vbox = gtk.VBox()
|
||||||
|
vbox.pack_start(ebox, expand=False)
|
||||||
|
vbox.pack_start(gtk.HSeparator(), expand=False)
|
||||||
|
|
||||||
|
## Keep the references for later use.
|
||||||
|
self._vbox = vbox
|
||||||
|
self._ebox = ebox
|
||||||
|
self._view_title = label
|
||||||
|
self.add(vbox)
|
||||||
|
|
||||||
view_frames.append(self)
|
view_frames.append(self)
|
||||||
if len(view_frames) == 1:
|
if len(view_frames) == 1:
|
||||||
self.focus()
|
self.focus()
|
||||||
|
@ -84,9 +98,10 @@ class ViewFrame (gtk.Frame):
|
||||||
# Set view
|
# Set view
|
||||||
self._view = self.empty_view
|
self._view = self.empty_view
|
||||||
self._view.connect("button-press-event", self.on_button_press_event)
|
self._view.connect("button-press-event", self.on_button_press_event)
|
||||||
self.add(self._view)
|
self._vbox.add(self._view)
|
||||||
|
self._view_title.set_text(self._view.title)
|
||||||
|
self.show_all()
|
||||||
self._view.show()
|
self._view.show()
|
||||||
self.show()
|
|
||||||
|
|
||||||
def focus(self):
|
def focus(self):
|
||||||
"""Gets focus and ensures that no other window is in focus."""
|
"""Gets focus and ensures that no other window is in focus."""
|
||||||
|
@ -98,6 +113,7 @@ class ViewFrame (gtk.Frame):
|
||||||
frame.unfocus()
|
frame.unfocus()
|
||||||
|
|
||||||
self.set_shadow_type(gtk.SHADOW_IN)
|
self.set_shadow_type(gtk.SHADOW_IN)
|
||||||
|
self._ebox.set_state(gtk.STATE_ACTIVE)
|
||||||
self.focused = True
|
self.focused = True
|
||||||
self.emit('focus-changed', self, True)
|
self.emit('focus-changed', self, True)
|
||||||
return self
|
return self
|
||||||
|
@ -108,6 +124,7 @@ class ViewFrame (gtk.Frame):
|
||||||
return
|
return
|
||||||
|
|
||||||
self.set_shadow_type(gtk.SHADOW_OUT)
|
self.set_shadow_type(gtk.SHADOW_OUT)
|
||||||
|
self._ebox.set_state(gtk.STATE_NORMAL)
|
||||||
self.focused = False
|
self.focused = False
|
||||||
self.emit('focus-changed', self, False)
|
self.emit('focus-changed', self, False)
|
||||||
|
|
||||||
|
@ -123,9 +140,8 @@ class ViewFrame (gtk.Frame):
|
||||||
return
|
return
|
||||||
|
|
||||||
# detach view from current parent
|
# detach view from current parent
|
||||||
view_parent = view.get_parent()
|
if view._view_frame:
|
||||||
if view_parent:
|
view._view_frame.set_view(None)
|
||||||
view_parent.set_view(None)
|
|
||||||
|
|
||||||
# switch which widget we are listening to
|
# switch which widget we are listening to
|
||||||
if self._button_event:
|
if self._button_event:
|
||||||
|
@ -135,11 +151,16 @@ class ViewFrame (gtk.Frame):
|
||||||
self.on_button_press_event)
|
self.on_button_press_event)
|
||||||
|
|
||||||
# remove old view, set new view
|
# remove old view, set new view
|
||||||
self._view.hide()
|
if self._view:
|
||||||
self.remove(self._view)
|
self._view.hide()
|
||||||
self.add(view)
|
self._vbox.remove(self._view)
|
||||||
|
self._view._view_frame = None
|
||||||
|
|
||||||
|
self._view_title.set_text(view.title)
|
||||||
|
self._vbox.add(view)
|
||||||
view.show()
|
view.show()
|
||||||
|
|
||||||
|
view._view_frame = self
|
||||||
self._view = view
|
self._view = view
|
||||||
|
|
||||||
def get_view(self):
|
def get_view(self):
|
||||||
|
@ -262,7 +283,7 @@ class View (gtk.Frame):
|
||||||
gtk.Frame.__init__(self)
|
gtk.Frame.__init__(self)
|
||||||
self.title = title
|
self.title = title
|
||||||
self.set_shadow_type(gtk.SHADOW_NONE)
|
self.set_shadow_type(gtk.SHADOW_NONE)
|
||||||
self.set_label(title)
|
self._view_frame = None
|
||||||
|
|
||||||
def get_toolbar(self):
|
def get_toolbar(self):
|
||||||
return None
|
return None
|
||||||
|
@ -294,11 +315,12 @@ class Plot (View):
|
||||||
self._toolbar = PlotToolbar(self)
|
self._toolbar = PlotToolbar(self)
|
||||||
self.canvas.add_events(gtk.gdk.ENTER_NOTIFY_MASK)
|
self.canvas.add_events(gtk.gdk.ENTER_NOTIFY_MASK)
|
||||||
self.current_dim = None
|
self.current_dim = None
|
||||||
|
self._current_selection = None
|
||||||
|
|
||||||
def set_frozen(self, frozen):
|
def set_frozen(self, frozen):
|
||||||
"""A frozen plot will not be updated when the current selection is changed."""
|
"""A frozen plot will not be updated when the current selection is changed."""
|
||||||
self._frozen = frozen
|
self._frozen = frozen
|
||||||
if not frozen:
|
if not frozen and self._current_selection != None:
|
||||||
self.set_current_selection(self._current_selection)
|
self.set_current_selection(self._current_selection)
|
||||||
|
|
||||||
def get_title(self):
|
def get_title(self):
|
||||||
|
@ -316,13 +338,12 @@ class Plot (View):
|
||||||
3.) the selections dim_name is the plot's dimension.
|
3.) the selections dim_name is the plot's dimension.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
self._current_selection = selection
|
||||||
if self._frozen \
|
if self._frozen \
|
||||||
or not self.get_property('visible') \
|
or not self.get_property('visible') \
|
||||||
or self.current_dim != dim_name:
|
or self.current_dim != dim_name:
|
||||||
return
|
return
|
||||||
else:
|
|
||||||
self._current_selection = selection
|
|
||||||
|
|
||||||
self.set_current_selection(selection)
|
self.set_current_selection(selection)
|
||||||
|
|
||||||
def set_selection_listener(self, listener):
|
def set_selection_listener(self, listener):
|
||||||
|
@ -726,10 +747,6 @@ class DefaultPlotMode (PlotMode):
|
||||||
def __init__(self, plot):
|
def __init__(self, plot):
|
||||||
PlotMode.__init__(self, plot, 'default', 'Default mode', 'cursor.png')
|
PlotMode.__init__(self, plot, 'default', 'Default mode', 'cursor.png')
|
||||||
|
|
||||||
def activate(self):
|
|
||||||
for k, v in self.canvas.callbacks.items():
|
|
||||||
print k, v
|
|
||||||
|
|
||||||
|
|
||||||
class PanPlotMode (PlotMode):
|
class PanPlotMode (PlotMode):
|
||||||
def __init__(self, plot):
|
def __init__(self, plot):
|
||||||
|
|
Reference in New Issue