Skip to content

Commit 34a56d4

Browse files
authored
GUI: Add UIView (#2036)
* GUI: Add UIView * Fix docs * expose UIView * fix imports
1 parent 6e985b7 commit 34a56d4

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

arcade/gui/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@
3030
from arcade.gui.widgets import UIInteractiveWidget
3131
from arcade.gui.widgets import UILayout
3232
from arcade.gui.widgets import UISpace
33+
from arcade.gui.view import UIView
34+
from arcade.gui.widgets.dropdown import UIDropdown
3335
from arcade.gui.widgets import UISpriteWidget
3436
from arcade.gui.widgets import UIWidget
3537
from arcade.gui.widgets.buttons import (
3638
UITextureButton,
3739
UITextureButtonStyle,
3840
UIFlatButton,
3941
)
40-
from arcade.gui.widgets.dropdown import UIDropdown
4142
from arcade.gui.widgets.image import UIImage
4243
from arcade.gui.widgets.layout import UIBoxLayout, UIAnchorLayout, UIGridLayout
4344
from arcade.gui.widgets.slider import UIBaseSlider, UISlider, UITextureSlider, UISliderStyle
@@ -66,6 +67,7 @@
6667
"UIInputText",
6768
"UILayout",
6869
"UILabel",
70+
"UIView",
6971
"UIMouseEvent",
7072
"UIMouseDragEvent",
7173
"UIMouseMovementEvent",

arcade/gui/view.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from arcade import View
2+
from arcade.gui import UIManager
3+
4+
5+
class UIView(View):
6+
"""This view provides basic GUI setup.
7+
8+
This is a convenience class, which adds the UIManager to the view under `self.ui`.
9+
The UIManager is enabled when the view is shown and disabled when the view is hidden.
10+
11+
If you override ``on_show_view`` or ``on_show_view``,
12+
don't forget to call super().on_show_view() or super().on_hide_view().
13+
14+
"""
15+
16+
def __init__(self):
17+
super().__init__()
18+
self.ui = UIManager()
19+
20+
def on_show_view(self):
21+
self.ui.enable()
22+
23+
def on_hide_view(self):
24+
self.ui.disable()

util/update_quick_index.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
'gui/surface.py': ['GUI', 'gui.rst'],
7777
'gui/ui_manager.py': ['GUI', 'gui.rst'],
7878
'gui/nine_patch.py': ['GUI', 'gui.rst'],
79+
'gui/view.py': ['GUI', 'gui.rst'],
7980
'widgets/__init__.py': ['GUI Widgets', 'gui_widgets.rst'],
8081
'widgets/buttons.py': ['GUI Widgets', 'gui_widgets.rst'],
8182
'widgets/dropdown.py': ['GUI Widgets', 'gui_widgets.rst'],

0 commit comments

Comments
 (0)