Bläddra i källkod

Add property in UI module. Add support for function with default argument.

Aster Jian 12 år sedan
förälder
incheckning
3060463e4f

+ 1 - 1
Extras/LuaScript/pkgs/Audio/Audio.pkg

@@ -15,7 +15,7 @@ class Audio : public Object
 public:
     // Methods:
     bool SetMode(int bufferLengthMSec, int mixRate, bool stereo, bool interpolation = true);
-    bool SetMode(int bufferLengthMSec, int mixRate, bool stereo/*, bool interpolation = true*/);
+    bool SetMode(int bufferLengthMSec, int mixRate, bool stereo);
     bool Play();
     void Stop();
 

+ 16 - 24
Extras/LuaScript/pkgs/UI/BorderImage.pkg

@@ -2,42 +2,34 @@ $#include "BorderImage.h"
 
 enum BlendMode{};
 
-/// %Image %UI element with optional border.
 class BorderImage : public UIElement
 {
 public:
-    /// Construct.
+    // Method:
     BorderImage(Context* context);
-    /// Destruct.
     virtual ~BorderImage();
-	
-    /// Set texture.
+    
     void SetTexture(Texture* texture);
-    /// Set part of texture to use as the image.
     void SetImageRect(const IntRect& rect);
-    /// Use whole texture as the image.
     void SetFullImageRect();
-    /// Set image border dimensions.
     void SetBorder(const IntRect& rect);
-    /// Set offset to image rectangle used on hover.
     void SetHoverOffset(const IntVector2& offset);
-    /// Set offset to image rectangle used on hover.
     void SetHoverOffset(int x, int y);
-    /// Set blend mode.
     void SetBlendMode(BlendMode mode);
-    /// Set tiled mode.
     void SetTiled(bool enable);
     
-    /// Return texture.
-    Texture* GetTexture() const { return texture_; }
-    /// Return image rectangle.
-    const IntRect& GetImageRect() const { return imageRect_; }
-    /// Return image border dimensions.
-    const IntRect& GetBorder() const { return border_; }
-    /// Return offset to image rectangle used on hover.
-    const IntVector2& GetHoverOffset() const { return hoverOffset_; }
-    /// Return blend mode.
-    BlendMode GetBlendMode() const { return blendMode_; }
-    /// Return whether is tiled.
-    bool IsTiled() const { return tiled_; }
+    Texture* GetTexture() const;
+    const IntRect& GetImageRect() const;
+    const IntRect& GetBorder() const;
+    const IntVector2& GetHoverOffset() const;
+    BlendMode GetBlendMode() const;
+    bool IsTiled() const;
+    
+    // Properties:
+    tolua_property__get_set Texture* texture;
+    tolua_property__get_set const IntRect& imageRect;
+    tolua_property__get_set const IntRect& border;
+    tolua_property__get_set const IntVector2& hoverOffset;
+    tolua_property__get_set BlendMode blendMode;
+    tolua_property__is_set bool tiled;
 };

+ 12 - 18
Extras/LuaScript/pkgs/UI/Button.pkg

@@ -1,34 +1,28 @@
 $#include "Button.h"
 
-/// Pushbutton %UI element.
 class Button : public BorderImage
 {
 public:
-    /// Construct.
+    // Methods:
     Button(Context* context);
-    /// Destruct.
     virtual ~Button();
-    /// Set offset to image rectangle used when pressed.
+    
     void SetPressedOffset(const IntVector2& offset);
-    /// Set offset to image rectangle used when pressed.
     void SetPressedOffset(int x, int y);
-    /// Set pressed label offset.
     void SetLabelOffset(const IntVector2& offset);
-    /// Set pressed label offset.
     void SetLabelOffset(int x, int y);
-    /// Set repeat properties. Rate 0 (default) disables repeat.
     void SetRepeat(float delay, float rate);
-    /// Set repeat delay.
     void SetRepeatDelay(float delay);
-    /// Set repeat rate.
     void SetRepeatRate(float rate);
     
-    /// Return pressed image offset.
-    const IntVector2& GetPressedOffset() const { return pressedOffset_; }
-    /// Return pressed label offset.
-    const IntVector2& GetLabelOffset() const { return labelOffset_; }
-    /// Return repeat delay.
-    float GetRepeatDelay() const { return repeatDelay_; }
-    /// Return repeat rate.
-    float GetRepeatRate() const { return repeatRate_; }
+    const IntVector2& GetPressedOffset() const;
+    const IntVector2& GetLabelOffset() const;
+    float GetRepeatDelay() const;
+    float GetRepeatRate() const;
+    
+    // Properties:
+    tolua_property__get_set const IntVector2& pressedOffset;
+    tolua_property__get_set const IntVector2& labelOffset;
+    tolua_property__get_set const float repeatDelay;
+    tolua_property__get_set const float repeatRate;
 };

+ 8 - 10
Extras/LuaScript/pkgs/UI/CheckBox.pkg

@@ -1,22 +1,20 @@
 $#include "CheckBox.h"
 
-/// %UI element that can be toggled between unchecked and checked state.
 class CheckBox : public BorderImage
 {
 public:
-    /// Construct.
+    // Methods:
     CheckBox(Context* context);
-    /// Destruct.
     virtual ~CheckBox();
-    /// Set checked state.
+    
     void SetChecked(bool enable);
-    /// Set checked image offset.
     void SetCheckedOffset(const IntVector2& rect);
-    /// Set checked image offset.
     void SetCheckedOffset(int x, int y);
     
-    /// Return whether is checked.
-    bool IsChecked() const { return checked_; }
-    /// Return checked image offset.
-    const IntVector2& GetCheckedOffset() const { return checkedOffset_; }
+    bool IsChecked() const;
+    const IntVector2& GetCheckedOffset() const;
+    
+    // Properties:
+    tolua_property__is_set bool checked;
+    tolua_property__get_set const IntVector2& checkedOffset;
 };

+ 6 - 8
Extras/LuaScript/pkgs/UI/Cursor.pkg

@@ -1,6 +1,5 @@
 $#include "Cursor.h"
 
-/// %Cursor shapes recognized by the UI subsystem.
 enum CursorShape
 {
     CS_NORMAL = 0,
@@ -14,20 +13,19 @@ enum CursorShape
     CS_MAX_SHAPES
 };
 
-/// Mouse cursor %UI element.
 class Cursor : public BorderImage
 {
 public:
-    /// Construct.
+    // Methods:
     Cursor(Context* context);
-    /// Destruct.
     virtual ~Cursor();
     
-    /// Define a shape.
     void DefineShape(CursorShape shape, Image* image, const IntRect& imageRect, const IntVector2& hotSpot, bool osMouseVisible = false);
-    /// Set current shape.
+    void DefineShape(CursorShape shape, Image* image, const IntRect& imageRect, const IntVector2& hotSpot);
+    
     void SetShape(CursorShape shape);
+    CursorShape GetShape() const;
     
-    /// Get current shape.
-    CursorShape GetShape() const { return shape_; }
+    // Properties:
+    tolua_property__get_set CursorShape shape;
 };

+ 15 - 23
Extras/LuaScript/pkgs/UI/DropDownList.pkg

@@ -1,44 +1,36 @@
 $#include "DropDownList.h"
 
-/// %Menu %UI element that displays a popup list view.
 class DropDownList : public Menu
 {
 public:
-    /// Construct.
+    // Methods:
     DropDownList(Context* context);
-    /// Destruct.
     ~DropDownList();
-    /// Add item to the end of the list.
+    
     void AddItem(UIElement* item);
-    /// Insert item to a specific position.
     void InsertItem(unsigned index, UIElement* item);
-    /// Remove specific item.
     void RemoveItem(UIElement* item);
-    /// Remove item at index.
     void RemoveItem(unsigned index);
-    /// Remove all items.
     void RemoveAllItems();
-    /// Set selection.
     void SetSelection(unsigned index);
-    /// Set place holder text. This is the text shown when there is no selection in drop down list.
     void SetPlaceholderText(const String& text);
-    /// Set whether popup should be automatically resized to match the dropdown button width.
     void SetResizePopup(bool enable);
-
-    /// Return number of items.
+   
     unsigned GetNumItems() const;
-    /// Return item at index.
     UIElement* GetItem(unsigned index) const;
-    /// Return selection index, or M_MAX_UNSIGNED if none selected.
     unsigned GetSelection() const;
-    /// Return selected item, or null if none selected.
     UIElement* GetSelectedItem() const;
-    /// Return listview element.
-    ListView* GetListView() const { return listView_; }
-    /// Return selected item placeholder element.
-    UIElement* GetPlaceholder() const { return placeholder_; }
-    /// Return place holder text.
+    ListView* GetListView() const;
+    UIElement* GetPlaceholder() const;
     const String& GetPlaceholderText() const;
-    /// Return whether popup should be automatically resized.
-    bool GetResizePopup() const { return resizePopup_; }
+    bool GetResizePopup() const;
+    
+    // Properties:
+    tolua_readonly tolua_property__get_set unsigned numItems;
+    tolua_property__get_set unsigned selection;
+    tolua_readonly tolua_property__get_set UIElement* selectedItem;
+    tolua_readonly tolua_property__get_set ListView* listView;
+    tolua_readonly tolua_property__get_set UIElement* placeholder;
+    tolua_property__get_set const String& placeholderText;
+    tolua_property__get_set bool resizePopup;
 };

