Exemplo n.º 1
0
Arquivo: base.py Projeto: pybee/toga
    def rehint(self):
        # print("REHINT", self, self.native.get_preferred_width(), self.native.get_preferred_height())
        width = self.native.get_preferred_width()
        height = self.native.get_preferred_height()

        self.interface.intrinsic.width = at_least(width[0])
        self.interface.intrinsic.height = at_least(height[0])
Exemplo n.º 2
0
    def test_tutorial_1(self):
        root = TestNode(
            'app', style=Pack(direction=COLUMN, padding_top=10), children=[
                TestNode('f_box', style=Pack(direction=ROW, padding=5), children=[
                    TestNode('f_input', style=Pack(flex=1, padding_left=160), size=(at_least(100), 15)),
                    TestNode('f_label', style=Pack(width=100, padding_left=10), size=(at_least(40), 10)),
                ]),
                TestNode('c_box', style=Pack(direction=ROW, padding=5), children=[
                    TestNode('join_label', style=Pack(width=150, padding_right=10), size=(at_least(80), 10)),
                    TestNode('c_input', style=Pack(flex=1), size=(at_least(100), 15)),
                    TestNode('c_label', style=Pack(width=100, padding_left=10), size=(at_least(40), 10)),
                ]),
                TestNode('button', style=Pack(flex=1, padding=15), size=(at_least(120), 30)),
            ]
        )

        # Minimum size
        root.style.layout(root, Viewport(0, 0))
        self.assertLayout(
            root,
            (380, 120),
            {'origin': (0, 10), 'content': (380, 110), 'children': [
                {'origin': (5, 15), 'content': (370, 15), 'children': [
                    {'origin': (165, 15), 'content': (100, 15)},
                    {'origin': (275, 15), 'content': (100, 10)},
                ]},
                {'origin': (5, 40), 'content': (370, 15), 'children': [
                    {'origin': (5, 40), 'content': (150, 10)},
                    {'origin': (165, 40), 'content': (100, 15)},
                    {'origin': (275, 40), 'content': (100, 10)},
                ]},
                {'origin': (15, 75), 'content': (120, 30)}
            ]}
        )

        # Normal size
        root.style.layout(root, Viewport(640, 480))
        self.assertLayout(
            root,
            (640, 120),
            {'origin': (0, 10), 'content': (640, 110), 'children': [
                {'origin': (5, 15), 'content': (630, 15), 'children': [
                    {'origin': (165, 15), 'content': (360, 15)},
                    {'origin': (535, 15), 'content': (100, 10)},
                ]},
                {'origin': (5, 40), 'content': (630, 15), 'children': [
                    {'origin': (5, 40), 'content': (150, 10)},
                    {'origin': (165, 40), 'content': (360, 15)},
                    {'origin': (535, 40), 'content': (100, 10)},
                ]},
                {'origin': (15, 75), 'content': (610, 30)}
            ]}
        )
Exemplo n.º 3
0
    def rehint(self):
        # Height of a text input is known and fixed.
        stepper_size = self.input.intrinsicContentSize()
        input_size = self.input.intrinsicContentSize()

        self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
        self.interface.intrinsic.height = max(input_size.height, stepper_size.height)
Exemplo n.º 4
0
Arquivo: label.py Projeto: pybee/toga
    def rehint(self):
        # print("REHINT", self, self.native.get_preferred_width(), self.native.get_preferred_height(), getattr(self, '_fixed_height', False), getattr(self, '_fixed_width', False))
        width = self.native.get_preferred_width()
        height = self.native.get_preferred_height()

        self.interface.intrinsic.width = at_least(width[0])
        self.interface.intrinsic.height = height[1]
