Force hiding when running an activity even if the user hover the frame again.
This commit is contained in:
parent
978965bfa8
commit
ce91f2df99
@ -36,7 +36,7 @@ STATE_HIDING = 1
|
|||||||
MODE_NONE = 0
|
MODE_NONE = 0
|
||||||
MODE_MOUSE = 1
|
MODE_MOUSE = 1
|
||||||
MODE_KEYBOARD = 2
|
MODE_KEYBOARD = 2
|
||||||
MODE_NOT_INTERACTIVE = 3
|
MODE_FORCE = 3
|
||||||
|
|
||||||
_FRAME_HIDING_DELAY = 500
|
_FRAME_HIDING_DELAY = 500
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ 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):
|
def hide(self, force=False):
|
||||||
if self.state == STATE_HIDING:
|
if self.state == STATE_HIDING:
|
||||||
return
|
return
|
||||||
if self._animator:
|
if self._animator:
|
||||||
@ -165,7 +165,11 @@ class Frame(object):
|
|||||||
self._event_frame.show()
|
self._event_frame.show()
|
||||||
|
|
||||||
self.state = STATE_HIDING
|
self.state = STATE_HIDING
|
||||||
|
if force:
|
||||||
self.mode = MODE_NONE
|
self.mode = MODE_NONE
|
||||||
|
else:
|
||||||
|
self.mode = MODE_FORCE
|
||||||
|
self._animator.connect('completed', self._hide_completed_cb)
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
if self.state == STATE_SHOWING:
|
if self.state == STATE_SHOWING:
|
||||||
@ -180,7 +184,7 @@ class Frame(object):
|
|||||||
self._event_frame.hide()
|
self._event_frame.hide()
|
||||||
|
|
||||||
self.state = STATE_SHOWING
|
self.state = STATE_SHOWING
|
||||||
self.mode = MODE_NOT_INTERACTIVE
|
self.mode = MODE_FORCE
|
||||||
|
|
||||||
def get_popup_context(self):
|
def get_popup_context(self):
|
||||||
return self._popup_context
|
return self._popup_context
|
||||||
@ -281,6 +285,9 @@ 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_completed_cb(self, animator):
|
||||||
|
self.mode = MODE_NONE
|
||||||
|
|
||||||
def _size_changed_cb(self, screen):
|
def _size_changed_cb(self, screen):
|
||||||
self._update_position()
|
self._update_position()
|
||||||
|
|
||||||
|
@ -21,8 +21,14 @@ import gobject
|
|||||||
|
|
||||||
EASE_OUT_EXPO = 1
|
EASE_OUT_EXPO = 1
|
||||||
|
|
||||||
class Animator(object):
|
class Animator(gobject.GObject):
|
||||||
|
__gsignals__ = {
|
||||||
|
'completed': (gobject.SIGNAL_RUN_FIRST,
|
||||||
|
gobject.TYPE_NONE, ([])),
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, time, fps, easing=EASE_OUT_EXPO):
|
def __init__(self, time, fps, easing=EASE_OUT_EXPO):
|
||||||
|
gobject.GObject.__init__(self)
|
||||||
self._animations = []
|
self._animations = []
|
||||||
self._time = time
|
self._time = time
|
||||||
self._interval = 1.0 / fps
|
self._interval = 1.0 / fps
|
||||||
@ -44,13 +50,18 @@ class Animator(object):
|
|||||||
if self._timeout_sid:
|
if self._timeout_sid:
|
||||||
gobject.source_remove(self._timeout_sid)
|
gobject.source_remove(self._timeout_sid)
|
||||||
self._timeout_sid = 0
|
self._timeout_sid = 0
|
||||||
|
self.emit('completed')
|
||||||
|
|
||||||
def _next_frame_cb(self):
|
def _next_frame_cb(self):
|
||||||
current_time = min (self._time, time.time() - self._start_time)
|
current_time = min (self._time, time.time() - self._start_time)
|
||||||
for animation in self._animations:
|
for animation in self._animations:
|
||||||
animation.do_frame(current_time, self._time, self._easing)
|
animation.do_frame(current_time, self._time, self._easing)
|
||||||
|
|
||||||
return (current_time != self._time)
|
if current_time == self._time:
|
||||||
|
self.stop()
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
class Animation(object):
|
class Animation(object):
|
||||||
def __init__(self, start, end):
|
def __init__(self, start, end):
|
||||||
|
Loading…
Reference in New Issue
Block a user