+ 34 - 43
Extras/LuaScript/pkgs/UI/FileSelector.pkg

@@ -1,69 +1,60 @@
 $#include "FileSelector.h"
 
-/// %File selector's list entry (file or directory.)
 struct FileSelectorEntry
 {
-    /// Name.
-    String name_;
-    /// Directory flag.
-    bool directory_;
+    String name_ @ name;
+    bool directory_ @ directory;
 };
 
-/// %File selector dialog.
 class FileSelector : public Object
 {
 public:
-    /// Construct.
+    // Methods:
     FileSelector(Context* context);
-    /// Destruct.
     virtual ~FileSelector();
-    /// Set fileselector UI style.
+
     void SetDefaultStyle(XMLFile* style);
-    /// Set title text.
     void SetTitle(const String& text);
-    /// Set button texts.
     void SetButtonTexts(const String& okText, const String& cancelText);
-    /// Set current path.
     void SetPath(const String& path);
-    /// Set current filename.
     void SetFileName(const String& fileName);
-    /// Set filters.
     void SetFilters(const Vector<String>& filters, unsigned defaultIndex);
-    /// Set directory selection mode. Default false.
     void SetDirectoryMode(bool enable);
-    /// Update elements to layout properly. Call this after manually adjusting the sub-elements.
     void UpdateElements();
 
-    /// Return the UI style file.
     XMLFile* GetDefaultStyle() const;
-    /// Return fileselector window.
-    Window* GetWindow() const { return window_; }
-    /// Return window title text element.
-    Text* GetTitleText() const { return titleText_; }
-    /// Return file list.
-    ListView* GetFileList() const { return fileList_; }
-    /// Return path editor.
-    LineEdit* GetPathEdit() const { return pathEdit_; }
-    /// Return filename editor.
-    LineEdit* GetFileNameEdit() const { return fileNameEdit_; }
-    /// Return filter dropdown.
-    DropDownList* GetFilterList() const { return filterList_; }
-    /// Return OK button.
-    Button* GetOKButton() const { return okButton_; }
-    /// Return cancel button.
-    Button* GetCancelButton() const { return cancelButton_; }
-    /// Return close button.
-    Button* GetCloseButton() const { return closeButton_; }
-    /// Return window title.
+    Window* GetWindow() const;
+    Text* GetTitleText() const;
+    ListView* GetFileList() const;
+    LineEdit* GetPathEdit() const;
+    LineEdit* GetFileNameEdit() const;
+    DropDownList* GetFilterList() const;
+    Button* GetOKButton() const;
+    Button* GetCancelButton() const;
+    Button* GetCloseButton() const;
     const String& GetTitle() const;
-    /// Return current path.
-    const String& GetPath() const { return path_; }
-    /// Return current filename.
+    const String& GetPath() const;
     const String& GetFileName() const;
-    /// Return current filter.
     const String& GetFilter() const;
-    /// Return current filter index.
     unsigned GetFilterIndex() const;
-    /// Return directory mode flag.
-    bool GetDirectoryMode() const { return directoryMode_; }
+    bool GetDirectoryMode() const;
+    
+    // Properties:
+    tolua_property__get_set XMLFile* defaultStyle;
+    tolua_readonly tolua_property__get_set Window* window;
+    tolua_readonly tolua_property__get_set Text* titleText;
+    tolua_readonly tolua_property__get_set ListView* fileList;
+    tolua_readonly tolua_property__get_set LineEdit* pathEdit;
+    tolua_readonly tolua_property__get_set LineEdit* fileNameEdit;
+    tolua_readonly tolua_property__get_set DropDownList* filterList;
+    tolua_readonly tolua_property__get_set Button* OKButton;
+    tolua_readonly tolua_property__get_set Button* cancelButton;
+    tolua_readonly tolua_property__get_set Button* closeButton;
+    
+    tolua_property__get_set const String& title;
+    tolua_property__get_set const String& path;
+    tolua_property__get_set const String& fileName;
+    tolua_readonly tolua_property__get_set const String& filter;
+    tolua_readonly tolua_property__get_set unsigned filterIndex;
+    tolua_property__get_set bool directoryMode;
 };

+ 0 - 1
Extras/LuaScript/pkgs/UI/Font.pkg

@@ -1,6 +1,5 @@
 $#include "Font.h"
 