Exemplo n.º 5
0
    def test_tutorial_0(self):
        root = TestNode(
            'app', style=Pack(), children=[
                TestNode('button', style=Pack(flex=1, padding=50), size=(at_least(120), 30)),
            ]
        )

        # Minimum size
        root.style.layout(root, Viewport(0, 0))
        self.assertLayout(
            root,
            (220, 130),
            {'origin': (0, 0), 'content': (220, 130), 'children': [
                {'origin': (50, 50), 'content': (120, 30)}
            ]}
        )

        # Normal size
        root.style.layout(root, Viewport(640, 480))
        self.assertLayout(
            root,
            (640, 130),
            {'origin': (0, 0), 'content': (640, 130), 'children': [
                {'origin': (50, 50), 'content': (540, 30)}
            ]}
        )
Exemplo n.º 6
0
Arquivo: slider.py Projeto: pybee/toga
    def rehint(self):
        # print("REHINT", self, self.native.get_preferred_width(), self.native.get_preferred_height())
        width = self.native.get_preferred_width()
        height = self.native.get_preferred_height()

        # Set intrinsic width to at least the minimum width
        self.interface.intrinsic.width = at_least(width[0])
        # Set intrinsic height to the natural height
        self.interface.intrinsic.height = height[1]
Exemplo n.º 7
0
    def test_beeliza(self):
        root = TestNode(
            'app', style=Pack(direction=COLUMN), children=[
                TestNode('detailedlist', style=Pack(flex=1), size=(at_least(100), at_least(100))),
                TestNode('box', style=Pack(direction=ROW), children=[
                    TestNode('input', style=Pack(flex=1, padding=5), size=(at_least(100), 15)),
                    TestNode('button', style=Pack(padding=5), size=(at_least(40), 10)),
                ]),
            ]
        )

        # Minimum size
        root.style.layout(root, Viewport(0, 0))
        self.assertLayout(
            root,
            (160, 125),
            {'origin': (0, 0), 'content': (160, 125), 'children': [
                {'origin': (0, 0), 'content': (100, 100)},
                {'origin': (0, 100), 'content': (160, 25), 'children': [
                    {'origin': (5, 105), 'content': (100, 15)},
                    {'origin': (115, 105), 'content': (40, 10)},
                ]},
            ]}
        )

        # Normal size
        root.style.layout(root, Viewport(640, 480))
        self.assertLayout(
            root,
            (640, 480),
            {'origin': (0, 0), 'content': (640, 480), 'children': [
                {'origin': (0, 0), 'content': (640, 455)},
                {'origin': (0, 455), 'content': (640, 25), 'children': [
                    {'origin': (5, 460), 'content': (580, 15)},
                    {'origin': (595, 460), 'content': (40, 10)},
                ]},
            ]}
        )
Exemplo n.º 8
0
    def test_tutorial_3(self):
        root = TestNode(
            'app', style=Pack(direction=COLUMN), children=[
                TestNode('box', style=Pack(), children=[
                    TestNode('input', style=Pack(flex=1, padding=5), size=(at_least(100), 15)),
                    TestNode('button', style=Pack(width=50, padding=5), size=(at_least(40), 10)),
                ]),
                TestNode('web', style=Pack(flex=1), size=(at_least(100), at_least(100))),
            ]
        )

        # Minimum size
        root.style.layout(root, Viewport(0, 0))
        self.assertLayout(
            root,
            (170, 125),
            {'origin': (0, 0), 'content': (170, 125), 'children': [
                {'origin': (0, 0), 'content': (170, 25), 'children': [
                    {'origin': (5, 5), 'content': (100, 15)},
                    {'origin': (115, 5), 'content': (50, 10)},
                ]},
                {'origin': (0, 25), 'content': (100, 100)}
            ]}
        )

        # Normal size
        root.style.layout(root, Viewport(640, 480))
        self.assertLayout(
            root,
            (640, 480),
            {'origin': (0, 0), 'content': (640, 480), 'children': [
                {'origin': (0, 0), 'content': (640, 25), 'children': [
                    {'origin': (5, 5), 'content': (570, 15)},
                    {'origin': (585, 5), 'content': (50, 10)},
                ]},
                {'origin': (0, 25), 'content': (640, 455)}
            ]}
        )
