-
Notifications
You must be signed in to change notification settings - Fork 363
Closed
Labels
guiRelated to arcade GUI (sub module arcade.gui)Related to arcade GUI (sub module arcade.gui)
Milestone
Description
Bug Report
Buttons behind Menus are drawn on top of Models, when leaving window with the mouse.
- Open demo
- click button
- leave window with mouse
-> Open button re-rendered on top of highest layer.
"""
Menu.
"""
import arcade
import arcade.gui
# Screen title and size
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
SCREEN_TITLE = "Making a Menu"
class MainView(arcade.View):
"""Main application class."""
def __init__(self):
super().__init__()
self.ui = arcade.gui.UIManager()
switch_menu_button = arcade.gui.UIFlatButton(text="Open", width=150)
switch_menu_button.center_on_screen()
self.ui.add(switch_menu_button)
@switch_menu_button.event("on_click")
def on_click_switch_button(event):
volume_menu = SubMenu()
self.ui.add(volume_menu)
self.submenu = volume_menu
def on_hide_view(self):
# Disable the UIManager when the view is hidden.
self.ui.disable()
def on_show_view(self):
"""This is run once when we switch to this view"""
arcade.set_background_color(arcade.color.DARK_BLUE_GRAY)
self.ui.enable()
def on_draw(self):
"""Render the screen."""
# Clear the screen
self.clear()
# Draw the ui.
self.ui.draw()
class SubMenu(arcade.gui.UIMouseFilterMixin, arcade.gui.UIAnchorLayout):
"""Acts like a fake view/window."""
def __init__(self, ):
super().__init__(size_hint=(1, 1))
# Setup frame which will act like the window.
frame = self.add(
arcade.gui.UIAnchorLayout(width=300, height=400, size_hint=None)
)
frame.with_padding(all=20)
# Add a background to the window.
# Nine patch smoothes the edges.
frame.with_background(
texture=arcade.gui.NinePatchTexture(
left=7,
right=7,
bottom=7,
top=7,
texture=arcade.load_texture(
":resources:gui_basic_assets/window/dark_blue_gray_panel.png"
),
)
)
back_button = arcade.gui.UIFlatButton(text="Back", width=250)
back_button.on_click = self.on_click_back_button
widget_layout = arcade.gui.UIBoxLayout(align="left", space_between=10)
widget_layout.add(back_button)
frame.add(child=widget_layout, anchor_x="center_x", anchor_y="top")
def on_click_back_button(self, event):
self.parent.remove(self)
def main():
"""Main function"""
window = arcade.Window(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE, resizable=True)
main_view = MainView()
window.show_view(main_view)
arcade.run()
if __name__ == "__main__":
main()
Metadata
Metadata
Assignees
Labels
guiRelated to arcade GUI (sub module arcade.gui)Related to arcade GUI (sub module arcade.gui)