About Store Forum Documentation Contact



Post Reply 
Need better access to Gui struct members
Author Message
fatcoder Offline
Member

Post: #1
Need better access to Gui struct members
When overriding some of the gui control structs in order to modify their drawing behaviour, there is a major show stopper, which is that many of the members are declared as private so they cannot be accessed to read their values.

For example, GuiObj has a whole bunch of private members such as _bar_height, _alpha, _lit_bar, _lit_title and _flash, which are not accessible. This makes it almost impossible to override these controls and draw them correctly without reproducing a vast amount of the control's logic. A good example is _alpha, which I'm assuming controls the alpha level of the control during fade in/out. Since we can't access this, we can't fade our custom controls without a lot of work.

If the "private" above these members can be changed to "protected" it will allow us to make much better gui controls while reusing the existing functionality.

On a side note, if the create() method for gui controls could also be made virtual, then we can also override that to set our own custom members during creation.
(This post was last modified: 01-12-2012 05:21 AM by fatcoder.)
01-12-2012 04:58 AM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #2
RE: Need better access to Gui struct members
Also, it would be great if we could have more replaceClass() methods on the various controls like in the Tabs control for example, which uses a Button to represent each tab. There is a replaceClass() method that allows you to replace the Button class with your own derived class to override the Tab's buttons.

A good example where this is needed is with the Region control that has two SlideBars. There is no way to override the draw method of these SlideBars so that you can customize the way the SlideBars (and their subsequent Buttons) are drawn.

Perhaps these sort of internal controls could be pointers created at runtime, so that we can pass in a pointer to a derived class if needed (so we get our own custom draw() method called). For example, the Region control could have something like this.

Code:
SlideBar *slidebar[2];

Region& replaceSlideBars(SlideBar  *slidebar0, SlideBar  *slidebar1)
{
   if(slidebar0)
   {
      delete slidebar[0];
      slidebar[0] = slidebar0;
   }
   if(slidebar1)
   {
      delete slidebar[1];
      slidebar[1] = slidebar1;
   }
   return T;
}

I don't know the inner workings of the Gui system, so that is just some pseudo code to illustrate my idea. Doing something like this to the various controls that use internal controls would significantly increase the flexibility of the Gui system.
01-26-2012 12:40 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #3
RE: Need better access to Gui struct members
next SDK will have - new methods Window::barHighlight,titleHighlight,alpha to get the values
01-28-2012 03:56 PM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #4
RE: Need better access to Gui struct members
Thank you. Very much appreciated.

Any thoughts on a way to override internal controls as pointed out in the previous post? Like the scrollbars inside a region as an example.

I know you're pressed for time, but would love to at least know if anything will be done soonish or at all? I've spent days working on the GUI and am really hitting a road block with this. I've started researching some 3rd party GUI libraries and need to make a decision if I should change to one of those or stay with EE GUI. This is the only real show stopper I have with EE GUI. Cheers.
01-28-2012 04:28 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: Need better access to Gui struct members
currently region slidebars are stored as C++ array, so it can't use replaceClass, SlideBar slidebar[2];

I'd need to adjust the codes so it would use different approach

But I think you can override Region::draw, and draw children, and instead of drawing slidebars, do some custom drawing
01-30-2012 07:58 PM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #6
RE: Need better access to Gui struct members
Thanks for the reply.

I've thought of an even simpler approach. Since the slidebars (and all internal controls I've seen so far) are declared public, we don't need any kind of replace() methods. By just changing the slidebars to be pointers...

Code:
SlideBar *slidebar[2];

We can then access them directly and then do something like this.

Quote:window += region.create(...);
region.sliderbar[0] = new MyCustomSlideBar();
region.sliderbar[0].create(...);
region.sliderbar[1] = new MyCustomSlideBar();
region.sliderbar[1].create(...);

Then in the Region control's constructor, you would create the default slidebars for those who don't want to change them.

Quote:sliderbar[0] = new EE::SlideBar();
sliderbar[0].create(...);
sliderbar[1] = new EE::SlideBar();
sliderbar[1].create(...);

And in the Region control's destructor, you destroy the slidebars, which frees the user from having to destroy them.

Quote:del sliderbar[0];
del sliderbar[1];

I believe this simple change would solve many headaches with working with the gui system and make it a lot more flexible. This approach can be used in all gui controls that have internal controls (I have just been picking on the Region control as an example).

For example, the SlideBar control itself internally has 3 button controls which also need to be overridden in order to complete the look. Using the same approach you would just need to change the button array to be pointers as well.
01-30-2012 11:55 PM
Find all posts by this user Quote this message in a reply
Post Reply