1#!/usr/bin/env python3
2
3import pyglet
4import glooey
5import run_demos
6
7class TestScrollContent(glooey.Grid):
8    """
9    A 2x2 grid of event loggers that is 450x450 px.
10    """
11    custom_num_rows = 2
12    custom_num_cols = 2
13    custom_padding = 50
14
15    def __init__(self):
16        super().__init__()
17
18        for i in range(2):
19            for j in range(2):
20                self.add(i, j, glooey.EventLogger(150, 150, 'orange'))
21
22class TestScrollPane(glooey.ScrollPane):
23    custom_vert_scrolling = True
24    custom_horz_scrolling = True
25
26class TestHVScrollBar:
27
28    class Decoration(glooey.Background):
29        custom_color = 'dark'
30
31    class Forward(glooey.Button):
32        custom_size_hint = 20, 20
33        custom_alignment = 'fill'
34        custom_base_color = 'green'
35        custom_over_color = 'orange'
36        custom_down_color = 'purple'
37
38    class Backward(glooey.Button):
39        custom_size_hint = 20, 20
40        custom_alignment = 'fill'
41        custom_base_color = 'green'
42        custom_over_color = 'orange'
43        custom_down_color = 'purple'
44
45    class Grip(glooey.Button):
46        custom_size_hint = 20, 20
47        custom_alignment = 'fill'
48        custom_base_color = 'green'
49        custom_over_color = 'orange'
50        custom_down_color = 'purple'
51
52class TestHScrollBar(TestHVScrollBar, glooey.HScrollBar):
53    pass
54
55class TestVScrollBar(TestHVScrollBar, glooey.VScrollBar):
56    pass
57
58window = pyglet.window.Window()
59gui = glooey.Gui(window)
60grid = glooey.Grid(2, 2)
61
62frame = glooey.Frame()
63pane = TestScrollPane()
64hbar = TestHScrollBar(pane)
65vbar = TestVScrollBar(pane)
66big_content = TestScrollContent()
67small_content = glooey.Placeholder(100, 100)
68
69grid.size_hint = 200, 200
70grid.padding = 10
71grid.set_row_height(1, 0)
72grid.set_col_width(1, 0)
73grid.alignment = 'center'
74frame.alignment = 'fill'
75frame.decoration.outline = 'green'
76
77pane.add(big_content)
78frame.add(pane)
79grid.add(0, 0, frame)
80grid.add(0, 1, vbar)
81grid.add(1, 0, hbar)
82gui.add(grid)
83
84@run_demos.on_space(gui)
85def interactive_mover_tests():
86    vbar.scale_grip = False
87    hbar.scale_grip = False
88    #yield "Horizontal and vertical scroll bars."
89
90    pane.add(small_content)
91    yield "Content smaller than the pane."
92    pane.add(big_content)
93
94    vbar.scale_grip = True
95    hbar.scale_grip = True
96    yield "Scaled scroll grips."
97
98    pane.add(small_content)
99    yield "Scaled scroll grips with content smaller than the pane."
100    pane.add(big_content)
101
102pyglet.app.run()
103
104
105
106