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

Author Topic: SFGUI (0.4.0 released)  (Read 392550 times)

0 Members and 4 Guests are viewing this topic.

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: SFGUI (0.3.1 released)
« Reply #615 on: July 28, 2016, 03:15:39 pm »
This seems like a stupid question, so I held off from asking it, but I haven't made any progress. How would I make a Widget (i.e. a class that inherits from Widget and can be added to Containers, drawn by the rendering engine etc), out of other predefined Widgets? I can do it by making a class which contains a Box that contains the Widgets, and having a GetWidget() method, for adding it into Containers, however I'd much rather make a class which is an actual Widget. As a simple and arbitrary example, the sort of thing I'm trying to do is make a dropdown box out of a Label, a Button and a ScrolledWindow (that's not exactly what I'm making, but it's much easier to explain).

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: SFGUI (0.3.1 released)
« Reply #617 on: July 28, 2016, 07:54:16 pm »
I've seen that, my question was how to do it with predefined sfg::Widgets, rather than drawing primitives. I'm basically just talking about the InvalidateImpl() function, as I'm wanting to draw my custom widget's member Widgets, rather than creating all the shapes manually. What confused me more, is that IIRC, Box doesn't implement InvalidateImpl() and Frame only draws a rounded rectangle, so how do the children get drawn?

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: SFGUI (0.3.1 released)
« Reply #618 on: July 28, 2016, 08:02:36 pm »
Every widget takes care of all its own drawing. They can't and don't "inherit" the drawing of their superclasses. If they are invisible, InvalidateImpl() will be left empty. If you want to override an existing Widget's behaviour, override handling of all of the relevant events and drawing of the Widget.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: SFGUI (0.3.2 released)
« Reply #619 on: April 06, 2017, 03:27:41 pm »

theo

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: SFGUI (0.3.2 released)
« Reply #620 on: April 10, 2017, 01:02:15 pm »
Hello,

Is there a known problem with the SFGUI website? I asked a question on the forum, but now I can't reach it anymore. First it gave a 404 (not found), now the URL dumps me to the github site.

Thank you.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: SFGUI (0.3.2 released)
« Reply #621 on: April 10, 2017, 01:49:28 pm »
The forum and website is down for now, until Tank finishes moving them to the new server.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

theo

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: SFGUI (0.3.2 released)
« Reply #622 on: April 10, 2017, 04:45:00 pm »
OK thanks.

InversePalindrome

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Inverse Palindrome
Re: SFGUI (0.3.2 released)
« Reply #623 on: April 18, 2017, 05:34:59 pm »
Is there a way to set a background for a label, making them look similar to the background of a button?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: SFGUI (0.3.2 released)
« Reply #624 on: April 18, 2017, 05:40:04 pm »
Background as in color? Or do you mean the outline?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

InversePalindrome

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Inverse Palindrome
Re: SFGUI (0.3.2 released)
« Reply #625 on: April 18, 2017, 06:14:37 pm »
Background as in color? Or do you mean the outline?
The outline of the label, not the text itself.

theo

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: SFGUI (0.3.2 released)
« Reply #626 on: April 24, 2017, 11:48:06 pm »
I notice that the SFGUI website is still down, and since some developers read this thread, I take the liberty of asking my question here too.

The problem is as follows.

I have two spinbuttons, A and B.
Both can be changed individually by user interaction.
If I change the value of A by user interaction, the bound processing function also changes the value of B programmatically, through the SetValue function.
If I do this, button B gets two signals instead of the expected one.

Here is the code:

Quote

#include "stdafx.h"
#include <iostream>
#include "SFGUI/SFGUI.hpp"
#include "SFGUI/Widgets.hpp"
#include "SFML/Graphics.hpp"

using namespace std;

constexpr int SCREEN_WIDTH = 800;
constexpr int SCREEN_HEIGHT = 600;

class HelloWorld
{
public:
   HelloWorld () {}
   void value_changed (sfg::SpinButton::Ptr button);
   void Run ();
private:
   sfg::SFGUI sfgui;
   sfg::SpinButton::Ptr _button_a;
   sfg::SpinButton::Ptr _button_b;
};


void HelloWorld::value_changed (sfg::SpinButton::Ptr button)
{
   auto value = button->GetValue ();
   if (button == _button_a)
   {
      cout << "button A" << endl;
      _button_b->SetValue (value);
   }
   if (button == _button_b)
   {
      cout << "button B" << endl;
   }
}

