Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
626e52e
remove a lot of type: ignore in gui code (nearly all of them)
eruvanos Sep 5, 2024
d34ab8c
fix type warnings in gui examples
eruvanos Sep 5, 2024
ff93ee8
UIWidget.remove now returns the kwargs it was added with
eruvanos Sep 5, 2024
4754599
Fix 3.9 compatibility
eruvanos Sep 7, 2024
e32d119
Fix UISlider does not catch drag event
eruvanos Sep 11, 2024
ba2aeeb
Improve typing
eruvanos Sep 11, 2024
137387d
Add test for slider disabled
eruvanos Sep 11, 2024
4bd75f0
Fix ignore inputs when slider disabled
eruvanos Sep 11, 2024
412d7f6
Fix types
eruvanos Sep 11, 2024
7d07bbc
Fix types
eruvanos Sep 11, 2024
d7f9651
Use pyglet constant
eruvanos Sep 11, 2024
9929151
Higher contrast for gui example texts
eruvanos Sep 11, 2024
9ff5e72
Add scroll indicator to scrollable UITextArea
eruvanos Sep 11, 2024
4483b80
Add scroll indicator to scrollable UITextArea
eruvanos Sep 11, 2024
e51ed6f
Format
eruvanos Sep 11, 2024
721fe80
fix gui docs and tutorial
eruvanos Sep 17, 2024
c24e2ab
Improve experimental UIScrollArea
eruvanos Sep 17, 2024
5fbec3b
Fix typing
eruvanos Sep 17, 2024
0691516
Fix docs
eruvanos Sep 17, 2024
0287f86
Use same import structure in gui examples
eruvanos Sep 18, 2024
d8e2cd7
Improve box algorithm, to fix issues with min_size
eruvanos Sep 19, 2024
1ff8816
Improve debug output of UIManager
eruvanos Sep 19, 2024
58c7663
higher contrast in widget example
eruvanos Sep 19, 2024
c772b92
Add size hint example
eruvanos Sep 19, 2024
3b6f104
Add documentation about how to create an own widget
eruvanos Sep 22, 2024
42494b7
Fix docs
eruvanos Sep 22, 2024
b92503f
Fix line length
eruvanos Sep 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion arcade/examples/gui/0_basic_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
UIManager,
UITextureButton,
UIAnchorLayout,
UIView,
)

# Preload textures, because they are mostly used multiple times, so they are not
Expand Down Expand Up @@ -70,7 +71,7 @@ def on_draw(self):
# ...


class BlueView(arcade.gui.UIView):
class BlueView(UIView):
"""Uses the arcade.gui.UIView which takes care about the UIManager setup."""

def __init__(self):
Expand Down
42 changes: 36 additions & 6 deletions arcade/examples/gui/1_layouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from datetime import datetime

import arcade
from arcade.gui import UIAnchorLayout
from arcade.gui import UIAnchorLayout, UIImage, UITextArea

arcade.resources.load_system_fonts()

Expand Down Expand Up @@ -59,6 +59,36 @@
and layouts in general.
"""

TEX_SCROLL_DOWN = arcade.load_texture(":resources:gui_basic_assets/scroll/indicator_down.png")
TEX_SCROLL_UP = arcade.load_texture(":resources:gui_basic_assets/scroll/indicator_up.png")


class ScrollableTextArea(UITextArea, UIAnchorLayout):
"""This widget is a text area that can be scrolled, like a UITextLayout, but shows indicator,
that the text can be scrolled."""

def __init__(self, **kwargs):
super().__init__(**kwargs)

indicator_size = 22
self._down_indicator = UIImage(
texture=TEX_SCROLL_DOWN, size_hint=None, width=indicator_size, height=indicator_size
)
self._down_indicator.visible = False
self.add(self._down_indicator, anchor_x="right", anchor_y="bottom", align_x=-3)

self._up_indicator = UIImage(
texture=TEX_SCROLL_UP, size_hint=None, width=indicator_size, height=indicator_size
)
self._up_indicator.visible = False
self.add(self._up_indicator, anchor_x="right", anchor_y="top", align_x=-3)

def on_update(self, dt):
self._up_indicator.visible = self.layout.view_y < 0
self._down_indicator.visible = (
abs(self.layout.view_y) < self.layout.content_height - self.layout.height
)


class LayoutView(arcade.gui.UIView):
"""This view demonstrates the use of layouts."""
Expand All @@ -71,16 +101,16 @@ def __init__(self):
self.anchor = self.add_widget(UIAnchorLayout())

# Add describing text in center
text_area = arcade.gui.UITextArea(
text_area = ScrollableTextArea(
text=DESCRIPTION,
text_color=arcade.uicolor.WHITE_CLOUDS,
font_name=("Lato", "proxima-nova", "Helvetica Neue", "Arial", "sans-serif"),
font_size=12,
size_hint=(0.5, 0.8),
)
self.anchor.add(text_area, anchor_x="center_x", anchor_y="center_y")
text_area.with_border(color=arcade.uicolor.GRAY_CONCRETE)
text_area.with_background(color=arcade.uicolor.GRAY_CONCRETE.replace(a=125))
text_area.with_border(color=arcade.uicolor.DARK_BLUE_MIDNIGHT_BLUE)
text_area.with_background(color=arcade.uicolor.DARK_BLUE_MIDNIGHT_BLUE.replace(a=125))
text_area.with_padding(left=5)

# add a grid layout with the window and grid size and grid position
Expand All @@ -89,8 +119,8 @@ def __init__(self):
row_count=2,
align_horizontal="left",
)
self.grid.with_background(color=arcade.uicolor.GRAY_CONCRETE)
self.grid.with_border(color=arcade.uicolor.GRAY_ASBESTOS)
self.grid.with_background(color=arcade.uicolor.GRAY_ASBESTOS)
self.grid.with_border(color=arcade.uicolor.GRAY_CONCRETE)
self.grid.with_padding(all=10)
self.anchor.add(self.grid, anchor_x="left", anchor_y="top", align_x=10, align_y=-10)
self.grid.add(
Expand Down
Loading
Loading