Jump to content

[SOLVED] Can't set a color of WidgetVBox object


photo

Recommended Posts

Hi, everyone! I can not set a color of my WidgetVBox object so that when I do it, rung object doesn't get the color.

 

class Rung : Unigine::Widgets::Canvas

 

...

 

 

class Workspace : Unigine::Widgets::Widget
{
Rung rung;
 
Unigine::Widgets::VBox box;
 
Workspace()
{
box = new Unigine::Widgets::VBox();
widget = box.widget;
 
// Добавляем rung в workspace
rung = new Rung();
widget.addChild(rung.widget, GUI_ALIGN_TOP | GUI_ALIGN_LEFT);
 
this.setHeight(600);
this.setWidth(800);
box.setBackground(1);
box.setColor(vec4(0, 0.98, 0.98, 1));
}
 
~Workspace()
{
}
};
Link to comment
  • 3 weeks later...

everything works, checked it on this code sample.


#include <core/unigine.h>

#include <core/systems/widgets/widget.h>

#include <core/systems/widgets/widget_canvas.h>

#include <core/systems/widgets/widget_vbox.h>

 

Gui gui;

 

class Rung : Unigine::Widgets::Canvas {

 

Rung() {

int width = gui.getWidth();

int height = gui.getHeight();

int line = addLine();

addLinePoint(line,vec3(0,0,0));

addLinePoint(line,vec3(width,height,0));

 

line = addLine();

addLinePoint(line,vec3(width,0,0));

addLinePoint(line,vec3(0,height,0));

}

};

 

class Workspace : Unigine::Widgets::Widget {

 

Rung rung;

 

Unigine::Widgets::VBox box;

 

Workspace() {

box = new Unigine::Widgets::VBox();

widget = box.widget;

 

rung = new Rung();

widget.addChild(rung.widget,GUI_ALIGN_TOP | GUI_ALIGN_LEFT);

 

this.setHeight(600);

this.setWidth(800);

box.setBackground(1);

box.setColor(vec4(0.0f,0.98f,0.98f,1.0f));

 

gui.addChild(box.widget,GUI_ALIGN_TOP | GUI_ALIGN_LEFT);

}

 

~Workspace() {

 

}

};

 

 

int init() {

Player player = new PlayerSpectator();

player.setDirection(Vec3(0.755f,-1.0f,0.25f));

engine.game.setPlayer(player);

engine.game.setEnabled(1);

 

gui = engine.getGui();

Workspace w = new Workspace();

return 1;

}

  • Like 1
Link to comment
×
×
  • Create New...