-/// %Font resource.
 class Font : public Resource
 {
 public:

+ 25 - 33
Extras/LuaScript/pkgs/UI/LineEdit.pkg

@@ -1,52 +1,44 @@
 $#include "LineEdit.h"
 
-/// Single-line text editor %UI element.
 class LineEdit : public BorderImage
 {
 public:
-    /// Construct.
+    // Methods:
     LineEdit(Context* context);
-    /// Destruct.
     virtual ~LineEdit();
-    /// Set text.
+    
     void SetText(const String& text);
-    /// Set cursor position.
     void SetCursorPosition(unsigned position);
-    /// Set cursor blink rate. 0 disables blinking.
     void SetCursorBlinkRate(float rate);
-    /// Set maximum text length. 0 for unlimited.
     void SetMaxLength(unsigned length);
-    /// Set echo character for password entry and such. 0 (default) shows the actual text.
     void SetEchoCharacter(unsigned c);
-    /// Set whether can move cursor with arrows or mouse, default true.
     void SetCursorMovable(bool enable);
-    /// Set whether selections are allowed, default true.
     void SetTextSelectable(bool enable);
-    /// Set whether copy-paste operations are allowed, default true.
     void SetTextCopyable(bool enable);
-    /// Set text selection doubleclick interval in seconds.
     void SetDoubleClickInterval(float interval);
 
-    /// Return text.
-    const String& GetText() const { return line_; }
-    /// Return cursor position.
-    unsigned GetCursorPosition() const { return cursorPosition_; }
-    /// Return cursor blink rate.
-    float GetCursorBlinkRate() const { return cursorBlinkRate_; }
-    /// Return maximum text length.
-    unsigned GetMaxLength() const { return maxLength_; }
-    /// Return echo character.
-    unsigned GetEchoCharacter() const { return echoCharacter_; }
-    /// Return whether can move cursor with arrows or mouse.
-    bool IsCursorMovable() const { return cursorMovable_; }
-    /// Return whether selections are allowed.
-    bool IsTextSelectable() const { return textSelectable_; }
-    /// Return whether copy-paste operations are allowed.
-    bool IsTextCopyable() const { return textCopyable_; }
-    /// Return text element.
-    Text* GetTextElement() const { return text_; }
-    /// Return cursor element.
-    BorderImage* GetCursor() const { return cursor_; }
-    /// Return text selection doubleclick interval in seconds.
+    const String& GetText() const;
+    unsigned GetCursorPosition() const;
+    float GetCursorBlinkRate() const;
+    unsigned GetMaxLength() const;
+    unsigned GetEchoCharacter() const;
+    bool IsCursorMovable() const;
+    bool IsTextSelectable() const;
+    bool IsTextCopyable() const;
+    Text* GetTextElement() const;
+    BorderImage* GetCursor() const;
     float GetDoubleClickInterval() const;
+    
+    // Properties:
+    tolua_property__get_set const String& text;
+    tolua_property__get_set unsigned cursorPosition;
+    tolua_property__get_set float cursorBlinkRate;
+    tolua_property__get_set unsigned maxLength;
+    tolua_property__get_set unsigned echoCharacter;
+    tolua_property__is_set bool cursorMovable;
+    tolua_property__is_set bool textSelectable;
+    tolua_property__is_set bool textCopyable;
+    tolua_readonly tolua_property__get_set Text* textElement;
+    tolua_readonly tolua_property__get_set BorderImage* cursor;
+    tolua_property__get_set float doubleClickInterval;
 };

+ 30 - 49
Extras/LuaScript/pkgs/UI/ListView.pkg

@@ -1,92 +1,73 @@
 $#include "ListView.h"
 
-/// %ListView selection highlight mode.
 enum HighlightMode
 {
-    /// Never highlight selections.
     HM_NEVER,
-    /// Highlight when focused.
     HM_FOCUS,
-    /// Highlight always.
     HM_ALWAYS
 };
 
-/// Scrollable list %UI element.
 class ListView : public ScrollView
 {
 public:
-    /// Construct.
+    // Methods:
     ListView(Context* context);
-    /// Destruct.
     virtual ~ListView();
-    /// Add item to the end of the list.
+    
     void AddItem(UIElement* item);
-    /// \brief Insert item at a specific index. In hierarchy mode, the optional parameter will be used to determine the child's indent level in respect to its parent.
-    /// If index is greater than the total items then the new item is inserted at the end of the list.
-    /// In hierarchy mode, if index is greater than the index of last children of the specified parent item then the new item is inserted next to the last children.
-    /// And if the index is lesser than the index of the parent item itself then the new item is inserted before the first child item.
+    
     void InsertItem(unsigned index, UIElement* item, UIElement* parentItem = 0);
-    /// Remove specific item, starting search at the specified index if provided. In hierarchy mode will also remove any children.
+    void InsertItem(unsigned index, UIElement* item);
+    
     void RemoveItem(UIElement* item, unsigned index = 0);
-    /// Remove item at index. In hierarchy mode will also remove any children.
+    void RemoveItem(UIElement* item);
+    
     void RemoveItem(unsigned index);
-    /// Remove all items.
     void RemoveAllItems();
-    /// Set selection.
     void SetSelection(unsigned index);
-    /// Add item to the selection, multiselect mode only.
     void AddSelection(unsigned index);
-    /// Remove item from the selection.
     void RemoveSelection(unsigned index);
-    /// Toggle selection of an item.
     void ToggleSelection(unsigned index);
-    /// Move selection by a delta and clamp at list ends. If additive (multiselect only), will add to the existing selection.
+    
     void ChangeSelection(int delta, bool additive = false);
-    /// Clear selection.
+    void ChangeSelection(int delta);
+    
     void ClearSelection();
-    /// Set selected items' highlight mode.
     void SetHighlightMode(HighlightMode mode);
-    /// Enable multiselect.
     void SetMultiselect(bool enable);
-    /// \brief Enable hierarchy mode. Allows items to have parent-child relationship at different indent level and the ability to expand/collapse child items.
-    /// All items in the list will be lost during mode change.
     void SetHierarchyMode(bool enable);
-    /// Set base indent, i.e. the indent level of the ultimate parent item.
     void SetBaseIndent(int baseIndent);
-    /// Enable clearing of selection on defocus.
     void SetClearSelectionOnDefocus(bool enable);
-    /// Set item doubleclick interval in seconds.
     void SetDoubleClickInterval(float interval);
 
-    /// Expand item at index. Only has effect in hierarchy mode.
     void Expand(unsigned index, bool enable, bool recursive = false);
-    /// Toggle item's expanded flag at index. Only has effect in hierarchy mode.
+    void Expand(unsigned index, bool enable);
+    
     void ToggleExpand(unsigned index, bool recursive = false);
-
-    /// Return number of items.
+    void ToggleExpand(unsigned index);
+    
     unsigned GetNumItems() const;
-    /// Return item at index.
     UIElement* GetItem(unsigned index) const;
-    /// Return index of item, or M_MAX_UNSIGNED If not found.
     unsigned FindItem(UIElement* item) const;
-    /// Return first selected index, or M_MAX_UNSIGNED if none selected.
     unsigned GetSelection() const;
-    /// Return first selected item, or null if none selected.
     UIElement* GetSelectedItem() const;
-    /// Return whether an item at index is seleccted.
     bool IsSelected(unsigned index) const;
-    /// Return whether an item at index has its children expanded (in hierachy mode only).
     bool IsExpanded(unsigned index) const;
-    /// Return highlight mode.
-    HighlightMode GetHighlightMode() const { return highlightMode_; }
-    /// Return whether multiselect enabled.
-    bool GetMultiselect() const { return multiselect_; }
-    /// Return whether selection is cleared on defocus.
-    bool GetClearSelectionOnDefocus() const { return clearSelectionOnDefocus_; }
-    /// Return whether hierarchy mode enabled.
-    bool GetHierarchyMode() const { return hierarchyMode_; }
-    /// Return base indent.
-    int GetBaseIndent() const { return baseIndent_; }
-    /// Return item doubleclick interval in seconds.
+    HighlightMode GetHighlightMode() const;
+    bool GetMultiselect() const;
+    bool GetClearSelectionOnDefocus() const;
+    bool GetHierarchyMode() const;
+    int GetBaseIndent() const;
     float GetDoubleClickInterval() const;
+    
+    // Properties:
+    tolua_readonly tolua_property__get_set unsigned numItems;
+    tolua_property__get_set unsigned selection;
+    tolua_readonly tolua_property__get_set UIElement* selectedItem;
+    tolua_property__get_set HighlightMode highlightMode;
+    tolua_property__get_set bool multiselect;
+    tolua_property__get_set bool clearSelectionOnDefocus;
+    tolua_property__get_set bool hierarchyMode;
+    tolua_property__get_set int baseIndent;
+    tolua_property__get_set float doubleClickInterval;
 };

+ 15 - 18
Extras/LuaScript/pkgs/UI/Menu.pkg

@@ -1,33 +1,30 @@
 $#include "Menu.h"
 
-/// %Menu %UI element that optionally shows a popup.
 class Menu : public Button
 {
 public:
-    /// Construct.
+    // Methods:
     Menu(Context* context);
-    /// Destruct.
     virtual ~Menu();
-    /// Set popup element to show on selection.
+    
     void SetPopup(UIElement* element);
-    /// Set popup element offset.
     void SetPopupOffset(const IntVector2& offset);
-    /// Set popup element offset.
     void SetPopupOffset(int x, int y);
-    /// Force the popup to show or hide.
     void ShowPopup(bool enable);
-    /// Set accelerator key (set zero key code to disable.)
     void SetAccelerator(int key, int qualifiers);
 
-    /// Return popup element.
-    UIElement* GetPopup() const { return popup_; }
-    /// Return popup element offset.
-    const IntVector2& GetPopupOffset() const { return popupOffset_; }
-    /// Return whether popup is open.
-    bool GetShowPopup() const { return showPopup_; }
-    /// Return accelerator key code, 0 if disabled.
-    int GetAcceleratorKey() const { return acceleratorKey_; }
-    /// Return accelerator qualifiers.
-    int GetAcceleratorQualifiers() const { return acceleratorQualifiers_; }
+    UIElement* GetPopup() const;
+    const IntVector2& GetPopupOffset() const;
+    bool GetShowPopup() const;
+    int GetAcceleratorKey() const;
     int GetAcceleratorQualifiers() const;
+    
+    // Properties:
+    tolua_property__get_set UIElement* popup;
+    tolua_property__get_set const IntVector2& popupOffset;
+    tolua_property__get_set bool showPopup;
+    tolua_readonly tolua_property__get_set int acceleratorKey;
+    tolua_readonly tolua_property__get_set int acceleratorQualifiers;
 };
+
+$#define SetShowPopup ShowPopup

+ 18 - 25
Extras/LuaScript/pkgs/UI/ScrollBar.pkg

@@ -1,46 +1,39 @@
 $#include "ScrollBar.h"
 
-/// Scroll bar %UI element with forward and back buttons.
 class ScrollBar : public UIElement
 {
 public:
-    /// Construct.
+    // Methods:
     ScrollBar(Context* context);
-    /// Destruct.
     virtual ~ScrollBar();
-    /// Set orientation type.
+    
     void SetOrientation(Orientation orientation);
-    /// Set slider range maximum value (minimum value is always 0.)
     void SetRange(float range);
-    /// Set slider current value.
     void SetValue(float value);
-    /// Change slider current value by a delta.
     void ChangeValue(float delta);
-    /// Set button scroll step.
     void SetScrollStep(float step);
-    /// Set button step factor, can be used to adjust the step for constant pixel size.
     void SetStepFactor(float factor);
-    /// Scroll back one step.
     void StepBack();
-    /// Scroll forward one step.
     void StepForward();
     
-    /// Return scrollbar orientation.
     Orientation GetOrientation() const;
-    /// Return slider range.
     float GetRange() const;
-    /// Return slider current value.
     float GetValue() const;
-    /// Return button scroll step.
-    float GetScrollStep() const { return scrollStep_; }
-    /// Return button step factor.
-    float GetStepFactor() const { return stepFactor_; }
-    /// Return scroll step multiplied by factor.
+    float GetScrollStep() const;
+    float GetStepFactor() const;
     float GetEffectiveScrollStep() const;
-    /// Return back button element.
-    Button* GetBackButton() const { return backButton_; }
-    /// Return forward button element.
-    Button* GetForwardButton() const { return forwardButton_; }
-    /// Return slider element.
-    Slider* GetSlider() const { return slider_; }
+    Button* GetBackButton() const;
+    Button* GetForwardButton() const;
+    Slider* GetSlider() const;
+    
+    // Properties:
+    tolua_property__get_set Orientation orientation;
+    tolua_property__get_set float range;
+    tolua_property__get_set float value;
+    tolua_property__get_set float scrollStep;
+    tolua_property__get_set float stepFactor;
+    tolua_readonly tolua_property__get_set float effectiveScrollStep;
+    tolua_readonly tolua_property__get_set Button* backButton;
+    tolua_readonly tolua_property__get_set Button* forwardButton;
+    tolua_readonly tolua_property__get_set Slider* slider;
 };

+ 21 - 28
Extras/LuaScript/pkgs/UI/ScrollView.pkg

@@ -1,45 +1,38 @@
 $#include "ScrollView.h"
 
-/// Scrollable %UI element for showing a (possibly large) child element.
 class ScrollView : public UIElement
 {
 public:
-    /// Construct.
+    // Methods:
     ScrollView(Context* context);
-    /// Destruct.
     virtual ~ScrollView();
-    /// Set content element.
+    
     void SetContentElement(UIElement* element);
-    /// Set view offset from the top-left corner.
     void SetViewPosition(const IntVector2& position);
-    /// Set view offset from the top-left corner.
     void SetViewPosition(int x, int y);
-    /// Set scrollbars' visibility manually. Disables scrollbar autoshow/hide.
     void SetScrollBarsVisible(bool horizontal, bool vertical);
-    /// Set whether to automatically show/hide scrollbars. Default true.
     void SetScrollBarsAutoVisible(bool enable);
-    /// Set arrow key scroll step. Also sets it on the scrollbars.
     void SetScrollStep(float step);
-    /// Set arrow key page step.
     void SetPageStep(float step);
-
-    /// Return view offset from the top-left corner.
-    const IntVector2& GetViewPosition() const { return viewPosition_; }
-    /// Return content element.
-    UIElement* GetContentElement() const { return contentElement_; }
-    /// Return horizontal scroll bar.
-    ScrollBar* GetHorizontalScrollBar() const { return horizontalScrollBar_; }
-    /// Return vertical scroll bar.
-    ScrollBar* GetVerticalScrollBar() const { return verticalScrollBar_; }
-    /// Return scroll panel.
-    BorderImage* GetScrollPanel() const { return scrollPanel_; }
-    /// Return whether scrollbars are automatically shown/hidden.
-    bool GetScrollBarsAutoVisible() const { return scrollBarsAutoVisible_; }
-    /// Return arrow key scroll step.
+    
+    const IntVector2& GetViewPosition() const;
+    UIElement* GetContentElement() const;
+    ScrollBar* GetHorizontalScrollBar() const;
+    ScrollBar* GetVerticalScrollBar() const;
+    BorderImage* GetScrollPanel() const;
+    bool GetScrollBarsAutoVisible() const;
     float GetScrollStep() const;
-    /// Return arrow key page step.
-    float GetPageStep() const { return pageStep_; }
-
-    /// Set view position attribute.
+    float GetPageStep() const;
+    
     void SetViewPositionAttr(const IntVector2& value);
+    
+    // Properties:
+    tolua_property__get_set const IntVector2& viewPosition;
+    tolua_property__get_set UIElement* contentElement;
+    tolua_readonly tolua_property__get_set ScrollBar* horizontalScrollBar;
+    tolua_readonly tolua_property__get_set ScrollBar* verticalScrollBar;
+    tolua_readonly tolua_property__get_set BorderImage* scrollPanel;
+    tolua_property__get_set bool scrollBarsAutoVisible;
+    tolua_property__get_set float scrollStep;
+    tolua_property__get_set float pageStep;
 };

+ 15 - 19
Extras/LuaScript/pkgs/UI/Slider.pkg

@@ -1,32 +1,28 @@
 $#include "Slider.h"
 
-/// %Slider bar %UI element.
 class Slider : public BorderImage
 {
 public:
-    /// Construct.
+    // Methods:
     Slider(Context* context);
-    /// Destruct.
     virtual ~Slider();
-    /// Set orientation type.
+    
     void SetOrientation(Orientation orientation);
-    /// Set slider range maximum value (minimum value is always 0.)
     void SetRange(float range);
-    /// Set slider current value.
     void SetValue(float value);
-    /// Change value by a delta.
     void ChangeValue(float delta);
-    /// Set paging minimum repeat rate (number of events per second).
     void SetRepeatRate(float rate);
-
-    /// Return orientation type.
-    Orientation GetOrientation() const { return orientation_; }
-    /// Return slider range.
-    float GetRange() const { return range_; }
-    /// Return slider current value.
-    float GetValue() const { return value_; }
-    /// Return knob element.
-    BorderImage* GetKnob() const { return knob_; }
-    /// Return paging minimum repeat rate (number of events per second).
-    float GetRepeatRate() const { return repeatRate_; }
+    
+    Orientation GetOrientation() const;
+    float GetRange() const;
+    float GetValue() const;
+    BorderImage* GetKnob() const;
+    float GetRepeatRate() const;
+    
+    // Properties:
+    tolua_property__get_set Orientation orientation;
+    tolua_property__get_set float range;
+    tolua_property__get_set float value;
+    tolua_readonly tolua_property__get_set BorderImage* knob;
+    tolua_property__get_set float repeatRate;
 };

+ 21 - 55
Extras/LuaScript/pkgs/UI/Sprite.pkg

@@ -2,79 +2,45 @@ $#include "Sprite.h"
 
 enum BlendMode{};
 
-/// %UI element which allows sub-pixel positioning and size, as well as rotation. Only other Sprites should be added as child elements.
 class Sprite : public UIElement
 {
 public:
-	/// Construct.
+    // Methods:
     Sprite(Context* context);
-    /// Destruct.
     virtual ~Sprite();
-
-    /// Set floating point position.
+    
     void SetPosition(const Vector2& position);
-    /// Set floating point position.
     void SetPosition(float x, float y);
-    /// Set hotspot for positioning and rotation.
     void SetHotSpot(const IntVector2& hotSpot);
-    /// Set hotspot for positioning and rotation.
     void SetHotSpot(int x, int y);
-    /// Set scale. Scale also affects child sprites.
     void SetScale(const Vector2& scale);
-    /// Set scale. Scale also affects child sprites.
     void SetScale(float x, float y);
-    /// Set uniform scale. Scale also affects child sprites.
     void SetScale(float scale);
-    /// Set rotation angle.
     void SetRotation(float angle);
-    /// Set texture.
     void SetTexture(Texture* texture);
-    /// Set part of texture to use as the image.
     void SetImageRect(const IntRect& rect);
-    /// Use whole texture as the image.
     void SetFullImageRect();
-    /// Set blend mode.
     void SetBlendMode(BlendMode mode);
     
-    /// Return floating point position.
-    const Vector2& GetPosition() const { return floatPosition_; }
-    /// Return hotspot.
-    const IntVector2& GetHotSpot() const { return hotSpot_; }
-    /// Return scale.
-    const Vector2& GetScale() const { return scale_; }
-    /// Return rotation angle.
-    float GetRotation() const { return rotation_; }
-    /// Return texture.
-    Texture* GetTexture() const { return texture_; }
-    /// Return image rectangle.
-    const IntRect& GetImageRect() const { return imageRect_; }
-    /// Return blend mode.
-    BlendMode GetBlendMode() const { return blendMode_; }
-    
-    /// Set texture attribute.
+    const Vector2& GetPosition() const;
+    const IntVector2& GetHotSpot() const;
+    const Vector2& GetScale() const;
+    float GetRotation() const;
+    Texture* GetTexture() const;
+    const IntRect& GetImageRect() const;
+    BlendMode GetBlendMode() const;
     void SetTextureAttr(ResourceRef value);
-    /// Return texture attribute.
     ResourceRef GetTextureAttr() const;
-    /// Update and return rendering transform, also used to transform child sprites.
     const Matrix3x4& GetTransform() const;
-};
-
-/// Create sprite without lua GC.
-Sprite* NewSprite(Context* context);
-
-/// Delete sprite.
-void Delete(Sprite* sprite);
-
-${
-
-static Sprite* NewSprite(Context* context)
-{
-	return new Sprite(context);
-}
-
-static void Delete(Sprite* sprite)
-{
-    delete sprite;
-}
-
-$}
+    
+    // Properties:
+    tolua_property__get_set const Vector2& position;
+    tolua_property__get_set const IntVector2& hotSpot;
+    tolua_property__get_set const Vector2& scale;
+    tolua_property__get_set float rotation;
+    tolua_property__get_set Texture* texture;
+    tolua_property__get_set const IntRect& imageRect;
+    tolua_property__get_set BlendMode blendMode;
+    tolua_property__get_set ResourceRef textureAttr;
+    tolua_property__get_set const Matrix3x4& transform;
+};

