Jump to content
  • entries
    4
  • comments
    0
  • views
    4,629

Widget Fields


GorzenDev

1,637 views

 Share

Finished and added Field functionality meaning its now possible to set the Fields for each widget.
for example the style for a button (Push,Link,Checkbox), or backgroundcolor for panels etc.

below is a screenshot of the fields in action
guieditor_prev4.thumb.JPG.b6841efab04c2ef17284105bf42ed76a.JPG

 

Next will be finishing support for custom widgets which i already started on as you can see in the screenshot above(colorlabel).

At the moment the way to add your custom widgets is a 3 step process.


First step is adding the widget name to the config.ini like

[DefineTypes]
CustomTypeCount=2
name_0=ColorLabel
name_1=MultiListView


Next is adding a type_file with content like so

[Base]
name=ColorLabel
;allow other widgets to use this as a parent
allowparent=false
;allow addItem
islistType=false
;location of the widget script in your leadwerks project - only used while exporting
wScript=Scripts/GUI/ColorLabel.lua
;location of the widget script for this editor
eScript=ElementTypes/Custom/Editor/editorColorLabel.lua
;default size
defWidth=80
defHeight=20
;amount of 'extras' defined
dCount=6
[Define_0]
name=align
type=String
[Define_1]
name=valign
type=String
[Define_2]
name=wordwrap
type=Bool
[Define_3]
name=border
type=Bool
[Define_4]
name=bordercolor
type=Vec4
[Define_5]
name=textcolor
type=Vec4


And last but not least you need to edit a copy of your script and disable any EventQueue::Emit events,
and add some mouseMove,mousDown,mouseUp events for the editor to interact with the widget.

 

So a custom widget colorlabel would look like this when exported.

//GUI Editor Generated
#include "MenuClass.h"
    
MenuClass::MenuClass(Context* context)
{
    gui = GUI::Create(context);
    
    //Panel
    Panel = Widget::Create("", 0, 0, 1024, 100, gui->GetBase(), "Scripts/GUI/Panel.lua");
    Panel->SetAlignment(false, false, false, false);
    //Button
    Button = Widget::Create("Template", 81, 38, 150, 20, Panel, "Scripts/GUI/Button.lua");
    Button->SetAlignment(false, false, false, false);
    //Button1
    Button1 = Widget::Create("Template", 338, 38, 150, 20, Panel, "Scripts/GUI/Button.lua");
    Button1->SetAlignment(false, false, false, false);
    //ColorLabel
    ColorLabel = Widget::Create("colorlabel", 710, 39, 80, 20, Panel, "Scripts/GUI/ColorLabel.lua");
    ColorLabel->SetAlignment(false, false, false, false);
    ColorLabel->SetString("align","Center");
    ColorLabel->SetString("valign","Center");
    ColorLabel->SetBool("border",true);
    ColorLabel->SetObject("bordercolor", new Vec3(1,0,0,0));
    ColorLabel->SetObject("textcolor", new Vec3(0,0,1,1));
    //Panel1
    Panel1 = Widget::Create("", 342, 328, 300, 200, gui->GetBase(), "Scripts/GUI/Panel.lua");
    Panel1->SetAlignment(false, false, false, false);
    Panel1->SetObject("backgroundcolor", new Vec3(0.2,0.2,0.2,1));
    //Button2
    Button2 = Widget::Create("exit", 80, 156, 150, 20, Panel1, "Scripts/GUI/Button.lua");
    Button2->SetAlignment(false, false, false, false);
    //Button3
    Button3 = Widget::Create("options", 77, 98, 150, 20, Panel1, "Scripts/GUI/Button.lua");
    Button3->SetAlignment(false, false, false, false);
    //Button4
    Button4 = Widget::Create("load", 76, 33, 150, 20, Panel1, "Scripts/GUI/Button.lua");
    Button4->SetAlignment(false, false, false, false);
}
MenuClass::~MenuClass()
{
    Button4->Release();
    Button3->Release();
    Button2->Release();
    Panel1->Release();
    ColorLabel->Release();
    Button1->Release();
    Button->Release();
    Panel->Release();
    gui->Release();
}
//
bool MenuClass::ProcessEvent(Event event)
{
    if (event.id == Event::WidgetAction)
    {
        //
    }
    return true;
}
//
bool MenuClass::Update()
{
    return true;
}


 

 Share

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...