mirror of
https://github.com/csd4ni3l/fractal-viewer.git
synced 2026-01-01 04:13:41 +01:00
Remove unnecesseray double UIAnchorLayout with controller support and setting of controller events on window
This commit is contained in:
@@ -6,7 +6,6 @@ from utils.constants import button_style, dropdown_style, slider_style, settings
|
||||
from utils.utils import FakePyPresence
|
||||
from utils.preload import button_texture, button_hovered_texture
|
||||
|
||||
from arcade.gui import UIBoxLayout, UIAnchorLayout
|
||||
from arcade.gui.experimental.focus import UIFocusGroup
|
||||
|
||||
class Settings(arcade.gui.UIView):
|
||||
@@ -30,17 +29,16 @@ class Settings(arcade.gui.UIView):
|
||||
self.modified_settings = {}
|
||||
|
||||
def create_layouts(self):
|
||||
self.root = self.add_widget(UIFocusGroup())
|
||||
self.anchor = self.root.add(UIAnchorLayout(size_hint=(1, 1)))
|
||||
self.anchor = self.add_widget(UIFocusGroup(size_hint=(1, 1)))
|
||||
|
||||
self.box = UIBoxLayout(space_between=50, align="center", vertical=False)
|
||||
self.box = arcade.gui.UIBoxLayout(space_between=50, align="center", vertical=False)
|
||||
self.anchor.add(self.box, anchor_x="center", anchor_y="top", align_x=10, align_y=-75)
|
||||
|
||||
self.top_box = UIBoxLayout(space_between=self.window.width / 160, vertical=False)
|
||||
self.top_box = arcade.gui.UIBoxLayout(space_between=self.window.width / 160, vertical=False)
|
||||
self.anchor.add(self.top_box, anchor_x="left", anchor_y="top", align_x=10, align_y=-10)
|
||||
|
||||
self.key_layout = self.box.add(UIBoxLayout(space_between=20, align='left'))
|
||||
self.value_layout = self.box.add(UIBoxLayout(space_between=13, align='left'))
|
||||
self.key_layout = self.box.add(arcade.gui.UIBoxLayout(space_between=20, align='left'))
|
||||
self.value_layout = self.box.add(arcade.gui.UIBoxLayout(space_between=13, align='left'))
|
||||
|
||||
def on_show_view(self):
|
||||
super().on_show_view()
|
||||
@@ -68,7 +66,7 @@ class Settings(arcade.gui.UIView):
|
||||
|
||||
self.top_box.add(category_button)
|
||||
|
||||
self.root.detect_focusable_widgets()
|
||||
self.anchor.detect_focusable_widgets()
|
||||
|
||||
def display_category(self, category):
|
||||
if hasattr(self, 'apply_button'):
|
||||
@@ -96,7 +94,7 @@ class Settings(arcade.gui.UIView):
|
||||
self.value_layout.add(dropdown)
|
||||
|
||||
elif setting_dict['type'] == "bool":
|
||||
button_layout = self.value_layout.add(arcade.gui.UIBoxLayout(space_between=50, vertical=False))
|
||||
button_layout = self.value_layout.add(arcade.gui.arcade.gui.UIBoxLayout(space_between=50, vertical=False))
|
||||
|
||||
on_radiobutton = arcade.gui.UITextureButton(texture=button_texture, texture_hovered=button_hovered_texture, text="ON", style=button_style, width=150, height=50)
|
||||
self.on_radiobuttons[setting] = on_radiobutton
|
||||
@@ -139,7 +137,7 @@ class Settings(arcade.gui.UIView):
|
||||
self.apply_button.on_click = lambda event: self.apply_settings()
|
||||
self.anchor.add(self.apply_button, anchor_x="right", anchor_y="bottom", align_x=-10, align_y=10)
|
||||
|
||||
self.root.detect_focusable_widgets()
|
||||
self.anchor.detect_focusable_widgets()
|
||||
|
||||
def apply_settings(self):
|
||||
for config_key, value in self.modified_settings.items():
|
||||
@@ -272,7 +270,7 @@ class Settings(arcade.gui.UIView):
|
||||
|
||||
self.key_layout.add(self.credits_label)
|
||||
|
||||
self.root.detect_focusable_widgets()
|
||||
self.anchor.detect_focusable_widgets()
|
||||
|
||||
def set_highlighted_style(self, element):
|
||||
element.texture = button_hovered_texture
|
||||
|
||||
Reference in New Issue
Block a user