Exemplo n.º 9
0
 def rehint(self):
     # Height of a text input is known and fixed.
     # Width must be > 100
     # print("REHINT TextInput", self, self.native.PreferredSize)
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = self.native.PreferredSize.Height
Exemplo n.º 10
0
 def rehint(self):
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = at_least(self.interface.MIN_HEIGHT)
Exemplo n.º 11
0
 def rehint(self):
     # Height of a date input is known and fixed.
     # Width must be > 100
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = self.native.PreferredSize.Height
Exemplo n.º 12
0
 def rehint(self):
     # Height of a text input is known.
     fitting_size = self.native.systemLayoutSizeFittingSize(CGSize(0, 0))
     self.interface.intrinsic.width = at_least(fitting_size.width)
     self.interface.intrinsic.height = fitting_size.height
Exemplo n.º 13
0
 def rehint(self):
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = self.native.intrinsicContentSize().height
Exemplo n.º 14
0
 def rehint(self):
     # Height of a text input is known and fixed.
     # print("REHINT text input", self, self.native.getMeasuredWidth(), self.native.getMeasuredHeight())
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = self.native.getMeasuredHeight(
     ) / self.app.native.device_scale
Exemplo n.º 15
0
 def rehint(self):
     self.interface.intrinsic.width = at_least(self.interface.size[0])
     self.interface.intrinsic.height = at_least(self.interface.size[1])
Exemplo n.º 16
0
 def test_at_least_repr(self):
     self.assertEqual(repr(at_least(10)), 'at least 10')
Exemplo n.º 17
0
 def rehint(self):
     # Height of a text input is known.
     fitting_size = self.native.systemLayoutSizeFittingSize(CGSize(0, 0))
     self.interface.intrinsic.width = at_least(fitting_size.width)
     self.interface.intrinsic.height = fitting_size.height
Exemplo n.º 18
0
    def rehint(self):
        width = self.native.get_preferred_width()
        height = self.native.get_preferred_height()

        self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
        self.interface.intrinsic.height = height[1]
Exemplo n.º 19
0
 def rehint(self):
     fitting_size = self.native.fittingSize()
     self.interface.intrinsic.height = fitting_size.height
     self.interface.intrinsic.width = at_least(fitting_size.width)
Exemplo n.º 20
0
 def rehint(self):
     # Width & height of a label is known and fixed.
     # print("REHINT label", self, self.native.fittingSize().width, self.native.fittingSize().height)
     fitting_size = self.native.systemLayoutSizeFittingSize(CGSize(0, 0))
     self.interface.intrinsic.width = at_least(fitting_size.width)
     self.interface.intrinsic.height = fitting_size.height
Exemplo n.º 21
0
Arquivo: label.py Projeto: pybee/toga
 def rehint(self):
     # Width & height of a label is known and fixed.
     # print("REHINT label", self, self.native.fittingSize().width, self.native.fittingSize().height)
     fitting_size = self.native.systemLayoutSizeFittingSize(CGSize(0, 0))
     self.interface.intrinsic.width = at_least(fitting_size.width)
     self.interface.intrinsic.height = fitting_size.height
Exemplo n.º 22
0
 def rehint(self):
     width = self.native.get_preferred_width()
     height = self.native.get_preferred_height()
     if width and height:
         self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
         self.interface.intrinsic.height = height[1]
Exemplo n.º 23
0
 def rehint(self):
     # Height of a text input is known and fixed.
     # Width must be > 100
     # print("REHINT TextInput", self, self.native.PreferredSize)
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = self.native.PreferredSize.Height
Exemplo n.º 24
0
Arquivo: label.py Projeto: pybee/toga
 def rehint(self):
     # Width & height of a label is known and fixed.
     content_size = self.native.intrinsicContentSize()
     # print("REHINT label", self, content_size.width, content_size.height)
     self.interface.intrinsic.width = at_least(content_size.width)
     self.interface.intrinsic.height = content_size.height
Exemplo n.º 25
0
 def rehint(self):
     # print("REHINT label", self, self.native.getMeasuredWidth(), self.native.getMeasuredHeight())
     self.interface.intrinsic.width = at_least(
         self.native.getMeasuredWidth() / self.app.device_scale)
     self.interface.intrinsic.height = self.native.getMeasuredHeight(
     ) / self.app.device_scale