+ 35 - 37
Extras/LuaScript/pkgs/UI/Text.pkg

@@ -1,56 +1,54 @@
 $#include "Text.h"
 
-/// %Text %UI element.
 class Text : public UIElement
 {
 public:
-    /// Construct.
+    // Methods:
     Text(Context* context);
-    /// Destruct.
     virtual ~Text();
-    /// Set font and font size.
+
     bool SetFont(const String& fontName, int size = DEFAULT_FONT_SIZE);
-    /// Set font and font size.
+    bool SetFont(const String& fontName);
+    
     bool SetFont(Font* font, int size = DEFAULT_FONT_SIZE);
-    /// Set text. Text is assumed to be either ASCII or UTF8-encoded.
+    bool SetFont(Font* font);
+    
     void SetText(const String& text);
-    /// Set row alignment.
     void SetTextAlignment(HorizontalAlignment align);
-    /// Set row spacing, 1.0 for original font spacing.
     void SetRowSpacing(float spacing);
-    /// Set wordwrap. In wordwrap mode the text element will respect its current width. Otherwise it resizes itself freely.
     void SetWordwrap(bool enable);
-    /// Set selection. When length is not provided, select until the text ends.
+    
     void SetSelection(unsigned start, unsigned length = M_MAX_UNSIGNED);
-    /// Clear selection.
+    void SetSelection(unsigned start);
+    
     void ClearSelection();
-    /// Set selection background color. Color with 0 alpha (default) disables.
     void SetSelectionColor(const Color& color);
-    /// Set hover background color. Color with 0 alpha (default) disables.
     void SetHoverColor(const Color& color);
+
+    Font* GetFont() const;
+    int GetFontSize() const;
+    const String& GetText() const;
+    HorizontalAlignment GetTextAlignment() const;
+    float GetRowSpacing() const;
+    bool GetWordwrap() const;
+    unsigned GetSelectionStart() const;
+    unsigned GetSelectionLength() const;
+    const Color& GetSelectionColor() const;
+    const Color& GetHoverColor() const;
+    int GetRowHeight() const;
+    unsigned GetNumRows() const;
     
-    /// Return font.
-    Font* GetFont() const { return font_; }
-    /// Return font size.
-    int GetFontSize() const { return fontSize_; }
-    /// Return text.
-    const String& GetText() const { return text_; }
-    /// Return row alignment.
-    HorizontalAlignment GetTextAlignment() const { return textAlignment_; }
-    /// Return row spacing.
-    float GetRowSpacing() const { return rowSpacing_; }
-    /// Return wordwrap mode.
-    bool GetWordwrap() const { return wordWrap_; }
-    /// Return selection start.
-    unsigned GetSelectionStart() const { return selectionStart_; }
-    /// Return selection length.
-    unsigned GetSelectionLength() const { return selectionLength_; }
-    /// Return selection background color.
-    const Color& GetSelectionColor() const { return selectionColor_; }
-    /// Return hover background color.
-    const Color& GetHoverColor() const { return hoverColor_; }
-    /// Return row height.
-    int GetRowHeight() const { return rowHeight_; }
-    /// Return number of rows.
-    unsigned GetNumRows() const { return rowWidths_.Size(); }
+    // Properties:
+    tolua_property__get_set Font* font;
+    tolua_readonly tolua_property__get_set int fontSize;
+    tolua_property__get_set const String& text;
+    tolua_property__get_set HorizontalAlignment textAlignment;
+    tolua_property__get_set float rowSpacing;
+    tolua_property__get_set bool wordwrap;
+    tolua_readonly tolua_property__get_set unsigned selectionStart;
+    tolua_readonly tolua_property__get_set unsigned selectionLength;
+    tolua_property__get_set const Color& selectionColor;
+    tolua_property__get_set const Color& hoverColor;
+    tolua_readonly tolua_property__get_set int rowHeight;
+    tolua_readonly tolua_property__get_set unsigned numRows;
 };

