diff options
-rw-r--r-- | doc/lua/openstarbound/widget.md | 16 | ||||
-rw-r--r-- | source/windowing/StarImageStretchWidget.cpp | 6 | ||||
-rw-r--r-- | source/windowing/StarImageStretchWidget.hpp | 2 | ||||
-rw-r--r-- | source/windowing/StarWidgetLuaBindings.cpp | 7 |
4 files changed, 30 insertions, 1 deletions
diff --git a/doc/lua/openstarbound/widget.md b/doc/lua/openstarbound/widget.md index 4d97e9a..288c899 100644 --- a/doc/lua/openstarbound/widget.md +++ b/doc/lua/openstarbound/widget.md @@ -30,4 +30,18 @@ Gets the cursor position of a TextBoxWidget. #### `void` widget.setCursorPosition(`String` widgetName, `int` cursorPosition) -Sets the cursor position of a TextBoxWidget.
\ No newline at end of file +Sets the cursor position of a TextBoxWidget. + +--- + +#### `void` widget.setImageStretchSet(`String` widgetName, `Json` imageStretchSet) + +Sets the full image set of a ImageStretchWidget. + +``` +{ + begin = "image.png", + inner = "image.png", + end = "image.png" +} +``` diff --git a/source/windowing/StarImageStretchWidget.cpp b/source/windowing/StarImageStretchWidget.cpp index a511cb1..27edc39 100644 --- a/source/windowing/StarImageStretchWidget.cpp +++ b/source/windowing/StarImageStretchWidget.cpp @@ -7,6 +7,12 @@ ImageStretchWidget::ImageStretchWidget(ImageStretchSet const& imageStretchSet, G } +void ImageStretchWidget::setImageStretchSet(String const& beginImage, String const& innerImage, String const& endImage) { + m_imageStretchSet.begin = beginImage; + m_imageStretchSet.inner = innerImage; + m_imageStretchSet.end = endImage; +} + void ImageStretchWidget::renderImpl() { context()->drawImageStretchSet(m_imageStretchSet, RectF(screenBoundRect()), m_direction); } diff --git a/source/windowing/StarImageStretchWidget.hpp b/source/windowing/StarImageStretchWidget.hpp index cdc4f46..c3ade1c 100644 --- a/source/windowing/StarImageStretchWidget.hpp +++ b/source/windowing/StarImageStretchWidget.hpp @@ -9,6 +9,8 @@ STAR_CLASS(ImageStretchWidget); class ImageStretchWidget : public Widget { public: ImageStretchWidget(ImageStretchSet const& imageStretchSet, GuiDirection direction); + void setImageStretchSet(String const& beginImage, String const& innerImage, String const& endImage); + virtual ~ImageStretchWidget() {} protected: diff --git a/source/windowing/StarWidgetLuaBindings.cpp b/source/windowing/StarWidgetLuaBindings.cpp index 89eef00..9ad2186 100644 --- a/source/windowing/StarWidgetLuaBindings.cpp +++ b/source/windowing/StarWidgetLuaBindings.cpp @@ -14,6 +14,7 @@ #include "StarItemSlotWidget.hpp" #include "StarItemDatabase.hpp" #include "StarFlowLayout.hpp" +#include "StarImageStretchWidget.hpp" namespace Star { @@ -452,6 +453,12 @@ LuaCallbacks LuaBindings::makeWidgetCallbacks(Widget* parentWidget, GuiReaderPtr } }); + callbacks.registerCallback("setImageStretchSet", [parentWidget](String const& widgetName, Json const& imageSet) { + if (auto imageStretch = parentWidget->fetchChild<ImageStretchWidget>(widgetName)) { + imageStretch->setImageStretchSet(imageSet.getString("begin", ""), imageSet.getString("inner", ""), imageSet.getString("end", "")); + } + }); + return callbacks; } |