Resizing two windows simultaneously in layout container

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

funbiscuit
Just popping in
Just popping in
Posts: 16
Joined: Mon Jun 06, 2016 10:41

Re: Resizing two windows simultaneously in layout container

Postby funbiscuit » Tue Jun 14, 2016 09:55

@yaronct

Well, I don't have currently time to make a test project so for now I can only send you all code you need.
Here it is:
test_hlayout.zip
(21.25 KiB) Downloaded 375 times


There are two .cpp and two .h files needed for layout container. Also I included test.cpp file with example code of how you can use it. You would need to init all cegui stuff, create window and all that stuff by yourself.
Also there are modified TaharezLook scheme and looknfeel files. I added custom HSplitter there so you can customize splitter look later. But be careful since for splitter I use Alfisco imageset so you need to load it to cegui also.
Hope you'll be able to make it run.

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Resizing two windows simultaneously in layout container

Postby YaronCT » Tue Jun 14, 2016 10:37

@funbiscuit: "HSplitter::setEWSizingCursorImage" should get a "const Image* image" rather than "const String& name".. Look at "FrameWindow::setEWSizingCursorImage".

funbiscuit
Just popping in
Just popping in
Posts: 16
Joined: Mon Jun 06, 2016 10:41

Re: Resizing two windows simultaneously in layout container

Postby funbiscuit » Tue Jun 14, 2016 10:46

@yaronct

That was quite stupid :D Thanks, I added overload with Image argument and now it works.

Now I'll modify container so it can be vertical too. Then test that I can embed one layout into another and then I might consider it finished.

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Resizing two windows simultaneously in layout container

Postby YaronCT » Tue Jun 14, 2016 13:55

funbiscuit wrote:@yaronct
Yes, I can upload code somewhere. It's just 6 files (and two of them are xml) but not sure that it will be in fork since I'm not very familiar with git.


We don't use Git but Mercurial, which is quite similar. Note that if u want to contribute your code to cegui you'll have to learn Mercurial and create a cegui Bitbucket fork sooner or later, coz we accept contributions through pull requests in Bitbucket.

funbiscuit
Just popping in
Just popping in
Posts: 16
Joined: Mon Jun 06, 2016 10:41

Re: Resizing two windows simultaneously in layout container

Postby funbiscuit » Tue Jun 14, 2016 14:21

@yaronct

I'll do it in future, that's for sure. Btw, what should I do to that fork? Only add my classes for layout container and splitter? I mean it won't work by default since you will need to register them manually with this lines:


Code: Select all

CEGUI::WindowFactoryManager::getSingleton().addFactory<CEGUI::TplWindowFactory<CEGUI::HSplitter> >();
CEGUI::WindowFactoryManager::getSingleton().addFactory<CEGUI::TplWindowFactory<CEGUI::HLayoutContainer> >();


So what should I change for it to register automatically and behave like native cegui window class?

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Resizing two windows simultaneously in layout container

Postby YaronCT » Tue Jun 14, 2016 14:49

@funbiscuit: U add it to "System::addStandardWindowFactories" in "cegui/src/System.cpp".

funbiscuit
Just popping in
Just popping in
Posts: 16
Joined: Mon Jun 06, 2016 10:41

Re: Resizing two windows simultaneously in layout container

Postby funbiscuit » Wed Jun 15, 2016 10:24

@yaronct

Thanks! I also looked at what bitbucket can do and was surprised that I can make changes to code in browser and commit them there. So when I'll finish fighting with bugs I'll make a pull request.

============

Well, it looks like I'm almost done. Now I have only one serious bug which is might even be of cegui because I encountered it before. Everything lags and stutter quite a lot when I resize window that contains child windows with scaled size. You can see it in the video.
Of course user would not need to resize everything constantly but that's quite a downside of current implementation.

Anyway, here is the video. I attached multiple horizontal layouts as children to one vertical layout. And then filled horizontal layouts with windows. As you can see, I can resize everything.



So it works quite good except of lagging when you need to autoscale child windows. I think someone even asked somewhere in forum why cegui lags and stutter when you resize window with content which size and position depend on its parent. And if I remember correctly no solution was found there.

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Resizing two windows simultaneously in layout container

Postby YaronCT » Wed Jun 15, 2016 18:15

funbiscuit wrote:Now I have only one serious bug which is might even be of cegui because I encountered it before. Everything lags and stutter quite a lot when I resize window that contains child windows with scaled size.


I wasn't aware of that. If u can open an Issue about it on Bitbucket that would b nice.

funbiscuit
Just popping in
Just popping in
Posts: 16
Joined: Mon Jun 06, 2016 10:41

Re: Resizing two windows simultaneously in layout container