+ 23 - 34
Extras/LuaScript/pkgs/UI/Text3D.pkg

@@ -1,72 +1,61 @@
 $#include "Text3D.h"
 
-/// 3D text component.
 class Text3D : public Drawable
 {
 public:
-    /// Construct.
+    // Methods:
     Text3D(Context* context);
-    /// Destruct.
     ~Text3D();
-    /// Set font and font size. Return true if successful.
+    
     bool SetFont(const String& fontName, int size = DEFAULT_FONT_SIZE);
-    /// Set font and font size. Return true if successful.
+    bool SetFont(const String& fontName);
+    
     bool SetFont(Font* font, int size = DEFAULT_FONT_SIZE);
-    /// Set material.
+    bool SetFont(Font* font);
+    
     void SetMaterial(Material* material);
-    /// Set text. Text is assumed to be either ASCII or UTF8-encoded.
     void SetText(const String& text);
-    /// Set horizontal and vertical alignment.
     void SetAlignment(HorizontalAlignment hAlign, VerticalAlignment vAlign);
-    /// Set horizontal alignment.
     void SetHorizontalAlignment(HorizontalAlignment align);
-    /// Set vertical alignment.
     void SetVerticalAlignment(VerticalAlignment align);
-    /// Set row alignment.
     void SetTextAlignment(HorizontalAlignment align);
-    /// Set row spacing, 1.0 for original font spacing.
     void SetRowSpacing(float spacing);
-    /// Set wordwrap. In wordwrap mode the text element will respect its current width. Otherwise it resizes itself freely.
     void SetWordwrap(bool enable);
-    /// Set text width. Only has effect in word wrap mode.
     void SetWidth(int width);
-    /// Set color on all corners.
     void SetColor(const Color& color);
-    /// Set color on one corner.
     void SetColor(Corner corner, const Color& color);
-    /// Set opacity.
     void SetOpacity(float opacity);
-    /// Set whether to face camera automatically.
     void SetFaceCamera(bool enable);
     
-    /// Return font.
     Font* GetFont() const;
-    /// Return material.
     Material* GetMaterial() const;
-    /// Return font size.
     int GetFontSize() const;
-    /// Return text.
     const String& GetText() const;
-    /// Return row alignment.
     HorizontalAlignment GetTextAlignment() const;
-    /// Return horizontal alignment.
     HorizontalAlignment GetHorizontalAlignment() const;
-    /// Return vertical alignment.
     VerticalAlignment GetVerticalAlignment() const;
-    /// Return row spacing.
     float GetRowSpacing() const;
-    /// Return wordwrap mode.
     bool GetWordwrap() const;
-    /// Return text width.
     int GetWidth() const;
-    /// Return row height.
     int GetRowHeight() const;
-    /// Return number of rows.
     unsigned GetNumRows() const;
-    /// Return corner color.
     const Color& GetColor(Corner corner) const;
-    /// Return opacity.
     float GetOpacity() const;
-    /// Return whether faces camera automatically.
-    bool GetFaceCamera() const { return faceCamera_; }
+    bool GetFaceCamera() const;
+    
+    // Properties:
+    tolua_property__get_set Font* font;
+    tolua_property__get_set Material* material;
+    tolua_readonly tolua_property__get_set int fontSize;
+    tolua_property__get_set const String& text;
+    tolua_property__get_set HorizontalAlignment textAlignment;
+    tolua_property__get_set HorizontalAlignment horizontalAlignment;
+    tolua_property__get_set VerticalAlignment verticalAlignment;
+    tolua_property__get_set float rowSpacing;
+    tolua_property__get_set bool wordwrap;
+    tolua_property__get_set int width;
+    tolua_readonly tolua_property__get_set int rowHeight;
+    tolua_readonly tolua_property__get_set unsigned numRows;
+    tolua_property__get_set float opacity;
+    tolua_property__get_set bool faceCamera;
 };

+ 26 - 35
Extras/LuaScript/pkgs/UI/UI.pkg

@@ -1,56 +1,47 @@
 $#include "UI.h"
 
