diff options
| author | Alexander <alex@cogarr.net> | 2020-06-29 15:29:03 -0400 |
|---|---|---|
| committer | Alexander <alex@cogarr.net> | 2020-06-29 15:29:03 -0400 |
| commit | 80789508b9655d25629223b9dcc84b4cfb77ce45 (patch) | |
| tree | 37e140e532af61c1ca4699c8b6254cf2cb07ed02 /src/client/lua_api/gui | |
| parent | 44a1421c393632978d59c0698a93ae22243b97e9 (diff) | |
| download | brokengine-80789508b9655d25629223b9dcc84b4cfb77ce45.tar.gz brokengine-80789508b9655d25629223b9dcc84b4cfb77ce45.tar.bz2 brokengine-80789508b9655d25629223b9dcc84b4cfb77ce45.zip | |
Updates for mdoc
Also more tests
Diffstat (limited to 'src/client/lua_api/gui')
| -rw-r--r-- | src/client/lua_api/gui/iguibutton.cpp | 15 | ||||
| -rw-r--r-- | src/client/lua_api/gui/iguicheckbox.cpp | 17 | ||||
| -rw-r--r-- | src/client/lua_api/gui/iguicolorselector.cpp | 16 | ||||
| -rw-r--r-- | src/client/lua_api/gui/iguicombobox.cpp | 37 | ||||
| -rw-r--r-- | src/client/lua_api/gui/iguieditbox.cpp | 18 | ||||
| -rw-r--r-- | src/client/lua_api/gui/iguielement.cpp | 20 | ||||
| -rw-r--r-- | src/client/lua_api/gui/iguifiledialog.cpp | 13 | ||||
| -rw-r--r-- | src/client/lua_api/gui/iguiimage.cpp | 19 | ||||
| -rw-r--r-- | src/client/lua_api/gui/iguilabel.cpp | 7 | ||||
| -rw-r--r-- | src/client/lua_api/gui/iguispinbox.cpp | 11 | ||||
| -rw-r--r-- | src/client/lua_api/gui/iguitreeview.cpp | 14 | ||||
| -rw-r--r-- | src/client/lua_api/gui/iguiwindow.cpp | 12 |
12 files changed, 112 insertions, 87 deletions
diff --git a/src/client/lua_api/gui/iguibutton.cpp b/src/client/lua_api/gui/iguibutton.cpp index 3d4580b..cdbea77 100644 --- a/src/client/lua_api/gui/iguibutton.cpp +++ b/src/client/lua_api/gui/iguibutton.cpp @@ -17,9 +17,6 @@ extern "C" { #include <shared/util/hashmap.hpp> #include <shared/lua_api/common.hpp> -/*** -@module gui -*/ using namespace irr; using namespace core; using namespace gui; @@ -30,16 +27,16 @@ char lhashkey[20]; /*** Creates a new button. Buttons may have the following fields set for callbacks: + .onClick(self) - .onFocus(self) - .onUnfocus(self) - .onHover(self) - .onLeave(self) -@function newbutton() + +It may additionally call any @{iguielement} callbacks + +@function gui.newbutton() @tparam rect dimensions The rectangle to place the button at. If the box has a parent, it is offset from the upper-left of the parent element. @tparam string default_text The default text to have in the button -@tparam ?iguielement parent The parent element of the button. +@tparam? iguielement parent The parent element of the button. @treturn iguibutton The button element */ //gui.newbutton({{sx,sy},{ex,ey}},"text"[,parent]) diff --git a/src/client/lua_api/gui/iguicheckbox.cpp b/src/client/lua_api/gui/iguicheckbox.cpp index 6413883..365b75d 100644 --- a/src/client/lua_api/gui/iguicheckbox.cpp +++ b/src/client/lua_api/gui/iguicheckbox.cpp @@ -8,9 +8,6 @@ extern "C" { #include "iguielement.hpp" #include <shared/lua_api/common.hpp> -/*** -@module gui -*/ using namespace irr; using namespace gui; using namespace core; @@ -26,11 +23,11 @@ following fields, which they will call for callbacks: It may additionally call any @{iguielement} callbacks -@function newcheckbox() +@function gui.newcheckbox() @tparam rect dimensions The rectangle to place the box at. If the box has a parent, it is offset from the upper-left of the parent element. @tparam string default_text The default text to have in the edit box -@tparam ?iguielement parent The parent element of the edit box +@tparam? iguielement parent The parent element of the edit box @treturn iguieditbox The edit box element */ //new({startx,starty},{endx,endy},"checkbox_name"[,ud_parent]) @@ -59,6 +56,11 @@ int newiguicheckbox(lua_State* L){ return 1; } +/*** +Is the checkbox checked. +@function iguicheckbox:ischecked() +@treturn boolean Is this checkbox checked? +*/ //ischecked(self) int ischecked(lua_State *L){ lua_getfield(L,-1,"guielement"); @@ -69,6 +71,11 @@ int ischecked(lua_State *L){ return 1; } +/*** +Set the state of the checkbox. +@function iguicheckbox:setchecked(set) +@tparam boolean set Should this checkbox be checked? (false to uncheck) +*/ //setchecked(self, checked) int setchecked(lua_State *L){ int should = lua_toboolean(L,-1); diff --git a/src/client/lua_api/gui/iguicolorselector.cpp b/src/client/lua_api/gui/iguicolorselector.cpp index 8a61c6d..5a11394 100644 --- a/src/client/lua_api/gui/iguicolorselector.cpp +++ b/src/client/lua_api/gui/iguicolorselector.cpp @@ -10,9 +10,6 @@ extern "C" { #include "iguielement.hpp" #include <shared/lua_api/common.hpp> -/*** -@module gui -*/ using namespace irr; using namespace gui; using namespace core; @@ -20,10 +17,11 @@ using namespace core; extern IrrlichtDevice* device; /*** -@function newcolorselector() -Creates a new checkbox +Creates a new Color selector. +Creates a dialog box that allows the user to select a color. TODO:Broken? +@function gui.newcolorselector() @tparam string title The title for this color selector -@tparam ?iguielement parent The parent element of the edit box +@tparam? iguielement parent The parent element of the edit box @treturn iguicolorselector The color selector element */ //newcolorselector("title"[,parent]) @@ -61,6 +59,12 @@ static const luaL_reg iguicolorselector_m[] = { {0,0}, }; +/*** +A dialog that allows the user to select a color +@class iguicolorselector +@inherits guielement +*/ + int iguicolorselector_register(lua_State* L){// luaL_newmetatable(L,"gui.colorselector");//m{gui.checkbox} luaL_register(L,NULL,iguielement_m); diff --git a/src/client/lua_api/gui/iguicombobox.cpp b/src/client/lua_api/gui/iguicombobox.cpp index 43c66f1..a9c4137 100644 --- a/src/client/lua_api/gui/iguicombobox.cpp +++ b/src/client/lua_api/gui/iguicombobox.cpp @@ -11,9 +11,6 @@ extern "C" { #include <shared/lua_api/common.hpp>
#include <client/lua_api/gui/iguicombobox.hpp>
-/***
-@module gui
-*/
using namespace irr;
using namespace core;
using namespace gui;
@@ -24,10 +21,10 @@ extern IrrlichtDevice* device; Creates a new combo box.
Buttons may have the following fields set for callbacks:
`.onChange(self)`
-@function newcombobox()
+@function gui.newcombobox()
@tparam rect dimensions The rectangle to place the button at. If the box has a parent,
it is offset from the upper-left of the parent element.
-@tparam ?iguielement parent The parent element of the button.
+@tparam? iguielement parent The parent element of the button.
@treturn iguicombobox The combo box element
*/
//gui.newcombobox({{sx,sy},{ex,ey}}[,parent])
@@ -60,7 +57,15 @@ static int newiguicombobox(lua_State* L){ return 1;
}
-//{combobox}.addItem(self,text,id)
+/***
+Add an item to the combo box
+Adds an option to this combo box, with a given id for when it it selected
+@function iguicombobox:additem(text,id)
+@tparam string text The text to add to the combo box
+@tparam number id The id to return from getselected() when this option is
+selected
+*/
+//{combobox}.add(self,text,id)
int additem(lua_State *L){
int id = lua_tonumber(L,-1);
lua_pop(L,1);//self,text
@@ -78,6 +83,12 @@ int additem(lua_State *L){ return 0;
}
+/***
+Get the selected item.
+Returns the number for the selected item, set with add()
+@function iguicombobox:get()
+@treturn number The item number that is currently selected
+*/
// {combobox}.getselected(self)
int getselected(lua_State *L){
lua_getfield(L,-1,"guielement");//self,ud_guielement
@@ -88,7 +99,13 @@ int getselected(lua_State *L){ return 1;
}
-//{combobox}.removeitem(self,id)
+/***
+Remove an item
+Removes an item from the combo box at the given id. Id's are assigned with add()
+@function iguicombobox:remove()
+@tparam number id The id number of the item to remove
+*/
+//{combobox}.remove(self,id)
int removeitem(lua_State *L){
int idx = lua_tonumber(L,-1);//self,id
lua_pop(L,1);//self
@@ -105,9 +122,9 @@ static const luaL_reg iguicombobox_f[] = { };
static const luaL_reg iguicombobox_m[] = {
- {"addItem", additem},
- {"getSelected", getselected},
- {"removeItem", removeitem},
+ {"add", additem},
+ {"get", getselected},
+ {"remove", removeitem},
{0,0},
};
diff --git a/src/client/lua_api/gui/iguieditbox.cpp b/src/client/lua_api/gui/iguieditbox.cpp index 7de3f37..409c2fc 100644 --- a/src/client/lua_api/gui/iguieditbox.cpp +++ b/src/client/lua_api/gui/iguieditbox.cpp @@ -12,10 +12,6 @@ extern "C" { #include <shared/util/hashmap.hpp> #include <shared/lua_api/common.hpp> -/*** -@module gui -*/ - using namespace irr; using namespace core; using namespace gui; @@ -23,11 +19,11 @@ using namespace gui; extern IrrlichtDevice* device; /*** -@function neweditbox() -Creates a new text entry box +Creates a new text entry box. +@function gui.neweditbox() @tparam rect dimensions The rectangle to place the box at. If the box has a parent, it is offset from the upper-left of the parent element. -@tparam ?iguielement parent The parent element of the edit box -@tparam ?string default_text The default text to have in the edit box +@tparam? iguielement parent The parent element of the edit box +@tparam? string default_text The default text to have in the edit box @treturn iguieditbox The edit box element */ //gui.neweditbox({{sx,sy},{ex,ey}}[,parent][,"default text"]) @@ -73,6 +69,12 @@ static int newiguieditbox(lua_State* L){ return 1; } +/*** +Set the edit box to multiline mode. +Allow / disallow the edit box to accept newlines. +@function iguieditbox:setmultiline(enable) +@tparam boolean enable Should the edit box allow newlines? +*/ //self:setmultiline(bool_enabled) int set_multiline(lua_State *L){ int should = lua_toboolean(L,-1); diff --git a/src/client/lua_api/gui/iguielement.cpp b/src/client/lua_api/gui/iguielement.cpp index db7669a..17ec4a5 100644 --- a/src/client/lua_api/gui/iguielement.cpp +++ b/src/client/lua_api/gui/iguielement.cpp @@ -1,5 +1,5 @@ /*This file defines some things that all igui stuff can do*/ -/*** +/* All gui elements inherit from iguielement. Some functions (like settext()) do different things for different elements. All gui elements can call the following callbacks: @@ -9,7 +9,6 @@ All gui elements can call the following callbacks: onHover(self) onLeave(self) -@classmod iguielement */ extern "C" { #include <lua.h> @@ -28,9 +27,10 @@ using namespace core; using namespace gui; extern IrrlichtDevice *device; + /*** Move an element (by an offset) from it's current position -@function guielement:move() +@function iguielement:move() @tparam vector2d position The offset to move this element by */ //move({element},{x,y}) -> nil @@ -51,7 +51,7 @@ int moveiguielement(lua_State* L){ /*** Set the visibility of this element -@function guielement:setvisible() +@function iguielement:setvisible() @tparam boolean visible Should this element be visible? */ int setvisible(lua_State *L){ @@ -69,7 +69,7 @@ int setvisible(lua_State *L){ /*** Find the rectangle that an element occupies -@function guielement:getabsrect() +@function iguielement:getabsrect() @treturn rect The rectangle that this element occupies */ //getabsrect({element})-> {{sx,sy},{ex,ey}} @@ -91,7 +91,7 @@ int getiguiclippingrect(lua_State* L){ /*** Find the rectangle that an element occupies that is visible to the user -@function guielement:getabsclippingrect() +@function iguielement:getabsclippingrect() @treturn rect The rectangle that this element occupies that is visible to the user */ //getabsclippingrect({element}) :: {{sx,sy},{ex,ey}} @@ -112,7 +112,7 @@ int getiguiabsclippingrect(lua_State *L){ /*** Find the relative rectangle that this element occupies -@function guielement:getrelrect() +@function iguielement:getrelrect() @treturn rect The rectangle that this element occupies relative to it's parent */ int getiguirelrect(lua_State *L){ @@ -135,7 +135,7 @@ Sets the text of the element This function may do different things to different gui elements. For example, on a window, it sets the title. On a button, it sets the button's text. -@function guielement:settext() +@function iguielement:settext() @tparam string text The text to set on the element */ //setText({guielement},"text") :: nil @@ -168,7 +168,7 @@ int setrelrect(lua_State *L){ /*** -@function guielement:gettext() +@function iguielement:gettext() @treturn string The caption text of the element. For input element like editboxes, this returns the text that the edit box contains. */ @@ -189,7 +189,7 @@ int getiguitext(lua_State* L){ /*** Removes a gui element, and any child elements -@function guielement:remove() +@function iguielement:remove() */ //remove({self}) int removeiguielement(lua_State* L){ diff --git a/src/client/lua_api/gui/iguifiledialog.cpp b/src/client/lua_api/gui/iguifiledialog.cpp index d717673..9b789cb 100644 --- a/src/client/lua_api/gui/iguifiledialog.cpp +++ b/src/client/lua_api/gui/iguifiledialog.cpp @@ -17,9 +17,6 @@ extern "C" { #include <shared/util/hashmap.hpp> #include <shared/lua_api/common.hpp> -/*** -@module gui -*/ using namespace irr; using namespace core; using namespace gui; @@ -27,17 +24,17 @@ using namespace gui; extern IrrlichtDevice* device; /*** -@function newfileopendialog() Creates a new dialog to open a file. The file creation window may have the following fields set for callbacks: .onDirectorySelect(self) .onFileSelect(self) .onCanceled(self) -@tparam ?string title The rectangle to place the button at. If the box has a parent, +@function gui.newfileopendialog() +@tparam? string title The rectangle to place the button at. If the box has a parent, it is offset from the upper-left of the parent element. -@tparam ?string path The path to open the file dialog to -@tparam ?iguielement parent The parent element of the button. -@tparam ?boolean modal If other gui elements can be interacted with before this element is closed +@tparam? string path The path to open the file dialog to +@tparam? iguielement parent The parent element of the button. +@tparam? boolean modal If other gui elements can be interacted with before this element is closed @treturn iguifileopendialog The button element */ //gui.newfileopendialog(["title"][,"path"][,parent][,modal]) diff --git a/src/client/lua_api/gui/iguiimage.cpp b/src/client/lua_api/gui/iguiimage.cpp index 267cbd2..81f6568 100644 --- a/src/client/lua_api/gui/iguiimage.cpp +++ b/src/client/lua_api/gui/iguiimage.cpp @@ -17,9 +17,6 @@ extern "C" { #include "../../callbackhandeler.hpp" #include <shared/lua_api/common.hpp> -/*** -@module gui -*/ using namespace irr; using namespace video; using namespace gui; @@ -28,14 +25,14 @@ extern IrrlichtDevice* device; extern IGUIEnvironment* env; /*** -@function newiguiimage() +@function gui.newiguiimage() Creates a new guielement with an image. The size of the iguielement is the same as the itexture used for it's creation. @tparam vector2d position The upper-left hand corner of the element. it is offset from the upper-left of the parent element. @tparam number alpha The transparency of the element. @tparam itexture texture The texture to display on this element. -@tparam ?iguielement parent The parent element of the button. +@tparam? iguielement parent The parent element of the button. @treturn iguifileopendialog The button element */ //newiguiimage({startx,starty},alpha,{itexture}[,parent]) -> {guielement} @@ -70,6 +67,12 @@ static int newiguiimage(lua_State* L){ return 1; } +/*** +Set the color of the image +Sets the color offset (additive color) for the image. +@function iguiimage:setcolor(color c) +@tparam color color The color to set the image as +*/ //setcolor(self,{r,g,b,a}) int setcolor(lua_State* L){ long r,g,b,a; @@ -81,6 +84,12 @@ int setcolor(lua_State* L){ return 0; } +/*** +Set the image of the element +Sets the image for the element. TODO: Memory leak of old images? +@function iguiimage:setimage(itexture texture) +@tparam itexture texture The texture to set this image element to +*/ //setimage(self,itexture) int setimage(lua_State *L){ lua_getfield(L,-1,"texture");//{iguiimg},{itex} diff --git a/src/client/lua_api/gui/iguilabel.cpp b/src/client/lua_api/gui/iguilabel.cpp index 529d680..bcb1778 100644 --- a/src/client/lua_api/gui/iguilabel.cpp +++ b/src/client/lua_api/gui/iguilabel.cpp @@ -17,21 +17,18 @@ extern "C" { #include "../../callbackhandeler.hpp" #include <shared/lua_api/common.hpp> -/*** -@module gui -*/ using namespace irr; using namespace gui; extern IrrlichtDevice* device; /*** -@function newlabel() +@function gui.newlabel() Creates a new label to display text. @tparam rect pos The position of the label, reletive to the upper-left of it's parent element, or the root window if parent is nil. @tparam string text The text to display on this label. -@tparam ?iguielement parent The parent element of the button. +@tparam? iguielement parent The parent element of the button. @treturn iguilabel The label element */ //gui.newlabel({{sx,sy},{ex,ey}},"text"[,parent]) :: {guielement} diff --git a/src/client/lua_api/gui/iguispinbox.cpp b/src/client/lua_api/gui/iguispinbox.cpp index 7cb1775..25ecbde 100644 --- a/src/client/lua_api/gui/iguispinbox.cpp +++ b/src/client/lua_api/gui/iguispinbox.cpp @@ -12,9 +12,6 @@ extern "C" { #include <shared/util/hashmap.hpp> #include <shared/lua_api/common.hpp> -/*** -@module gui -*/ using namespace irr; using namespace core; using namespace gui; @@ -22,13 +19,13 @@ using namespace gui; extern IrrlichtDevice* device; /*** -@function newspinbox() +@function gui.newspinbox() Creates a new spinbox @tparam rect dimensions The rectangle to place the button at. If the box has a parent, it is offset from the upper-left of the parent element. -@tparam ?string default_text The default text to display in the spinbox. -@tparam ?iguielement parent The parent element of the button. -@tparam ?boolean border Display a border around the spinbox +@tparam? string default_text The default text to display in the spinbox. +@tparam? iguielement parent The parent element of the button. +@tparam? boolean border Display a border around the spinbox @treturn iguibutton The button element */ //gui.newspinbox({{sx,sy},{ex,ey}}[,"text"][,parent][,border]) diff --git a/src/client/lua_api/gui/iguitreeview.cpp b/src/client/lua_api/gui/iguitreeview.cpp index 68aa3cc..3778a50 100644 --- a/src/client/lua_api/gui/iguitreeview.cpp +++ b/src/client/lua_api/gui/iguitreeview.cpp @@ -11,25 +11,21 @@ extern "C" { #include "client/callbackhandeler.hpp" #include <shared/lua_api/common.hpp> -/*** -@module gui -*/ using namespace irr; using namespace core; using namespace gui; - extern IrrlichtDevice* device; /*** -@function newtreeview() +@function gui.newtreeview() Creates a new tree view @tparam dimensions rect The rectangle to place the tree view at. If the box has a parent, it is offset from the upper-left of the parent element. -@tparam ?iguielement parent The parent element of the button. -@tparam ?boolean draw_background Should we draw a background for the tree view? -@tparam ?boolean vertical_scroll Should there be a vertical scroll bar? -@tparam ?boolean horizonal_scroll Should there be a horizontal scroll bar? +@tparam? iguielement parent The parent element of the button. +@tparam? boolean draw_background Should we draw a background for the tree view? +@tparam? boolean vertical_scroll Should there be a vertical scroll bar? +@tparam? boolean horizonal_scroll Should there be a horizontal scroll bar? @treturn iguitreeview The tree view element */ //gui.newtreeview({{sx,sy},{ex,ey}},[,parent][,draw_background][,vertical_scroll][,horizontal_scroll]) diff --git a/src/client/lua_api/gui/iguiwindow.cpp b/src/client/lua_api/gui/iguiwindow.cpp index 236fd5d..70f26e4 100644 --- a/src/client/lua_api/gui/iguiwindow.cpp +++ b/src/client/lua_api/gui/iguiwindow.cpp @@ -17,18 +17,15 @@ extern "C" { #include "../../callbackhandeler.hpp" #include <shared/lua_api/common.hpp> -/*** -@module gui -*/ using namespace irr; using namespace gui; /*** -@function newwindow() Creates a new gui window . +@function gui.newwindow() @tparam rect dimensions The rectangle to create the window at. @tparam string title_text The text to show in the title bar of the window -@tparam ?iguielement parent The parent element of the window. +@tparam? iguielement parent The parent element of the window. @treturn iguiwindow The window element In return to the usual gui element calls, IGUI window may call a `onClose()` callback. @@ -84,6 +81,11 @@ static const luaL_reg iguiwindow_m[] = { {0, 0}, }; +/*** +A window that you can add other gui elements to. +@class iguiwindow +@inherits iguielement +*/ int iguiwindow_register(lua_State* L, IrrlichtDevice* d){ luaL_newmetatable(L,"gui.window");//m{gui.window} lua_newtable(L); |