Postby funbiscuit » Wed Jun 15, 2016 20:55

@yaronct

Uhm. I don't even know what to say.
I tried to reproduce bug under "clean" conditions. That's what I used (just two buttons with absolute position and size added to window):

Code: Select all

   CEGUI::PushButton* btn0 = static_cast<CEGUI::PushButton*>(CEGUI::WindowManager::getSingletonPtr()->createWindow("TaharezLook/Button"));
   btn0->setSize(CEGUI::USize(cegui_absdim(120), cegui_absdim(50)));
   btn0->setPosition(CEGUI::UVector2(cegui_absdim(500.0), cegui_absdim(100.0)));
   CEGUI::PushButton* btn1 = static_cast<CEGUI::PushButton*>(CEGUI::WindowManager::getSingletonPtr()->createWindow("TaharezLook/Button"));
   btn1->setSize(CEGUI::USize(cegui_absdim(120), cegui_absdim(50)));
   btn1->setPosition(CEGUI::UVector2(cegui_absdim(200.0), cegui_absdim(100.0)));

//wnd is TaharezLook FrameWindow added to root
   wnd->addChild(btn0);
   wnd->addChild(btn1);


And tried to resize it a lot when application window is maximized. And it stuttered. It stuttered a lot. FPS droped down to 25, 17 fps per second. While in normal condition I get 120 (I limit them). And you should understand that 25 fps is mean (over a second I guess). But stuttering is very noticeable.
So I tried to record it so you can see. And... No stuttering while I was recording. And when I stopped it didn't stutter again. And when I reopened application - it stuttered again while resizing. And it kept stuttering. Until I tried to record again just one second. After that again - no stuttering. FPS drops to about 40-60 but nothing noticeable.
I don't even know how that is possible.

I looked in Task Manager. Under normal condition there is about 15% load of one thread. When I start resizing it rises to about 95-99%. That's why it starts stutter. And if I record any time (even just one second) after that CPU load never rises higher than 65-80%. So that's why no stuttering after I record screen.
But again, I have no idea how that can be possible.

P.S. I tried both GLRenderer and GL3Renderer.
P.P.S. I also tried to run profiler that Visual Studio has but it said nothing new. Just that almost 100% of CPU was spent in ProcessEvents by ExternalCode (12 modules). That's where I inject mouse input to CEGUI.

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Resizing two windows simultaneously in layout container

Postby YaronCT » Thu Jun 16, 2016 16:39

@funbiscuit: That's indeed very weird; yet, it's Windows, so I guess everything is possible..

It's like e.g. when u have a problem with your air conditioner and u call a technician and of course when u try to show him the problem the air conditioner works perfectly and the moment he leaves it again doesn't work.. :lol:

Still, it's preferrable to have an issue about it on Bitbucket, even if the information u have is incomplete. The most important thing is that we don't forget about the issue. Info can always be added later to the issue.

funbiscuit
Just popping in
Just popping in
Posts: 16
Joined: Mon Jun 06, 2016 10:41

Re: Resizing two windows simultaneously in layout container

Postby funbiscuit » Fri Jun 17, 2016 17:18

@yaronct
Okay, I'll create issue at bitbucket.

Currently I'm "merging" code into normal CEGUI distribution and I have one very strange problem. I'm able to create my new widgets but if I try to call any new functions I get "unresolved external" error. This is strange because if I don't call any new functions - everything works (since I inherit from SequentialLayoutContainer I call only its functions to add children). Application builds and runs and layout works properly.

That's what I've done to merge my code to cegui:

added to include/CEGUI/widgets

Code: Select all

Splitter.h
ResizableLayoutContainer.h


added to src/widgets

Code: Select all

Splitter.cpp
ResizableLayoutContainer.cpp


added to include/CEGUI/widgets/All.h:

Code: Select all

#include "./Splitter.h"
#include "./ResizableLayoutContainer.h"


added to "System::addStandardWindowFactories" in "cegui/src/System.cpp":

Code: Select all

WindowFactoryManager::addWindowType<Splitter>();
WindowFactoryManager::addWindowType<ResizableLayoutContainer>();


#include "CEGUI/widgets/ResizableLayoutContainer.h"
#include "CEGUI/widgets/Splitter.h"

Then I ran CMake again and built the solution in both debug and release modes. No errors.

So did I miss something?

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Resizing two windows simultaneously in layout container

Postby YaronCT » Fri Jun 17, 2016 18:30

funbiscuit wrote:@yaronct
Okay, I'll create issue at bitbucket.


Thanx!

