Write a GridModel, with correct size and layout, and use it
This commit is contained in:
parent
fbc7bd8b97
commit
5988a89517
@ -11,30 +11,24 @@ from sugar.canvas.ScreenContainer import ScreenContainer
|
||||
from sugar.canvas.GridLayout import GridLayout
|
||||
from sugar.canvas.GridLayout import GridConstraints
|
||||
from sugar.canvas.GridLayout import GridGroup
|
||||
from sugar.canvas.GridModel import GridModel
|
||||
|
||||
class Frame:
|
||||
def __init__(self, shell, owner):
|
||||
self._windows = []
|
||||
|
||||
self._model = goocanvas.CanvasModelSimple()
|
||||
item = goocanvas.Rect(x=0, y=0, width=800, height=600,
|
||||
line_width=0, fill_color="#4f4f4f")
|
||||
self._model.get_root_item().add_child(item)
|
||||
self._model = GridModel("#4f4f4f")
|
||||
layout = self._model.get_layout()
|
||||
|
||||
self._screen_layout = GridLayout()
|
||||
self._screen_container = ScreenContainer(self._windows)
|
||||
|
||||
group = GridGroup()
|
||||
group.props.width = 800
|
||||
group.props.height = 600
|
||||
layout = group.get_layout()
|
||||
|
||||
constraints = GridConstraints(0, 11, 16, 1)
|
||||
self._create_window(constraints)
|
||||
|
||||
panel = BottomPanel(shell, owner.get_invites())
|
||||
layout.set_constraints(panel, constraints)
|
||||
group.add_child(panel)
|
||||
self._model.add(panel)
|
||||
|
||||
# Top
|
||||
constraints = GridConstraints(0, 0, 16, 1)
|
||||
@ -48,7 +42,6 @@ class Frame:
|
||||
constraints = GridConstraints(15, 1, 1, 10)
|
||||
self._create_window(constraints)
|
||||
|
||||
self._model.get_root_item().add_child(group)
|
||||
self._screen_container.set_layout(self._screen_layout)
|
||||
|
||||
def _create_window(self, constraints):
|
||||
|
@ -6,7 +6,7 @@ class CanvasWindow(gtk.Window):
|
||||
gtk.Window.__init__(self)
|
||||
|
||||
self._view = goocanvas.CanvasView()
|
||||
self._view.set_model(model)
|
||||
self._view.set_model(model.get())
|
||||
self.add(self._view)
|
||||
self._view.show()
|
||||
|
||||
|
30
sugar/canvas/GridModel.py
Normal file
30
sugar/canvas/GridModel.py
Normal file
@ -0,0 +1,30 @@
|
||||
import goocanvas
|
||||
|
||||
from sugar.canvas.GridLayout import GridGroup
|
||||
|
||||
# FIXME model subclassing doesn't work in pygoocanvas
|
||||
|
||||
class GridModel:
|
||||
def __init__(self, bg_color):
|
||||
self._model = goocanvas.CanvasModelSimple()
|
||||
|
||||
self._width = 800
|
||||
self._height = 600
|
||||
|
||||
item = goocanvas.Rect(width=self._width, height=self._height,
|
||||
line_width=0, fill_color=bg_color)
|
||||
self._model.get_root_item().add_child(item)
|
||||
|
||||
self._root = GridGroup()
|
||||
self._root.props.width = self._width
|
||||
self._root.props.height = self._height
|
||||
self._model.get_root_item().add_child(self._root)
|
||||
|
||||
def add(self, child):
|
||||
self._root.add_child(child)
|
||||
|
||||
def get(self):
|
||||
return self._model
|
||||
|
||||
def get_layout(self):
|
||||
return self._root.get_layout()
|
Loading…
Reference in New Issue
Block a user