-/// %UI subsystem. Manages the graphical user interface.
 class UI : public Object
 {
-
 public:
-    /// Set cursor UI element.
+    // Methods:
     void SetCursor(Cursor* cursor);
-    /// Set focused UI element.
     void SetFocusElement(UIElement* element);
-    /// Set modal element. Until all the modal elements are dismissed, all the inputs and events are only sent to them. Return true when successful.
-    /// Only the modal element can clear its modal status or when it is being destructed.
-    /// UI subystem auto-removes modal element when an ESC key is pressed, however if this is not desirable, setting a user-defined variable "NoAutoRemove" in the modal element would prevent this.
-    /// In that case, the modal element will only have its modal flag reset and reparented back to its original parent.
     bool SetModalElement(UIElement* modalElement, bool enable);
-    /// Clear the UI (excluding the cursor.)
     void Clear();
-    /// Update the UI logic. Called by HandlePostUpdate().
     void Update(float timeStep);
-    /// Update the UI for rendering. Called by HandleRenderUpdate().
     void RenderUpdate();
-    /// Render the UI.
     void Render();
-    /// Debug draw a UI element.
     void DebugDraw(UIElement* element);
-    /// Save a UI layout to an XML file. Return true if successful.
     bool SaveLayout(Serializer& dest, UIElement* element);
-    /// Set clipboard text.
     void SetClipBoardText(const String& text);
-    /// Set mouse wheel handling flag.
     void SetNonFocusedMouseWheel(bool nonFocusedMouseWheel);
-
-    /// Return root UI element.
-    UIElement* GetRoot() const { return rootElement_; }
-    /// Return root modal element.
-    UIElement* GetRootModalElement() const { return rootModalElement_; }
-    /// Return cursor.
-    Cursor* GetCursor() const { return cursor_; }
-    /// Return UI element at screen coordinates.
+    
+    UIElement* GetRoot() const;
+    UIElement* GetRootModalElement() const;
+    
+    Cursor* GetCursor() const;
+    
     UIElement* GetElementAt(const IntVector2& position, bool enabledOnly = true);
-    /// Return UI element at screen coordinates.
+    UIElement* GetElementAt(const IntVector2& position);
+    
     UIElement* GetElementAt(int x, int y, bool enabledOnly = true);
-    /// Return focused element.
-    UIElement* GetFocusElement() const { return focusElement_; }
-    /// Return topmost enabled root-level non-modal element.
+    UIElement* GetElementAt(int x, int y);
+    
+    UIElement* GetFocusElement() const;
     UIElement* GetFrontElement() const;
-    /// Return cursor position.
+    
     IntVector2 GetCursorPosition() const;
-    /// Return clipboard text.
-    const String& GetClipBoardText() const { return clipBoard_; }
-    /// Return mouse wheel handling flag.
-    bool IsNonFocusedMouseWheel() const { return nonFocusedMouseWheel_; }
-    /// Return true when UI has modal element(s).
+    const String& GetClipBoardText() const;
+    bool IsNonFocusedMouseWheel() const;
     bool HasModalElement() const;
-};
+    
+    // Properties:
+    tolua_readonly tolua_property__get_set UIElement* root;
+    tolua_readonly tolua_property__get_set UIElement* rootModalElement;
+    tolua_readonly tolua_property__get_set Cursor* cursor;
+    tolua_readonly tolua_property__get_set UIElement* focusElement;
+    tolua_readonly tolua_property__get_set UIElement* frontElement;
+    tolua_property__get_set const String& clipBoardText;
+    tolua_readonly tolua_property__is_set bool nonFocusedMouseWheel;
+    tolua_readonly tolua_property__has_set bool modalElement;
+};

+ 161 - 205
Extras/LuaScript/pkgs/UI/UIElement.pkg

@@ -1,6 +1,5 @@
 $#include "UIElement.h"
 
-/// %UI element horizontal alignment.
 enum HorizontalAlignment
 {
     HA_LEFT = 0,
@@ -8,7 +7,6 @@ enum HorizontalAlignment
     HA_RIGHT
 };
 
-/// %UI element vertical alignment.
 enum VerticalAlignment
 {
     VA_TOP = 0,
@@ -16,7 +14,6 @@ enum VerticalAlignment
     VA_BOTTOM
 };
 
-/// %UI element corners.
 enum Corner
 {
     C_TOPLEFT = 0,
@@ -26,325 +23,284 @@ enum Corner
     MAX_UIELEMENT_CORNERS
 };
 
-/// %UI element orientation.
 enum Orientation
 {
     O_HORIZONTAL = 0,
     O_VERTICAL
 };
 
-/// %UI element focus mode.
 enum FocusMode
 {
-    /// Is not focusable and does not affect existing focus.
     FM_NOTFOCUSABLE = 0,
-    /// Resets focus when clicked.
     FM_RESETFOCUS,
-    /// Is focusable.
     FM_FOCUSABLE,
-    /// Is focusable and also defocusable by pressing ESC.
     FM_FOCUSABLE_DEFOCUSABLE
 };
 
-/// Layout operation mode.
 enum LayoutMode
 {
-    /// No layout operations will be performed.
     LM_FREE = 0,
-    /// Layout child elements horizontally and resize them to fit. Resize element if necessary.
     LM_HORIZONTAL,
-    /// Layout child elements vertically and resize them to fit. Resize element if necessary.
     LM_VERTICAL
 };
 
-/// Traversal mode.
 enum TraversalMode
 {
-    /// Traverse thru children having same priority first and recurse into their children before traversing children having higher priority.
     TM_BREADTH_FIRST = 0,
-    /// Traverse thru each child and its children immediately after in sequence.
     TM_DEPTH_FIRST
 };
 
-/// Drag and drop disabled.
 static const unsigned DD_DISABLED;
-/// Drag and drop source flag.
 static const unsigned DD_SOURCE;
-/// Drag and drop target flag.
 static const unsigned DD_TARGET;
-/// Drag and drop source and target.
 static const unsigned DD_SOURCE_AND_TARGET;
 
