Jump to content

[SOLVED] Interface plugin trouble


photo

Recommended Posts

Posted

Hi,

 

I am playing with Unigine Interface plugin and I have a weird behavior with InterfaceWindow. I am using the same script file use for Unigine Editor.

I want make my own minimize / maximize button on the window. For do that i just have a WidgetVBox and when the callback is call i just switch the visibility of the vbox  container.setHidden(hidden).

Unfortunately sometime when i maximize the window i have a resize of the window but not the vbox. I put the photo.

 

Thanks

maximize.png

 

 

minimize.png

 

maximize2.png

Posted

Hi, Anthony

 

Could you please provide a test scene?

Posted

I will try to do something, but sometime is not so easy to extract one piece of code inside the script. I can give you the part of code i change.

Inside Interface.h (just change the callback for quit by a callbck for minimize:

#define DECLARE_WINDOW \
  int window_show; \
  int window_minimize; \
  WidgetWindow window; \
  WidgetIcon window_button; \
  InterfaceWindow interface; \
  DECLARE_CALLBACKS(window)
	
#define DECLARE_WINDOW_INIT(NAME) \
  window_minimize = 0;\
  interface = new InterfaceWindow(0); \
  interface.setWidth(width); \
  interface.setHeight(height); \
  interface.setPosition(position_x,position_y); \
        \
  window_button = new WidgetIcon(gui,"core/gui/dialog_minimize.png"); \
  window.setCallback(GUI_PRESSED,#NAME "::window_pressed",interface,window); \
  window.addChild(window_button,GUI_ALIGN_OVERLAP | GUI_ALIGN_TOP | GUI_ALIGN_RIGHT); \
  window_button.setCallback(GUI_CLICKED, #NAME"::switchSize"); \
  window_button.setPosition(4,-24); \
  window.setMoveable(0);

And the callback :

 


    void switchSize() {
        if (window_minimize == 0) {
            lastHeight = window.getHeight();
            
            container.setHidden(1); // Container is a vbox inside the window
            window_minimize = 1;
            window_button.setTexture("core/gui/dialog_maximize.png");
            
            window.setHeight(MINIMUM_SIZE);
        } else {           
            container.setHidden(0);
            window_minimize = 0;
            window_button.setTexture("core/gui/dialog_minimize.png");
  
            window.setHeight(lastHeight);
        }
    }

Anyway, other behavior i found, when i mimimize the window like on the screenshot 2, on OSX the windows title bar, move to the bottom of the widget. On windows the minimize doesn't change the position.

 

Thanks

 

Posted

Hi, i found solution for solve my trouble but i will try to make you a little sample for you can test.

 

1) for the minimize / maximize trouble i just use the macro DECLARE_WINDOW_SHOW apparently solve the problem

 

2) when i need to change the position of the interfacewindow i use :

 

 

ifdef _MACOS

        window.arrange();

        interface.setPosition(position_x,position_y+window.getHeight());

#endif

×
×
  • Create New...