Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML GUI buttons design  (Read 13352 times)

0 Members and 1 Guest are viewing this topic.

KagonKhan

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
SFML GUI buttons design
« on: August 01, 2021, 05:01:46 am »
To preface - yes I am aware of libraries for GUI using SFML.

I'm writing a game, and currently working on options menu. What I want to achieve is to have a button for resolution. Upon clicking it, a scrollable list is shown to choose resolutions from.

What I currently have, is the button class, and a list of buttons, scrollable by wheel. I also can manage showing, clicking / selecting, and hiding on my own. What I truly need is a way to "smartly" hide buttons that are outside of some defined area. An easy way would be to have a boolean that would render based on button position, but I am hoping that partial hiding would be possible - meaning that for example only top half of the button is visible IF it's at the border range.

Hoping for any suggestions

:^)

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: SFML GUI buttons design
« Reply #1 on: August 01, 2021, 08:56:09 am »
You can draw them on an sf::RenderTexture that is the size of the viewable area you want, and display this texture with a sprite.

KagonKhan

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: SFML GUI buttons design
« Reply #2 on: August 01, 2021, 08:58:01 am »
You can draw them on an sf::RenderTexture that is the size of the viewable area you want, and display this texture with a sprite.


O, that sounds interesting. I'll play around with that in the upcoming days - thanks!

KagonKhan

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: SFML GUI buttons design
« Reply #3 on: August 02, 2021, 08:11:18 am »
Okay, got it to work just like I needed. Thank you very much :^)