-/// Base class for %UI elements.
 class UIElement : public Serializable
 {
 public:
-    /// Construct.
+    // Methods:
     UIElement(Context* context);
-    /// Destruct.
     virtual ~UIElement();
-    /// Set name.
+
+    virtual const IntVector2& GetScreenPosition() const;
+
     void SetName(const String& name);
-    /// Set position.
+    
     void SetPosition(const IntVector2& position);
-    /// Set position.
     void SetPosition(int x, int y);
-    /// Set size.
+    
     void SetSize(const IntVector2& size);
-    /// Set size.
     void SetSize(int width, int height);
-    /// Set width only.
     void SetWidth(int width);
-    /// Set height only.
     void SetHeight(int height);
-    /// Set minimum size.
+    
     void SetMinSize(const IntVector2& minSize);
-    /// Set minimum size.
     void SetMinSize(int width, int height);
-    /// Set minimum width.
     void SetMinWidth(int width);
-    /// Set minimum height.
     void SetMinHeight(int height);
-    /// Set maximum size.
+    
     void SetMaxSize(const IntVector2& maxSize);
-    /// Set maximum size.
     void SetMaxSize(int width, int height);
-    /// Set maximum width.
     void SetMaxWidth(int width);
-    /// Set maximum height.
     void SetMaxHeight(int height);
-    /// Set fixed size.
+    
     void SetFixedSize(const IntVector2& size);
-    /// Set fixed size.
     void SetFixedSize(int width, int height);
-    /// Set fixed width.
     void SetFixedWidth(int width);
-    /// Set fixed height.
     void SetFixedHeight(int height);
-    /// Set horizontal and vertical alignment.
+    
     void SetAlignment(HorizontalAlignment hAlign, VerticalAlignment vAlign);
-    /// Set horizontal alignment.
     void SetHorizontalAlignment(HorizontalAlignment align);
-    /// Set vertical alignment.
     void SetVerticalAlignment(VerticalAlignment align);
-    /// Set child element clipping border.
+    
     void SetClipBorder(const IntRect& rect);
-    /// Set color on all corners.
+    
     void SetColor(const Color& color);
-    /// Set color on one corner.
     void SetColor(Corner corner, const Color& color);
-    /// Set priority.
+    
     void SetPriority(int priority);
-    /// Set opacity.
     void SetOpacity(float opacity);
-    /// Set whether should be brought to front when focused.
+    
     void SetBringToFront(bool enable);
-    /// Set whether should be put to background when another element is focused.
     void SetBringToBack(bool enable);
-    /// Set whether should clip child elements. Default false.
+    
     void SetClipChildren(bool enable);
-    /// Set whether should sort child elements according to priority. Default true.
     void SetSortChildren(bool enable);
-    /// Set whether parent elements' opacity affects opacity. Default true.
     void SetUseDerivedOpacity(bool enable);
-    /// Set whether reacts to input.
     void SetEnabled(bool enable);
-    /// Set whether is focused. Only one element can be focused at a time.
     void SetFocus(bool enable);
-    /// Set selected mode. Actual meaning is element dependent, for example constant hover or pressed effect.
     void SetSelected(bool enable);
-    /// Set whether is visible.
     void SetVisible(bool enable);
-    /// Set focus mode.
     void SetFocusMode(FocusMode mode);
-    /// Set drag and drop flags.
     void SetDragDropMode(unsigned mode);
-    /// Set style from an XML file. Find the style element by name. If the style file is not explicitly provided, use the default style from parental chain. Return true if the style is applied successfully.
+
     bool SetStyle(const String& styleName, XMLFile* file = 0);
-    /// Set style from an XML element. Return true if the style is applied successfully.
+    bool SetStyle(const String& styleName);
+    
     bool SetStyle(const XMLElement& element);
-    /// Set style from an XML file. Find the style element automatically. If the style file is not explicitly provided, use the default style from parental chain. Return true if the style is applied successfully.
     bool SetStyleAuto(XMLFile* file = 0);
-    /// Set default style file for later use by children elements.
+    bool SetStyleAuto();
     void SetDefaultStyle(XMLFile* style);
-    /// Set layout.
+    
     void SetLayout(LayoutMode mode, int spacing = 0, const IntRect& border = IntRect::ZERO);
-    /// Set layout mode only.
+    void SetLayout(LayoutMode mode, int spacing = 0);
+    void SetLayout(LayoutMode mode);
+    
     void SetLayoutMode(LayoutMode mode);
-    /// Set layout spacing.
     void SetLayoutSpacing(int spacing);
-    /// Set layout border.
     void SetLayoutBorder(const IntRect& border);
-    /// Set horizontal indentation.
     void SetIndent(int indent);
-    /// Set indent spacing (number of pixels per indentation level).
     void SetIndentSpacing(int indentSpacing);
-    /// Manually update layout. Should not be necessary in most cases, but is provided for completeness.
     void UpdateLayout();
-    /// Disable automatic layout update. Should only be used if there are performance problems.
     void DisableLayoutUpdate();
-    /// Enable automatic layout update.
     void EnableLayoutUpdate();
-    /// Bring UI element to front.
     void BringToFront();
-    /// Create and add a child element and return it.
+    
     UIElement* CreateChild(ShortStringHash type, const String& name = String::EMPTY, unsigned index = M_MAX_UNSIGNED);
-    /// Add a child element.
+    UIElement* CreateChild(ShortStringHash type, const String& name = String::EMPTY);
+    UIElement* CreateChild(ShortStringHash type);
+    
     void AddChild(UIElement* element);
-    /// Insert a child element into a specific position in the child list.
     void InsertChild(unsigned index, UIElement* element);
-    /// Remove a child element. Starting search at specified index if provided.
     void RemoveChild(UIElement* element, unsigned index = 0);
-    /// Remove a child element at index.
-    void RemoveChildAtIndex(unsigned index);
-    /// Remove all child elements.
+    void RemoveChild(UIElement* element);
+    void RemoveChildAtIndex @ RemoveChild(unsigned index);
     void RemoveAllChildren();
-    /// Remove from the parent element. If no other shared pointer references exist, causes immediate deletion.
     void Remove();
-    /// Find child index. Return M_MAX_UNSIGNED if not found.
     unsigned FindChild(UIElement* element) const;
-    /// Set parent element. Same as parent->InsertChild(index, this).
     void SetParent(UIElement* parent, unsigned index = M_MAX_UNSIGNED);
-    /// Set a user variable.
-    void SetVar(ShortStringHash key, const Variant& value);
-    /// Mark as internally (programmatically) created. Used when an element composes itself out of child elements.
+    void SetParent(UIElement* parent);
+    
     void SetInternal(bool enable);
-    /// Set traversal mode. The default traversal mode is TM_BREADTH_FIRST for non-root element. Root element should be set to TM_DEPTH_FIRST to avoid artifacts during rendering.
     void SetTraversalMode(TraversalMode traversalMode);
-    /// Set element event sender flag. When child element is added or deleted, the event would be sent using UIElement found in the parental chain having this flag set. If not set, the event is sent using UI's root as per normal.
     void SetElementEventSender(bool flag);
-	
-    /// Return name.
-    const String& GetName() const { return name_; }
-    /// Return position.
-    const IntVector2& GetPosition() const { return position_; }
-    /// Return size.
-    const IntVector2& GetSize() const { return size_; }
-    /// Return width.
-    int GetWidth() const { return size_.x_; }
-    /// Return height.
-    int GetHeight() const { return size_.y_; }
-    /// Return minimum size.
-    const IntVector2& GetMinSize() const { return minSize_; }
-    /// Return minimum width.
-    int GetMinWidth() const { return minSize_.x_; }
-    /// Return minimum height.
-    int GetMinHeight() const { return minSize_.y_; }
-    /// Return maximum size.
-    const IntVector2& GetMaxSize() const { return maxSize_; }
-    /// Return minimum width.
-    int GetMaxWidth() const { return maxSize_.x_; }
-    /// Return minimum height.
-    int GetMaxHeight() const { return maxSize_.y_; }
-    /// Return true if size is fixed.
-    bool IsFixedSize() const { return minSize_ == maxSize_; }
-    /// Return true if width is fixed.
-    bool IsFixedWidth() const { return minSize_.x_ == maxSize_.x_; }
-    /// Return true if height is fixed.
-    bool IsFixedHeight() const { return minSize_.y_ == maxSize_.y_; }
-    /// Return child element offset.
-    const IntVector2& GetChildOffset() const { return childOffset_; }
-    /// Return horizontal alignment.
-    HorizontalAlignment GetHorizontalAlignment() const { return horizontalAlignment_; }
-    /// Return vertical alignment.
-    VerticalAlignment GetVerticalAlignment() const { return verticalAlignment_; }
-    /// Return child element clipping border.
-    const IntRect& GetClipBorder() const { return clipBorder_; }
-    /// Return corner color.
-    const Color& GetColor(Corner corner) const { return color_[corner]; }
-    /// Return priority.
-    int GetPriority() const { return priority_; }
-    /// Return opacity.
-    float GetOpacity() const { return opacity_; }
-    /// Return derived opacity (affected by parent elements.) If UseDerivedOpacity is false, returns same as element's own opacity.
+    
+    const String& GetName() const;
+    const IntVector2& GetPosition() const;
+    const IntVector2& GetSize() const;
+    int GetWidth() const;
+    int GetHeight() const;
+    const IntVector2& GetMinSize() const;
+    int GetMinWidth() const;
+    int GetMinHeight() const;
+    const IntVector2& GetMaxSize() const;
+    int GetMaxWidth() const;
+    int GetMaxHeight() const;
+    
+    bool IsFixedSize() const;
+    bool IsFixedWidth() const;
+    bool IsFixedHeight() const;
+    
+    const IntVector2& GetChildOffset() const;
+    HorizontalAlignment GetHorizontalAlignment() const;
+    VerticalAlignment GetVerticalAlignment() const;
+    const IntRect& GetClipBorder() const;
+    const Color& GetColor(Corner corner) const;
+    int GetPriority() const;
+    float GetOpacity() const;
     float GetDerivedOpacity() const;
-    /// Return whether should be brought to front when focused.
-    bool GetBringToFront() const { return bringToFront_; }
-    /// Return whether should be put to background when another element is focused.
-    bool GetBringToBack() const { return bringToBack_; }
-    /// Return whether should clip child elements.
-    bool GetClipChildren() const { return clipChildren_; }
-    /// Return whether should sort child elements according to priority.
-    bool GetSortChildren() const { return sortChildren_; }
-    /// Return whether parent elements' opacity affects opacity.
-    bool GetUseDerivedOpacity() const { return useDerivedOpacity_; }
-    /// Return whether has focus.
+    bool GetBringToFront() const;
+    bool GetBringToBack() const;
+    bool GetClipChildren() const;
+    bool GetSortChildren() const;
+    bool GetUseDerivedOpacity() const;
     bool HasFocus() const;
-    /// Return whether reacts to input.
-    bool IsEnabled() const { return enabled_; }
-    /// Return whether is selected. Actual meaning is element dependent.
-    bool IsSelected() const { return selected_; }
-    /// Return whether is visible.
-    bool IsVisible() const { return visible_; }
-    /// Return whether the cursor is hovering on this element.
-    bool IsHovering() const { return hovering_; }
-    /// Return whether is internally created.
-    bool IsInternal() const { return internal_; }
-    /// Return whether has different color in at least one corner.
-    bool HasColorGradient() const { return colorGradient_; }
-    /// Return focus mode.
-    FocusMode GetFocusMode() const { return focusMode_; }
-    /// Return drag and drop flags.
-    unsigned GetDragDropMode() const { return dragDropMode_; }
-    /// Return applied style name. Return an empty string when the applied style is an 'auto' style (i.e. style derived from instance's type).
+    bool IsEnabled() const;
+    bool IsSelected() const;
+    bool IsVisible() const;
+    bool IsHovering() const;
+    bool IsInternal() const;
+    bool HasColorGradient() const;
+    FocusMode GetFocusMode() const;
+    unsigned GetDragDropMode() const;
     const String& GetAppliedStyle() const;
-    /// Return default style.
+    
     XMLFile* GetDefaultStyle(bool recursiveUp = true) const;
-    /// Return layout mode.
-    LayoutMode GetLayoutMode() const { return layoutMode_; }
-    /// Return layout spacing.
-    int GetLayoutSpacing() const { return layoutSpacing_; }
-    /// Return layout border.
-    const IntRect& GetLayoutBorder() const { return layoutBorder_; }
-    /// Return number of child elements.
+    XMLFile* GetDefaultStyle() const;
+    
+    LayoutMode GetLayoutMode() const;
+    int GetLayoutSpacing() const;
+    const IntRect& GetLayoutBorder() const;
+    
     unsigned GetNumChildren(bool recursive = false) const;
-    /// Return child element by index.
+    unsigned GetNumChildren() const;
+    
     UIElement* GetChild(unsigned index) const;
-    /// Return child element by name.
+    
     UIElement* GetChild(const String& name, bool recursive = false) const;
-    /// Return child element by variable. If only key is provided, return the first child having the matching variable key. If value is also provided then the actual variable value would also be checked against.
+    UIElement* GetChild(const String& name) const;
+    tolua_outside UIElement* UIElementGetChild @ GetChild(const char* name, bool recursive = false) const;
+    tolua_outside UIElement* UIElementGetChild @ GetChild(const char* name) const;
+    
     UIElement* GetChild(const ShortStringHash& key, const Variant& value = Variant::EMPTY, bool recursive = false) const;
-    /// Return parent element.
-    UIElement* GetParent() const { return parent_; }
-    /// Return root element.
+    UIElement* GetChild(const ShortStringHash& key, const Variant& value = Variant::EMPTY) const;
+    UIElement* GetChild(const ShortStringHash& key) const;
+    
+    UIElement* GetParent() const;
     UIElement* GetRoot() const;
-    /// Return derived color. Only valid when no gradient.
     const Color& GetDerivedColor() const;
-    /// Convert screen coordinates to element coordinates.
+    
     IntVector2 ScreenToElement(const IntVector2& screenPosition);
-    /// Convert element coordinates to screen coordinates.
     IntVector2 ElementToScreen(const IntVector2& position);
-    /// Return whether a point (either in element or screen coordinates) is inside the element.
+    
     bool IsInside(IntVector2 position, bool isScreen);
-    /// Return whether a point (either in element or screen coordinates) is inside the combined rect of the element and its children.
     bool IsInsideCombined(IntVector2 position, bool isScreen);
-    /// Return combined screen coordinate rect of element and its children.
+    
     IntRect GetCombinedScreenRect();
-    /// Sort child elements if sorting enabled and order dirty. Called by UI.
     void SortChildren();
-    /// Return minimum layout element size in the layout direction. Only valid after layout has been calculated.
-    int GetLayoutMinSize() const { return layoutMinSize_; }
-    /// Return horizontal indentation.
-    int GetIndent() const { return indent_; }
-    /// Return indent spacing (number of pixels per indentation level).
-    int GetIndentSpacing() const { return indentSpacing_; }
-    /// Return indent width in pixels.
-    int GetIndentWidth() const { return indent_ * indentSpacing_; }
-
-    /// Set child offset.
+    int GetLayoutMinSize() const;
+    
+    int GetIndent() const;
+    int GetIndentSpacing() const;
+    int GetIndentWidth() const;
     void SetChildOffset(const IntVector2& offset);
-    /// Set hovering state.
     void SetHovering(bool enable);
-    /// Set temporary visibility status without updating layout or sending events. Used internally.
-    void SetTempVisible(bool enable);
-    /// Adjust scissor for rendering.
-    void AdjustScissor(IntRect& currentScissor);
-    /// Get color attribute. Uses just the top-left color.
-    const Color& GetColorAttr() const { return color_[0]; }
-    /// Get traversal mode.
-    TraversalMode GetTraversalMode() const { return traversalMode_; }
-    /// Get element event sender flag.
-    bool IsElementEventSender() const { return elementEventSender_; }
-    /// Get element event sender.
+    TraversalMode GetTraversalMode() const;
+    bool IsElementEventSender() const;
     UIElement* GetElementEventSender() const;
+    
+    // Properties:
+    tolua_property__get_set const String& style;
+    tolua_property__get_set const String& name;
+    tolua_property__get_set const IntVector2& position;
+    tolua_property__get_set const IntVector2 size;
+    tolua_property__get_set int width;
+    tolua_property__get_set const int height;
+    tolua_property__get_set const IntVector2 minSize;
+    tolua_property__get_set const int minWidth;
+    tolua_property__get_set const int minHeight;
+    tolua_property__get_set IntVector2 maxSize;
+    tolua_property__get_set int maxWidth;
+    tolua_property__get_set int maxHeight;
+    
+    tolua_readonly tolua_property__is_set bool fixedSize;
+    tolua_readonly tolua_property__is_set bool fixedWidth;
+    tolua_readonly tolua_property__is_set bool fixedHeight;
+    
+    tolua_property__get_set HorizontalAlignment horizontalAlignment;
+    tolua_property__get_set VerticalAlignment verticalAlignment;
+    tolua_property__get_set IntRect clipBorder;
+    tolua_property__get_set int priority;
+    tolua_property__get_set float opacity;
+    tolua_property__get_set bool bringToFront;
+    tolua_property__get_set bool bringToBack;
+    tolua_property__get_set bool clipChildren;
+    tolua_property__get_set bool sortChildren;
+    tolua_property__get_set bool useDerivedOpacity;
+    tolua_property__is_set bool enabled;
+    tolua_property__has_set bool focus;
+    tolua_property__is_set bool selected;
+    tolua_property__is_set bool visible;
+    tolua_property__is_set bool hovering;
+    tolua_property__is_set bool internal;
+    tolua_readonly tolua_property__has_set bool colorGradient;
+    tolua_property__get_set FocusMode focusMode;
+    tolua_property__get_set unsigned dragDropMode;
+    tolua_property__get_set TraversalMode traversalMode;
+    tolua_property__get_set XMLFile* defaultStyle;
+    tolua_property__get_set LayoutMode layoutMode;
+    tolua_property__get_set int layoutSpacing;
+    tolua_property__get_set const IntRect& layoutBorder;
+    
+    tolua_property__get_set int indent;
+    tolua_property__get_set int indentSpacing;
+    tolua_readonly tolua_property__get_set int indentWidth;
+    tolua_property__get_set const IntVector2& childOffset;
+    tolua_property__is_set bool elementEventSender;
+    tolua_readonly tolua_property__get_set unsigned numChildren;
+    tolua_property__get_set UIElement* parent;
+    tolua_readonly tolua_property__get_set UIElement* root;
+    tolua_readonly tolua_property__get_set const IntVector2& screenPosition;
+    tolua_readonly tolua_property__get_set const IntRect& combinedScreenRect;
+    tolua_readonly tolua_property__get_set float derivedOpacity;
 };
