diff options
author | Vladimir Krasheninnikov <boba09@list.ru> | 2025-03-16 14:15:20 +0100 |
---|---|---|
committer | Vladimir Krasheninnikov <boba09@list.ru> | 2025-03-16 14:15:20 +0100 |
commit | 80a500afc9f92514f02a1fd2a8a9b012779f3539 (patch) | |
tree | e2a6d172e7953ecfb85e75b68623b6e06c8ce495 /source/windowing | |
parent | e8309c463d58b2ff8aab2e14a5b1e5f5065cecda (diff) |
Add widget.setImageStretchSet
Diffstat (limited to 'source/windowing')
-rw-r--r-- | source/windowing/StarImageStretchWidget.cpp | 6 | ||||
-rw-r--r-- | source/windowing/StarImageStretchWidget.hpp | 2 | ||||
-rw-r--r-- | source/windowing/StarWidgetLuaBindings.cpp | 7 |
3 files changed, 15 insertions, 0 deletions
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; } |