Fix hover checking logic
This commit is contained in:
parent
84f6bdd0c9
commit
49b0db642e
@ -23,10 +23,14 @@ from sugar.graphics.window import Window
|
|||||||
class PanelWindow(Window):
|
class PanelWindow(Window):
|
||||||
def __init__(self, orientation):
|
def __init__(self, orientation):
|
||||||
Window.__init__(self)
|
Window.__init__(self)
|
||||||
|
self.hover = False
|
||||||
|
|
||||||
self._orientation = orientation
|
self._orientation = orientation
|
||||||
|
|
||||||
self.set_decorated(False)
|
self.set_decorated(False)
|
||||||
self.connect('realize', self._realize_cb)
|
self.connect('realize', self._realize_cb)
|
||||||
|
self.connect('enter-notify-event', self._enter_notify_cb)
|
||||||
|
self.connect('leave-notify-event', self._leave_notify_cb)
|
||||||
|
|
||||||
self._bg = hippo.CanvasBox(background_color=0x414141ff,
|
self._bg = hippo.CanvasBox(background_color=0x414141ff,
|
||||||
orientation=self._orientation)
|
orientation=self._orientation)
|
||||||
@ -63,6 +67,12 @@ class PanelWindow(Window):
|
|||||||
def _realize_cb(self, widget):
|
def _realize_cb(self, widget):
|
||||||
self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
|
self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
|
||||||
self.window.set_accept_focus(False)
|
self.window.set_accept_focus(False)
|
||||||
|
|
||||||
|
def _enter_notify_cb(self, window, event):
|
||||||
|
self.hover = True
|
||||||
|
|
||||||
|
def _leave_notify_cb(self, window, event):
|
||||||
|
self.hover = False
|
||||||
|
|
||||||
def _size_changed_cb(self, screen):
|
def _size_changed_cb(self, screen):
|
||||||
self._update_size()
|
self._update_size()
|
||||||
|
@ -125,7 +125,6 @@ class Frame(object):
|
|||||||
self._shell = shell
|
self._shell = shell
|
||||||
self._current_position = 0.0
|
self._current_position = 0.0
|
||||||
self._animator = None
|
self._animator = None
|
||||||
self._hover_frame = False
|
|
||||||
|
|
||||||
self._event_frame = EventFrame()
|
self._event_frame = EventFrame()
|
||||||
self._event_frame.connect('enter-corner', self._enter_corner_cb)
|
self._event_frame.connect('enter-corner', self._enter_corner_cb)
|
||||||
@ -151,6 +150,36 @@ class Frame(object):
|
|||||||
self._key_listener = _KeyListener(self)
|
self._key_listener = _KeyListener(self)
|
||||||
self._mouse_listener = _MouseListener(self)
|
self._mouse_listener = _MouseListener(self)
|
||||||
|
|
||||||
|
def hide(self):
|
||||||
|
if self.state == STATE_HIDING:
|
||||||
|
return
|
||||||
|
if self._animator:
|
||||||
|
self._animator.stop()
|
||||||
|
|
||||||
|
self._animator = animator.Animator(0.5, 30, animator.EASE_OUT_EXPO)
|
||||||
|
self._animator.add(_Animation(self, 0.0))
|
||||||
|
self._animator.start()
|
||||||
|
|
||||||
|
self._event_frame.show()
|
||||||
|
|
||||||
|
self.state = STATE_HIDING
|
||||||
|
self.mode = MODE_NONE
|
||||||
|
|
||||||
|
def show(self):
|
||||||
|
if self.state == STATE_SHOWING:
|
||||||
|
return
|
||||||
|
if self._animator:
|
||||||
|
self._animator.stop()
|
||||||
|
|
||||||
|
self._animator = animator.Animator(0.5, 30, animator.EASE_OUT_EXPO)
|
||||||
|
self._animator.add(_Animation(self, 1.0))
|
||||||
|
self._animator.start()
|
||||||
|
|
||||||
|
self._event_frame.hide()
|
||||||
|
|
||||||
|
self.state = STATE_SHOWING
|
||||||
|
self.mode = MODE_NOT_INTERACTIVE
|
||||||
|
|
||||||
def get_popup_context(self):
|
def get_popup_context(self):
|
||||||
return self._popup_context
|
return self._popup_context
|
||||||
|
|
||||||
@ -161,6 +190,12 @@ class Frame(object):
|
|||||||
self._current_position = pos
|
self._current_position = pos
|
||||||
self._update_position()
|
self._update_position()
|
||||||
|
|
||||||
|
def _is_hover(self):
|
||||||
|
return (self._top_panel.hover or \
|
||||||
|
self._bottom_panel.hover or \
|
||||||
|
self._left_panel.hover or \
|
||||||
|
self._right_panel.hover)
|
||||||
|
|
||||||
def _create_top_panel(self):
|
def _create_top_panel(self):
|
||||||
panel = self._create_panel(hippo.ORIENTATION_HORIZONTAL)
|
panel = self._create_panel(hippo.ORIENTATION_HORIZONTAL)
|
||||||
root = panel.get_root()
|
root = panel.get_root()
|
||||||
@ -244,36 +279,6 @@ class Frame(object):
|
|||||||
screen_w, 0,
|
screen_w, 0,
|
||||||
screen_w - units.grid_to_pixels(1), 0)
|
screen_w - units.grid_to_pixels(1), 0)
|
||||||
|
|
||||||
def hide(self):
|
|
||||||
if self.state == STATE_HIDING:
|
|
||||||
return
|
|
||||||
if self._animator:
|
|
||||||
self._animator.stop()
|
|
||||||
|
|
||||||
self._animator = animator.Animator(0.5, 30, animator.EASE_OUT_EXPO)
|
|
||||||
self._animator.add(_Animation(self, 0.0))
|
|
||||||
self._animator.start()
|
|
||||||
|
|
||||||
self._event_frame.show()
|
|
||||||
|
|
||||||
self.state = STATE_HIDING
|
|
||||||
self.mode = MODE_NONE
|
|
||||||
|
|
||||||
def show(self):
|
|
||||||
if self.state == STATE_SHOWING:
|
|
||||||
return
|
|
||||||
if self._animator:
|
|
||||||
self._animator.stop()
|
|
||||||
|
|
||||||
self._animator = animator.Animator(0.5, 30, animator.EASE_OUT_EXPO)
|
|
||||||
self._animator.add(_Animation(self, 1.0))
|
|
||||||
self._animator.start()
|
|
||||||
|
|
||||||
self._event_frame.hide()
|
|
||||||
|
|
||||||
self.state = STATE_SHOWING
|
|
||||||
self.mode = MODE_NOT_INTERACTIVE
|
|
||||||
|
|
||||||
def _size_changed_cb(self, screen):
|
def _size_changed_cb(self, screen):
|
||||||
self._update_position()
|
self._update_position()
|
||||||
|
|
||||||
@ -281,15 +286,13 @@ class Frame(object):
|
|||||||
self._mouse_listener.mouse_enter()
|
self._mouse_listener.mouse_enter()
|
||||||
|
|
||||||
def _popup_context_deactivated_cb(self, popup_context):
|
def _popup_context_deactivated_cb(self, popup_context):
|
||||||
if not self._hover_frame:
|
if not self._is_hover():
|
||||||
self._mouse_listener.mouse_leave()
|
self._mouse_listener.mouse_leave()
|
||||||
|
|
||||||
def _enter_notify_cb(self, window, event):
|
def _enter_notify_cb(self, window, event):
|
||||||
self._hover_frame = True
|
|
||||||
self._mouse_listener.mouse_enter()
|
self._mouse_listener.mouse_enter()
|
||||||
|
|
||||||
def _leave_notify_cb(self, window, event):
|
def _leave_notify_cb(self, window, event):
|
||||||
self._hover_frame = False
|
|
||||||
if not self._popup_context.is_active():
|
if not self._popup_context.is_active():
|
||||||
self._mouse_listener.mouse_leave()
|
self._mouse_listener.mouse_leave()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user