+
+${
+
+UIElement* UIElementGetChild(const UIElement* uiElement, const char* name, bool recursive = false)
+{
+    return uiElement->GetChild(String(name), recursive);
+}
+#define GetStyle GetAppliedStyle
+
+$}

+ 17 - 25
Extras/LuaScript/pkgs/UI/Window.pkg

@@ -1,6 +1,5 @@
 $#include "Window.h"
 
-/// %Window movement and resizing modes.
 enum WindowDragMode
 {
     DRAG_NONE,
@@ -15,41 +14,34 @@ enum WindowDragMode
     DRAG_RESIZE_LEFT
 };
 
-/// %Window %UI element that can optionally by moved or resized.
 class Window : public BorderImage
 {
 public:
-    /// Construct.
     Window(Context* context);
-    /// Destruct.
     virtual ~Window();
-    /// Set whether can be moved.
+    
     void SetMovable(bool enable);
-    /// Set whether can be resized.
     void SetResizable(bool enable);
-    /// Set resize area width at edges.
     void SetResizeBorder(const IntRect& rect);
-    /// Set modal flag. When the modal flag is set, the focused window needs to be dismissed first to allow other UI elements to gain focus.
     void SetModal(bool modal);
-    /// Set modal shade color.
     void SetModalShadeColor(const Color& color);
-    /// Set modal frame color.
     void SetModalFrameColor(const Color& color);
-    /// Set modal frame size.
     void SetModalFrameSize(const IntVector2& size);
 
-    /// Return whether is movable.
-    bool IsMovable() const { return movable_; }
-    /// Return whether is resizable.
-    bool IsResizable() const { return resizable_; }
-    /// Return resize area width at edges.
-    const IntRect& GetResizeBorder() const { return resizeBorder_; }
-    /// Return modal flag.
-    bool IsModal() const { return modal_; }
-    /// Get modal shade color.
-    const Color& GetModalShadeColor() const { return modalShadeColor_; }
-    /// Get modal frame color.
-    const Color& GetModalFrameColor() const { return modalFrameColor_; }
-    /// Get modal frame size.
-    const IntVector2& GetModalFrameSize() const { return modalFrameSize_; }
+    bool IsMovable() const;
+    bool IsResizable() const;
+    const IntRect& GetResizeBorder() const;
+    bool IsModal() const;
+    const Color& GetModalShadeColor() const;
+    const Color& GetModalFrameColor() const;
+    const IntVector2& GetModalFrameSize() const;
+    
+    // Properties:
+    tolua_property__is_set bool movable;
+    tolua_property__is_set bool resizable;
+    tolua_property__get_set const IntRect& resizeBorder;
+    tolua_property__is_set bool modal;
+    tolua_property__get_set const Color& modalShadeColor;
+    tolua_property__get_set const Color& modalFrameColor;
+    tolua_property__get_set const IntVector2& modalFrameSize;
 };

+ 5 - 0
Extras/LuaScript/pkgs/basic.lua

@@ -81,4 +81,9 @@ function get_property_methods_hook(ptype, name)
         local Name = string.upper(string.sub(name, 1, 1))..string.sub(name, 2)
         return "Is"..Name, "Set"..Name
     end
+    
+    if ptype == "has_set" then
+        local Name = string.upper(string.sub(name, 1, 1))..string.sub(name, 2)
+        return "Has"..Name, "Set"..Name
+    end
 end