funbiscuit wrote:Currently I'm "merging" code into normal CEGUI distribution and I have one very strange problem. I'm able to create my new widgets but if I try to call any new functions I get "unresolved external" error. This is strange because if I don't call any new functions - everything works (since I inherit from SequentialLayoutContainer I call only its functions to add children). Application builds and runs and layout works properly.


My guess is u didn't write "CEGUIEXPORT" b4 the class name in the class declaration. Look at how other widget classes are defined.

funbiscuit wrote:So did I miss something?

Add your name and a short description of your project in "doc/doxygen/authors.doc" under "Main Contributors". :D

As for the rest - we'll c when u open a PR (Pull Request) and we'll comment u there.

funbiscuit
Just popping in
Just popping in
Posts: 16
Joined: Mon Jun 06, 2016 10:41

Re: Resizing two windows simultaneously in layout container

Postby funbiscuit » Fri Jun 17, 2016 18:44

@yaronct

Thanks! That macro solved everything :)
Now I'll create new fork from master branch, upload everything and make a pull request. But at first I'll test that my fork builds correctly so I didn't miss anything.

funbiscuit
Just popping in
Just popping in
Posts: 16
Joined: Mon Jun 06, 2016 10:41

Re: Resizing two windows simultaneously in layout container

Postby funbiscuit » Fri Jun 17, 2016 19:47

I've made a pull request:
https://bitbucket.org/cegui/cegui/pull-requests/215/resizable-layout-container/diff

But there is no demo to test so here is the code of example:

Code: Select all



CEGUI::FrameWindow* window = 0;
CEGUI::FrameWindow* window0 = 0;
CEGUI::FrameWindow* window4 = 0;

CEGUI::ResizableLayoutContainer* rlc0 = 0;
CEGUI::ResizableLayoutContainer* rlc2 = 0;


//create custom vertical layout container
CEGUI::ResizableLayoutContainer* grlc = static_cast<CEGUI::ResizableLayoutContainer*>(CEGUI::WindowManager::getSingletonPtr()->createWindow("CEGUI/ResizableLayoutContainer","GlobLayout"));
//expand it so it fills whole parent
grlc->setSize(CEGUI::USize(cegui_reldim(1), cegui_reldim(1)));
//wnd is, for example, any already created frame window that was attached to root (or anything else)
wnd->addChild(grlc);
grlc->setIsHorizontal(false); //this layout will be vertical (horizontal by default)


for (int i = 0; i < 3; ++i)//vertical
{
   std::stringstream stringStream0;
   stringStream0 << "Layout " << i;
   CEGUI::ResizableLayoutContainer* rlc = static_cast<CEGUI::ResizableLayoutContainer*>(CEGUI::WindowManager::getSingletonPtr()->createWindow("CEGUI/ResizableLayoutContainer", stringStream0.str()));

   rlc->setSize(CEGUI::USize(cegui_reldim(1), cegui_reldim(1)));
   //add new horizontal layout as child to vertical layout
   grlc->addChild(rlc);

   if (i == 0)
      rlc0 = rlc;
   if (i == 2)
      rlc2 = rlc;

   for (int j = 0; j < 4; ++j)//horizontal
   {

      std::stringstream stringStream;
      stringStream << "Window (" << i << "," << j << ")";

      window = static_cast<CEGUI::FrameWindow*>(CEGUI::WindowManager::getSingletonPtr()->createWindow("TaharezLook/FrameWindow", stringStream.str()));

      if (i == 0 && j == 0)
         window0 = window;

      if (i == 0 && j == 2)
         window4 = window;

      window->setSize(CEGUI::USize(CEGUI::UDim(1.0f, 0.0f), CEGUI::UDim(1.0f, 0.0f)));
      window->setMinSize(CEGUI::USize(CEGUI::UDim(0.0f, (j + 1)*30.0f), CEGUI::UDim(0.0f, (j + 1)*20.0f)));
      window->setText(stringStream.str());
      
      //we don't want user to resize or move windows directly
      //since layout will do it
      window->setSizingEnabled(false);
      window->setDragMovingEnabled(false);
      
      window->setCloseButtonEnabled(false);

      rlc->addChild(window);
   }
}

//uncomment following lines to test some features

rlc0->removeChild(window0);
rlc2->addChildToPosition(window0, 2);
//rlc0->moveChildToPosition(window4, 0);
//rlc0->moveChildToPosition(window0, 4);
//rlc0->swapChildPositions(1, 3);
//rlc0->removeChild(window0);



It will create something like this:
test.png

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Resizing two windows simultaneously in layout container

Postby YaronCT » Fri Jun 17, 2016 19:54

@funbiscuit:

Thanx! Feel free to add a sample to the sample framework with your test code. Actually, it would b great if u did! Don't feel like u have to, though.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 7 guests