From 26c7e308edd21c97e0fda8432d66d91c35f9b1b6 Mon Sep 17 00:00:00 2001 From: "glassmancody.info" Date: Mon, 21 Mar 2022 22:00:32 -0700 Subject: [PATCH] mygui bindings for color and alpha --- components/lua_ui/image.cpp | 2 ++ components/lua_ui/widget.cpp | 2 ++ docs/source/reference/lua-scripting/widgets/image.rst | 3 +++ docs/source/reference/lua-scripting/widgets/widget.rst | 8 ++++++++ 4 files changed, 15 insertions(+) diff --git a/components/lua_ui/image.cpp b/components/lua_ui/image.cpp index 7eeca1dc0e..6bcc4a5846 100644 --- a/components/lua_ui/image.cpp +++ b/components/lua_ui/image.cpp @@ -68,6 +68,8 @@ namespace LuaUi atlasCoord.height = textureSize.height; setImageCoord(atlasCoord); + setColour(propertyValue("color", MyGUI::Colour(1,1,1,1))); + WidgetExtension::updateProperties(); } } diff --git a/components/lua_ui/widget.cpp b/components/lua_ui/widget.cpp index a11d3db852..74ac8640e0 100644 --- a/components/lua_ui/widget.cpp +++ b/components/lua_ui/widget.cpp @@ -259,6 +259,8 @@ namespace LuaUi mAnchor = propertyValue("anchor", MyGUI::FloatSize()); mWidget->setVisible(propertyValue("visible", true)); mWidget->setPointer(propertyValue("pointer", std::string("arrow"))); + mWidget->setAlpha(propertyValue("alpha", 1.f)); + mWidget->setInheritsAlpha(propertyValue("inheritAlpha", true)); } void WidgetExtension::updateChildrenCoord() diff --git a/docs/source/reference/lua-scripting/widgets/image.rst b/docs/source/reference/lua-scripting/widgets/image.rst index bd68687cfe..c461a69a65 100644 --- a/docs/source/reference/lua-scripting/widgets/image.rst +++ b/docs/source/reference/lua-scripting/widgets/image.rst @@ -20,3 +20,6 @@ Properties * - tileV - boolean (false) - Tile the texture vertically + * - color + - util.color (1, 1, 1) + - Modulate constant color with the color of the image texture. diff --git a/docs/source/reference/lua-scripting/widgets/widget.rst b/docs/source/reference/lua-scripting/widgets/widget.rst index d114d0957b..99596a6b9b 100644 --- a/docs/source/reference/lua-scripting/widgets/widget.rst +++ b/docs/source/reference/lua-scripting/widgets/widget.rst @@ -35,6 +35,14 @@ Properties * - propagateEvents - boolean (true) - Allows base widget events to propagate to the widget's parent. + * - alpha + - number (1.0) + - | Set the opacity of the widget and its contents. + | If `inheritAlpha` is set to `true`, this becomes the maximum alpha value the widget can take. + * - inheritAlpha + - boolean (true) + - | Modulate `alpha` with parents `alpha`. + | If the parent has `inheritAlpha` set to `true`, the value after modulating is passed to the child. .. TODO: document the mouse pointer property, when API for reading / adding pointer types is available