void HelloWorld::Run ()
{
   sf::RenderWindow render_window (sf::VideoMode (SCREEN_WIDTH, SCREEN_HEIGHT), "Hello world");

   auto window = sfg::Window::Create ();
   window->SetTitle ("Test spinbuttons");

   auto table = sfg::Table::Create ();
   auto fill = sfg::Table::AttachOption::FILL;
   auto padding = sf::Vector2f (10.0f, 2.0f);

   auto label_a = sfg::Label::Create();
   label_a->SetText ("A");
   table->Attach (label_a, sf::Rect<sf::Uint32> (0, 0, 1, 1), fill, fill, padding);

   auto button_a = sfg::SpinButton::Create (1.0f, 10.0f, 1.0f);
   _button_a = button_a;
   button_a->SetValue (5.0f);
   button_a->GetSignal (sfg::SpinButton::OnValueChanged).Connect ([=](){value_changed (button_a); });
   button_a->SetRequisition (sf::Vector2f (60.0f, 0.0f));
   table->Attach (button_a, sf::Rect<sf::Uint32> (1, 0, 1, 1), fill, fill, padding);

   auto label_b = sfg::Label::Create ();
   label_b->SetText ("B");
   table->Attach (label_b, sf::Rect<sf::Uint32> (0, 1, 1, 1), fill, fill, padding);

   auto button_b = sfg::SpinButton::Create (1.0f, 10.0f, 1.0f);
   button_b->SetValue (5.0f);
   _button_b = button_b;
   button_b->SetRequisition (sf::Vector2f (60.0f, 0.0f));
   button_b->GetSignal (sfg::SpinButton::OnValueChanged).Connect ([=](){value_changed (button_b); });
   table->Attach (button_b, sf::Rect<sf::Uint32> (1, 1, 1, 1), fill, fill, padding);

   window->Add (table);
   sfg::Desktop desktop;
   desktop.Add (window);

   render_window.resetGLStates ();

   sf::Event event;
   sf::Clock clock;
   while (render_window.isOpen ())
   {
      while (render_window.pollEvent (event))
      {
         desktop.HandleEvent (event);
         if (event.type == sf::Event::Closed)
         {
            render_window.close ();
         }
      }
      desktop.Update (clock.restart ().asSeconds ());
      render_window.clear ();
      sfgui.Display (render_window);
      render_window.display ();
   }
}

int main ()
{
   HelloWorld hello_world;
   hello_world.Run ();
   return 0;
}


Now, if I click the up-button of spinbutton B, I get the expected output:

Quote
button B

But, if I click the up-button of spinbutton A, I get two signals on b:

Quote
button A
button B
button B

This is a problem, because I want to ignore signals originating from programmatical change of the value of B, while still handling the signals originating from user interaction with B.

It gets even stranger if I first click A, then B, en then A again. In this case the output is:

Quote
button A               // click button A
button B               // SetValue on B
button B               // mysterious second signal on B
button B               // click button B
button A               // click button A
button B               // SetValue on B, no second signal!

So, the number of signals received on B seems to depend on the exact sequence of clicks: if I click A after having clicked B, I get one signal on B. If I click A while the previous click was not on B, I get two signals on B.

Probably I am making some silly mistake, and probably I am making a fool of myself by asking, but I genuinely don't see it.

Tigre Pablito

  • Full Member
  • ***
  • Posts: 226
    • View Profile
    • Email
Re: SFGUI (0.3.2 released)
« Reply #627 on: May 17, 2017, 12:04:40 am »
Hi
Isn't any possibility of being able to use SFGUI with C#.Net?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: SFGUI (0.3.2 released)
« Reply #628 on: May 17, 2017, 01:56:48 am »
Nope, it's a C++ library and while zsbzsb has once started a .NET binding (IIRC), he never finished it.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

theo

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: SFGUI (0.3.2 released)
« Reply #629 on: July 19, 2017, 12:56:32 pm »
No answer for my previous question?

Let me give some background: I'm trying to implement a GURPS character generator. For those unfamiliar to GURPS: it's an RPG system, with a point-buy character generation process. You buy attributes, skills etc from a given budget of character points (CP). The default level of all attributes is 10.

A peculiar feature is that buying one attribute, can give you another attribute too. So if you buy one level of Strength (ST, cost 10 CP), you also get one level of Hitpoints (HP, cost 2 CP). And you can also buy HP separately.

So, if for example you buy one ST and one HP, it will cost 10 + 2 = 12 CP. The end result will be ST 11 and HP 12 (one HP for free from ST, and one from HP).

In my mind, the obvious way to implement that is as given in the code in my previous posting in this thread, with two spinbuttons (ST en HP), where interactively changing ST will programmatically change HP too. Problem is, that the behaviour when programmatically changing the value of the second spinbutton can give one or two signals, depending on the order of clicking. The behaviour seems to be deterministic, so it is possible to code around it. The code will have to remember the previous click too. But that will be kind of convoluted and before I go into that, I would like to know if this behaviour is intended (and if so, what is the logic behind it) or a bug.
« Last Edit: July 19, 2017, 12:59:33 pm by theo »