Fix part of bug 853, reposition and resize sugar frame after rotate

This commit is contained in:
Owen Williams 2007-02-24 13:28:04 -05:00 committed by Owen Williams
parent 067f703bfe
commit d7eb3fd734
2 changed files with 46 additions and 23 deletions

View File

@ -22,6 +22,7 @@ from sugar.graphics import units
class PanelWindow(gtk.Window):
def __init__(self, orientation):
gtk.Window.__init__(self)
self._orientation = orientation
self.set_decorated(False)
self.connect('realize', self._realize_cb)
@ -29,35 +30,46 @@ class PanelWindow(gtk.Window):
self._canvas = hippo.Canvas()
self._bg = hippo.CanvasBox(background_color=0x414141ff,
orientation=orientation)
padding = units.grid_to_pixels(1)
if orientation == hippo.ORIENTATION_HORIZONTAL:
self._bg.props.padding_left = padding
self._bg.props.padding_right = padding
width = gtk.gdk.screen_width()
height = units.grid_to_pixels(1)
else:
self._bg.props.padding_top = padding
self._bg.props.padding_bottom = padding
width = units.grid_to_pixels(1)
height = gtk.gdk.screen_height()
orientation=self._orientation)
self._update_size()
self._canvas.set_root(self._bg)
self.add(self._canvas)
self._canvas.show()
self.resize(width, height)
screen = gtk.gdk.screen_get_default()
screen.connect('size-changed', self._size_changed_cb)
def get_root(self):
return self._bg
def get_canvas(self):
return self._canvas
def _update_size(self):
padding = units.grid_to_pixels(1)
if self._orientation == hippo.ORIENTATION_HORIZONTAL:
self._bg.props.padding_left = padding
self._bg.props.padding_right = padding
self._bg.props.padding_top = 0
self._bg.props.padding_bottom = 0
width = gtk.gdk.screen_width()
height = units.grid_to_pixels(1)
else:
self._bg.props.padding_left = 0
self._bg.props.padding_right = 0
self._bg.props.padding_top = padding
self._bg.props.padding_bottom = padding
width = units.grid_to_pixels(1)
height = gtk.gdk.screen_height()
self.resize(width, height)
def _realize_cb(self, widget):
self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
self.window.set_accept_focus(False)
def _size_changed_cb(self, screen):
self._update_size()

View File

@ -50,6 +50,7 @@ class Frame:
self._hover_frame = False
self._shell = shell
self._mode = Frame.INACTIVE
self._current_position = 0
self._timeline = Timeline(self)
self._timeline.add_tag('slide_in', 18, 24)
@ -75,6 +76,9 @@ class Frame:
shell.get_model().connect('notify::state',
self._shell_state_changed_cb)
screen = gtk.gdk.screen_get_default()
screen.connect('size-changed', self._size_changed_cb)
def _create_top_panel(self):
panel = self._create_panel(hippo.ORIENTATION_HORIZONTAL)
@ -219,24 +223,28 @@ class Frame:
def notify_key_release(self):
if self._mode == Frame.TEMPORARY:
self._timeline.play('before_slide_out', 'slide_out')
def _move(self, pos):
self._current_position = pos
self._update_position()
def _update_position(self):
screen_h = gtk.gdk.screen_height()
screen_w = gtk.gdk.screen_width()
self._move_panel(self._top_panel, pos,
self._move_panel(self._top_panel, self._current_position,
0, units.grid_to_pixels(-1),
0, 0)
self._move_panel(self._bottom_panel, pos,
self._move_panel(self._bottom_panel, self._current_position,
0, screen_h,
0, screen_h - units.grid_to_pixels(1))
self._move_panel(self._left_panel, pos,
self._move_panel(self._left_panel, self._current_position,
units.grid_to_pixels(-1), 0,
0, 0)
self._move_panel(self._right_panel, pos,
self._move_panel(self._right_panel, self._current_position,
screen_w, 0,
screen_w - units.grid_to_pixels(1), 0)
@ -255,7 +263,10 @@ class Frame:
self._move(0)
if not self._event_frame.is_visible():
self._event_frame.show()
def _size_changed_cb(self, screen):
self._update_position()
def is_visible(self):
return self._top_panel.props.visible