Exemplo n.º 26
0
 def rehint(self):
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = self.native.fittingSize().height
Exemplo n.º 27
0
 def rehint(self):
     # Height of a text input is known and fixed.
     # Width must be > 100
     # print("REHINT TextInput", self, self._impl.intrinsicContentSize().width, self._impl.intrinsicContentSize().height)
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = self.native.intrinsicContentSize().height
Exemplo n.º 28
0
 def rehint(self):
     # self.native.Size = Size(0, 0)
     # print("REHINT Button", self, self.native.PreferredSize)
     self.interface.intrinsic.width = at_least(
         self.native.PreferredSize.Width)
     self.interface.intrinsic.height = self.native.PreferredSize.Height
Exemplo n.º 29
0
 def rehint(self):
     self.interface.intrinsic.width = at_least(self.native.PreferredSize.Width)
     self.interface.intrinsic.height = self.native.PreferredSize.Height
Exemplo n.º 30
0
 def test_size_repr(self):
     self.assertEqual(repr(self.size), '(1, 2)')
     self.size.width = at_least(10)
     self.assertEqual(repr(self.size), '(at least 10, 2)')
Exemplo n.º 31
0
 def rehint(self):
     # Height of a date input is known and fixed.
     # Width must be > 200
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = self.native.PreferredSize.Height
Exemplo n.º 32
0
Arquivo: button.py Projeto: pybee/toga
 def rehint(self):
     content_size = self.native.intrinsicContentSize()
     self.interface.intrinsic.width = at_least(content_size.width)
     self.interface.intrinsic.height = content_size.height
Exemplo n.º 33
0
 def rehint(self):
     self.native.measure(View__MeasureSpec.UNSPECIFIED,
                         View__MeasureSpec.UNSPECIFIED)
     self.interface.intrinsic.width = at_least(
         self.native.getMeasuredWidth())
     self.interface.intrinsic.height = self.native.getMeasuredHeight()
Exemplo n.º 34
0
Arquivo: label.py Projeto: pybee/toga
 def rehint(self):
     # print("REHINT label", self, self.native.getMeasuredWidth(), self.native.getMeasuredHeight())
     self.interface.intrinsic.width = at_least(self.native.getMeasuredWidth() / self.app.device_scale)
     self.interface.intrinsic.height = self.native.getMeasuredHeight() / self.app.device_scale
Exemplo n.º 35
0
 def rehint(self):
     fitting_size = self.native.systemLayoutSizeFittingSize_(CGSize(0, 0))
     self.interface.intrinsic.width = at_least(fitting_size.width)
     self.interface.intrinsic.height = fitting_size.height
Exemplo n.º 36
0
 def rehint(self):
     content_size = self.native.intrinsicContentSize()
     self.interface.intrinsic.height = content_size.height
     self.interface.intrinsic.width = at_least(max(self.interface.MIN_WIDTH, content_size.width))
Exemplo n.º 37
0
 def rehint(self):
     content_size = self.native.intrinsicContentSize()
     self.interface.intrinsic.height = content_size.height
     self.interface.intrinsic.width = at_least(content_size.width)
Exemplo n.º 38
0
Arquivo: canvas.py Projeto: pybee/toga
 def rehint(self):
     fitting_size = self.native.systemLayoutSizeFittingSize(CGSize(0, 0))
     self.interface.intrinsic.width = at_least(fitting_size.width)
     self.interface.intrinsic.height = at_least(fitting_size.height)
Exemplo n.º 39
0
 def rehint(self):
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = self.native.PreferredSize.Height
Exemplo n.º 40
0
 def rehint(self):
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = at_least(self.interface.MIN_HEIGHT)
Exemplo n.º 41
0
 def rehint(self):
     # Height of a text input is known and fixed.
     # print("REHINT text input", self, self.native.getMeasuredWidth(), self.native.getMeasuredHeight())
     self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH)
     self.interface.intrinsic.height = self.native.getMeasuredHeight() / self.app.native.device_scale