From e9004aa0f9de3cf4d2a84a77d093b870342aa45c Mon Sep 17 00:00:00 2001 From: Alysson Souza Date: Wed, 12 Mar 2008 07:04:07 +0000 Subject: [PATCH] Semi-broken support for colour buttons in auto4-lua Originally committed to SVN as r2026. --- aegisub/auto4_lua_dialog.cpp | 54 ++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/aegisub/auto4_lua_dialog.cpp b/aegisub/auto4_lua_dialog.cpp index b9f395343..7154f9b5f 100644 --- a/aegisub/auto4_lua_dialog.cpp +++ b/aegisub/auto4_lua_dialog.cpp @@ -55,6 +55,7 @@ #include #include #include +#include "colour_button.h" namespace Automation4 { @@ -208,6 +209,56 @@ namespace Automation4 { }; + + class Color : public LuaConfigDialogControl { + public: + wxString text; + + Color(lua_State *L) + : LuaConfigDialogControl(L) + { + lua_getfield(L, -1, "value"); + text = wxString(lua_tostring(L, -1), wxConvUTF8); + lua_pop(L, 1); + } + + virtual ~Color() { } + + bool CanSerialiseValue() + { + return true; + } + + wxString SerialiseValue() + { + return inline_string_encode(text); + } + + void UnserialiseValue(const wxString &serialised) + { + text = inline_string_decode(serialised); + } + + wxControl *Create(wxWindow *parent) + { + cw = new ColourButton(parent, -1, wxSize(50*width,10*height), wxColour(text)); + cw->SetToolTip(hint); + return cw; + } + + void ControlReadBack() + { + text = ((ColourButton*)cw)->GetColour().GetAsString(wxC2S_HTML_SYNTAX); + } + + void LuaReadBack(lua_State *L) + { + lua_pushstring(L, text.mb_str(wxConvUTF8)); + } + + }; + + // Multiline edit @@ -573,8 +624,7 @@ skipbuttons: } else if (controlclass == _T("checkbox")) { ctl = new LuaControl::Checkbox(L); } else if (controlclass == _T("color")) { - // FIXME - ctl = new LuaControl::Edit(L); + ctl = new LuaControl::Color(L); } else if (controlclass == _T("coloralpha")) { // FIXME ctl = new LuaControl::Edit(L);