Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Texture Button cuts itself on resizing window #2349

Closed
Piedpiper5 opened this issue Aug 20, 2024 · 3 comments
Closed

Texture Button cuts itself on resizing window #2349

Piedpiper5 opened this issue Aug 20, 2024 · 3 comments
Assignees
Labels
gui Related to arcade GUI (sub module arcade.gui)

Comments

@Piedpiper5
Copy link

So basically what is happening is that if the initial screen size is small (i don’t know how small) and u try to maximise it via the button on top right of the window the button cuts 3/4 off it self but if u manually maximise the window with ur cursor as much as u can and then click the top right button of the window it works fine (button doesn’t cut off).

Arcade 3.0.0.dev33

vendor: Intel
renderer: Intel(R) HD Graphics 5500
version: (3, 3)
python: 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]
platform: win32
pyglet version: 2.1.dev5
PIL version: 10.2.0

Actual behavior:

Button cuts off

Expected behavior:

Button doesn’t cut off

Steps to reproduce/example code:

Just run below code and click the maximise button of the opened window:

import arcade
import arcade.gui
print(arcade.get_display_size()[0], arcade.get_display_size()[1])

class StartingScreen(arcade.View):
def init(self):
super().init()

    self.ui_manager = arcade.gui.UIManager()
    self.ui_manager.enable()

    self.play_button_texture = arcade.load_texture(":resources:onscreen_controls/shaded_light/start.png")

    self.play_button = arcade.gui.UITextureButton(
        x=self.window.width / 4,
        y=self.window.height / 2.5,
        width=self.window.width / 2,
        height=self.window.height / 5,
        texture=self.play_button_texture
    )

    self.ui_manager.add(self.play_button)

def on_draw(self):
    self.clear()
    self.ui_manager.draw()

def on_resize(self, width, height):
    starting_screen = StartingScreen()
    self.window.show_view(starting_screen)

if name == 'main':
window = arcade.Window(
resizable=True,
width = 683,
height = 384
)
window.show_view(StartingScreen())
window.run()

Enhancement request:

I don’t know

What should be added/changed?

I don’t know

(rest of the questions are not applicable/irrelevant)

@eruvanos eruvanos self-assigned this Aug 21, 2024
@eruvanos eruvanos added the gui Related to arcade GUI (sub module arcade.gui) label Aug 21, 2024
@eruvanos eruvanos removed their assignment Aug 21, 2024
@eruvanos
Copy link
Member

I fixed the example code to be runnable:

import arcade
import arcade.gui

print(arcade.get_display_size()[0], arcade.get_display_size()[1])


class StartingScreen(arcade.View):
    def __init__(self):
        super().__init__()

        self.ui_manager = arcade.gui.UIManager()
        self.ui_manager.enable()

        self.play_button_texture = arcade.load_texture(
            ":resources:onscreen_controls/shaded_light/start.png"
        )

        self.play_button = arcade.gui.UITextureButton(
            x=self.window.width / 4,
            y=self.window.height / 2.5,
            width=self.window.width / 2,
            height=self.window.height / 5,
            texture=self.play_button_texture,
        )

        self.ui_manager.add(self.play_button)

    def on_draw(self):
        self.clear()
        self.ui_manager.draw()

    def on_resize(self, width, height):
        starting_screen = StartingScreen()
        self.window.show_view(starting_screen)


if __name__ == "__main__":
    window = arcade.Window(resizable=True, width=683, height=384)
    window.show_view(StartingScreen())
    window.run()

@eruvanos
Copy link
Member

eruvanos commented Aug 21, 2024

I will check, if I can somehow reproduce this.

@Piedpiper5 Can you check with this version:

import arcade
import arcade.gui

print(arcade.get_display_size()[0], arcade.get_display_size()[1])

PLAY_BUTTON_TEXTURE = arcade.load_texture(":resources:onscreen_controls/shaded_light/start.png")


class StartingScreen(arcade.View):
    def __init__(self):
        super().__init__()

        self.ui_manager = arcade.gui.UIManager()

        # self.play_button = arcade.gui.UITextureButton(
        #     x=self.window.width / 4,
        #     y=self.window.height / 2.5,
        #     width=self.window.width / 2,
        #     height=self.window.height / 5,
        #     texture=self.play_button_texture,
        # )
        # self.ui_manager.add(self.play_button)

        # using size_hint, and anchor layout
        self.play_button = arcade.gui.UITextureButton(
            texture=PLAY_BUTTON_TEXTURE,
            size_hint=(0.5, 0.2),
        )
        root = self.ui_manager.add(arcade.gui.UIAnchorLayout())
        root.add(self.play_button, anchor_x="center", anchor_y="center")

    def on_show_view(self) -> None:
        self.ui_manager.enable()

    def on_hide_view(self) -> None:
        self.ui_manager.disable()

    def on_draw(self):
        self.clear()
        self.ui_manager.draw()


if __name__ == "__main__":
    window = arcade.Window(resizable=True, width=683, height=384)
    window.show_view(StartingScreen())
    window.run()

@eruvanos eruvanos self-assigned this Aug 21, 2024
@eruvanos
Copy link
Member

Looks like it was an issue with texture loading, no further support required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gui Related to arcade GUI (sub module arcade.gui)
Projects
None yet
Development

No branches or pull requests

2 participants