Highlight buttons and change menu background to black.
This commit is contained in:
parent
93386a4d8a
commit
6a58df67a0
@ -173,8 +173,8 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem):
|
||||
|
||||
hippo.CanvasBox.__init__(self, **kwargs)
|
||||
|
||||
self.connect('motion-notify-event', self._motion_notify_event_cb)
|
||||
self.connect('button-press-event', self._button_press_event_cb)
|
||||
self.connect_after('button-press-event', self._button_press_event_cb)
|
||||
self.connect_after('motion-notify-event', self._motion_notify_event_cb)
|
||||
|
||||
def _clear_buffers(self):
|
||||
cur_buf_key = self._get_current_buffer_key()
|
||||
@ -314,16 +314,16 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem):
|
||||
|
||||
def _button_press_event_cb(self, item, event):
|
||||
item.emit_activated()
|
||||
return False
|
||||
|
||||
def get_popup(self):
|
||||
if self._tooltip:
|
||||
tooltip_popup = Popup()
|
||||
canvas_text = hippo.CanvasText(text=self._tooltip)
|
||||
canvas_text.props.background_color = color.MENU_BACKGROUND.get_int()
|
||||
canvas_text.props.border_color = color.MENU_BORDER.get_int()
|
||||
canvas_text.props.border = units.points_to_pixels(1)
|
||||
canvas_text.props.color = color.LABEL_TEXT.get_int()
|
||||
canvas_text.props.font_desc = font.DEFAULT.get_pango_desc()
|
||||
canvas_text.props.padding = units.points_to_pixels(5)
|
||||
tooltip_popup.append(canvas_text)
|
||||
|
||||
return tooltip_popup
|
||||
@ -364,7 +364,7 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem):
|
||||
|
||||
popup.popup(x, y)
|
||||
popup.connect('motion-notify-event',
|
||||
self._popup_motion_notify_event_cb)
|
||||
self.popup_motion_notify_event_cb)
|
||||
popup.connect('action-completed',
|
||||
self._popup_action_completed_cb)
|
||||
|
||||
@ -389,17 +389,29 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem):
|
||||
def _motion_notify_event_cb(self, button, event):
|
||||
if event.detail == hippo.MOTION_DETAIL_ENTER:
|
||||
self._timeline.play(None, 'popup')
|
||||
self.prelight(enter=True)
|
||||
elif event.detail == hippo.MOTION_DETAIL_LEAVE:
|
||||
if not self._hover_popup:
|
||||
self._timeline.play('before_popdown', 'popdown')
|
||||
self.prelight(enter=False)
|
||||
return False
|
||||
|
||||
def _popup_motion_notify_event_cb(self, popup, event):
|
||||
def popup_motion_notify_event_cb(self, popup, event):
|
||||
if event.detail == hippo.MOTION_DETAIL_ENTER:
|
||||
self._hover_popup = True
|
||||
self._timeline.play('popup', 'popup')
|
||||
self.prelight(enter=True)
|
||||
elif event.detail == hippo.MOTION_DETAIL_LEAVE:
|
||||
self._hover_popup = False
|
||||
self._timeline.play('popdown', 'popdown')
|
||||
self.prelight(enter=False)
|
||||
return False
|
||||
|
||||
def _popup_action_completed_cb(self, popup):
|
||||
self.popdown()
|
||||
|
||||
def prelight(self, enter):
|
||||
"""
|
||||
Override this method for adding prelighting behavior.
|
||||
"""
|
||||
pass
|
||||
|
@ -12,7 +12,7 @@ _system_colors = {
|
||||
'entry-border' : '#D1D1D2',
|
||||
'label-text' : '#FFFFFF',
|
||||
'desktop-background' : '#E2E2E3',
|
||||
'menu-background' : '#414141',
|
||||
'menu-background' : '#000000',
|
||||
'menu-separator' : '#D1D1D2',
|
||||
'menu-border' : '#D1D1D2',
|
||||
'button-normal' : '#FFFFFF',
|
||||
|
@ -21,8 +21,8 @@ import gobject
|
||||
import hippo
|
||||
|
||||
from canvasicon import CanvasIcon
|
||||
from xocolor import XoColor
|
||||
from sugar.graphics import units
|
||||
from sugar.graphics import color
|
||||
from sugar import profile
|
||||
|
||||
STANDARD_SIZE = 0
|
||||
@ -44,16 +44,20 @@ class IconButton(CanvasIcon):
|
||||
|
||||
CanvasIcon.__init__(self, cache=True, **kwargs)
|
||||
|
||||
self._prelight_color = profile.get_color()
|
||||
self._inactive_color = XoColor('#808080,#424242')
|
||||
self._normal_color = XoColor('white')
|
||||
if not self.props.fill_color:
|
||||
self.props.fill_color = color.BUTTON_BACKGROUND_NORMAL
|
||||
if not self.props.stroke_color:
|
||||
self.props.stroke_color = color.BUTTON_NORMAL
|
||||
self.props.background_color = color.BUTTON_BACKGROUND_NORMAL.get_int()
|
||||
|
||||
if not self.props.xo_color:
|
||||
self.props.xo_color = self._normal_color
|
||||
self._normal_fill_color = self.props.fill_color
|
||||
self._normal_stroke_color = self.props.stroke_color
|
||||
self._normal_background_color = self.props.background_color
|
||||
|
||||
self._set_size(STANDARD_SIZE)
|
||||
|
||||
self.connect('button-press-event', self._button_press_event_cb)
|
||||
self.connect('button-press-event',
|
||||
self._icon_button_button_press_event_cb)
|
||||
|
||||
def _set_size(self, size):
|
||||
if size == SMALL_SIZE:
|
||||
@ -73,9 +77,13 @@ class IconButton(CanvasIcon):
|
||||
elif pspec.name == 'active':
|
||||
self._active = value
|
||||
if self._active:
|
||||
self.props.xo_color = self._normal_color
|
||||
self.props.fill_color = self._normal_fill_color
|
||||
self.props.stroke_color = self._normal_stroke_color
|
||||
self.props.background_color = self._normal_background_color
|
||||
else:
|
||||
self.props.xo_color = self._inactive_color
|
||||
self.props.fill_color = color.BUTTON_BACKGROUND_INACTIVE
|
||||
self.props.stroke_color = color.BUTTON_INACTIVE
|
||||
self.props.background_color = color.BUTTON_BACKGROUND_INACTIVE.get_int()
|
||||
else:
|
||||
CanvasIcon.do_set_property(self, pspec, value)
|
||||
|
||||
@ -87,7 +95,17 @@ class IconButton(CanvasIcon):
|
||||
else:
|
||||
return CanvasIcon.do_get_property(self, pspec)
|
||||
|
||||
def _button_press_event_cb(self, widget, event):
|
||||
def _icon_button_button_press_event_cb(self, widget, event):
|
||||
if self._active:
|
||||
self.emit_activated()
|
||||
return True
|
||||
|
||||
def prelight(self, enter):
|
||||
if enter:
|
||||
if self._active:
|
||||
self.props.fill_color = color.BLACK
|
||||
self.props.background_color = color.BLACK.get_int()
|
||||
else:
|
||||
if self._active:
|
||||
self.props.fill_color = self._normal_fill_color
|
||||
self.props.background_color = self._normal_background_color
|
||||
|
Loading…
Reference in New Issue
Block a user