Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - ANDO1

#1
Downloaded the latest TGUI commit (including SFML 2.1 master) and used CMake to create both debug and release lib/dlls (dynamic versions only).  The latest fix seems to have fixed the problem with clipping of labels (widgets) in panels when using SFML::viewport.  Thanks again for all your help  :)
#2
 :) Thanks again for your diligent attention to problems.  I'm not sure how to test the commit that you made on GitHub.  I assume I would need to download those source/include files and recompile to libraries/dlls.  I haven't done this before as I have only been using released libs/dlls.  If you'd like me to test your latest changes, please let me know and I'll look into how to compile them.  Otherwise, I'm happy to wait until your updated release. :)
#3
It appears that the problem with clipping of widgets when using Viewports may still exist for widgets inside Panels if the the Panel is positioned anywhere other than the origin?  Please see minimum code.

#include <SFML/Graphics.hpp>
#include <TGUI/TGUI.hpp>
#include <windows.h>

int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, INT)
{
// Create Render Window
sf::RenderWindow window(sf::VideoMode(1280,1024), "Test", sf::Style::Fullscreen);

// Set view
sf::View SView;
SView.reset(sf::FloatRect(0, 0, 1280, 1024));   
SView.setViewport(sf::FloatRect(0.25f, 0.25f, 0.5f, 0.5f));
window.setView(SView);   

// Create GUI
tgui::Gui gui(window);

if (gui.setGlobalFont("Fonts/DejaVuSans.ttf") == false)
return(0);

// Create an empyt/transparent panel to hold a Label
tgui::Panel::Ptr dpanel(gui);
        dpanel->setSize(800.0f, 600.0f);
dpanel->setTransparency(0);
dpanel->setBackgroundColor(sf::Color(255,255,255,0));

// Setting Position of Panel at origin works fine
//     dpanel->setPosition(0, 0);
// Setting Position of Panel to location other than origin causes clipping of Label within Panel
        dpanel->setPosition(200, 200);

       // Create Label within panel
tgui::Label::Ptr label(*dpanel);
label->setText("Test Label");
label->setPosition(100,100);

while (window.isOpen())
{
sf::Event event;

        while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
                window.close();
            }
else if (event.type == sf::Event::KeyPressed)
{
switch (event.key.code)
{
case sf::Keyboard::Escape:
window.close();
break;
}
}

gui.handleEvent(event,false);
}


tgui::Callback callback;
while (gui.pollCallback(callback))
{
// Do event handler for gui here
}

window.clear();
gui.draw(false);
window.display();
}
return(0);
}
#4
I had the same problem with Labels and other widgets (e.g., Combobox) and was just about to post.  Just downloaded and tested the new code.  Works a treat.  Thanks again for your quick work.  :)
#5
Help requests / Re: Set View problem
06 April 2014, 01:44:33
Thanks Texus for the quick reply and for making such a useful GUI tool ;D



#6
Help requests / Set View problem
05 April 2014, 08:03:43
Hi
I'm having a problem with TGUI not adjusting mouse coordinates (responding to button events) when the view is set to any size other than the window size.
I'm trying to display a 1280x1024 picture with a button on the screen using different View sizes.  Using sf::setView I can get the picture to scale with the view provided I use gui->draw(false) (i.e., no resize), but mouse coords are not converted (i.e., pressing the button does not trigger any events, but when I move the mouse pointer to actual screen corrds corresponding to non-resized button coords, I can press the button).

Below is the minimum code. How do i tell tgui to use resized (View) coords?  What am I doing wrong?
Note, I have tried setting SView2 when drawing and then SView1 for event handling but that did not work.  I don't want to manually resize and reposition all the GUI objects to suit different window sizes. 


#include <SFML/Graphics.hpp>
#include <TGUI/TGUI.hpp>
#include <windows.h>

int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, INT)
{
   // Initialise SFML Render Window

   // Create Render Window
   sf::RenderWindow window(sf::VideoMode(1280,1024), "Test", sf::Style::Fullscreen);

   sf::View      SView1;
   sf::View      SView2;   

   // Set view
   SView1.reset(sf::FloatRect(0, 0, 1280, 1024));   
   SView2.reset(sf::FloatRect(0, 0, 2000, 2000));
   
   window.setView(SView1);    // SView1 works fine
//   window.setView(SView2);  // SView2 resizes okay, but gui button doesn't work

   // Create GUI
   tgui::Gui gui(window);

   if (gui.setGlobalFont("../../Fonts/DejaVuSans.ttf") == false)
      return(false);

   // Load a 1280x1024 size form with a button
   if (!gui.loadWidgetsFromFile("form.txt"))
      return(false);

   while (window.isOpen())
   {
        sf::Event event;

        while (window.pollEvent(event))
      {
            if (event.type == sf::Event::Closed)
         {
                window.close();
            }
         else if (event.type == sf::Event::KeyPressed)
         {
            switch (event.key.code)
            {
               case sf::Keyboard::Escape:
                  window.close();
                  break;
            }
         }

         gui.handleEvent(event);
      }


   tgui::Callback callback;
   while (gui.pollCallback(callback))
   {
         // Do event handler for gui here
   }

   window.clear();
   gui.draw(false);
   window.display();

   }
   return(0);
}