From 65527be1c7ad3f05ba651c25249fd8300f5f4fad Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Sat, 25 Apr 2020 08:38:13 +0200 Subject: [PATCH] set-color! --- src/gui-in-out-fader.cpp | 19 +++++++++++++++++++ src/gui-in-out-fader.h | 5 +++++ src/gui-skin.cpp | 11 +++++++++++ src/gui-skin.h | 5 +++++ src/gui.cpp | 29 +++++++++++++++++++++++++++++ src/gui.h | 5 +++++ 6 files changed, 74 insertions(+) diff --git a/src/gui-in-out-fader.cpp b/src/gui-in-out-fader.cpp index 35dafe6..fb8a9e3 100644 --- a/src/gui-in-out-fader.cpp +++ b/src/gui-in-out-fader.cpp @@ -22,6 +22,7 @@ #include #include +#include "color.h" #include "gui-in-out-fader.h" #include "wrapped.h" @@ -37,4 +38,22 @@ extern "C" { init_gui_in_out_fader_type, gui_in_out_fader_p, wrap_gui_in_out_fader, unwrap_gui_in_out_fader); + SCM + irr_gui_IGUIInOutFader_setColor (SCM wrapped_in_out_fader, + SCM color, + SCM dest_color) + { + irr::gui::IGUIInOutFader* fader = unwrap_gui_in_out_fader (wrapped_in_out_fader); + if (scm_is_false (dest_color)) + { + fader->setColor (scm_to_color (color)); + } + else + { + fader->setColor (scm_to_color (color), + scm_to_color (dest_color)); + } + return SCM_UNSPECIFIED; + } + } diff --git a/src/gui-in-out-fader.h b/src/gui-in-out-fader.h index a6762ff..ee79962 100644 --- a/src/gui-in-out-fader.h +++ b/src/gui-in-out-fader.h @@ -34,6 +34,11 @@ extern "C" { DECLARE_WRAPPED_TYPE (irr::gui::IGUIInOutFader*, init_gui_in_out_fader_type, gui_in_out_fader_p, wrap_gui_in_out_fader, unwrap_gui_in_out_fader); + SCM + irr_gui_IGUIInOutFader_setColor (SCM wrapped_in_out_fader, + SCM color, + SCM dest_color); + } #endif diff --git a/src/gui-skin.cpp b/src/gui-skin.cpp index a5bfe26..019dfdf 100644 --- a/src/gui-skin.cpp +++ b/src/gui-skin.cpp @@ -65,6 +65,17 @@ extern "C" { return wrap_gui_font (font); } + SCM + irr_gui_IGUISkin_setColor (SCM wrapped_gui_skin, + SCM which, + SCM new_color) + { + irr::gui::IGUISkin* skin = unwrap_gui_skin (wrapped_gui_skin); + skin->setColor (scm_to_default_color (which), + scm_to_color (new_color)); + return SCM_UNSPECIFIED; + } + SCM irr_gui_setFont (SCM wrapped_gui_skin, SCM font, diff --git a/src/gui-skin.h b/src/gui-skin.h index b4ec4c5..d269016 100644 --- a/src/gui-skin.h +++ b/src/gui-skin.h @@ -42,6 +42,11 @@ extern "C" { irr_gui_IGUISkin_getFont (SCM wrapped_gui_skin, SCM rest); + SCM + irr_gui_IGUISkin_setColor (SCM wrapped_gui_skin, + SCM which, + SCM new_color); + SCM irr_gui_setFont (SCM wrapped_gui_skin, SCM font, diff --git a/src/gui.cpp b/src/gui.cpp index 6068f3a..c507f1d 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -59,6 +59,7 @@ extern "C" { DEFINE_GSUBR ("add-button!", 1, 1, 1, irr_gui_addButton); DEFINE_GSUBR ("get-color", 1, 1, 0, irr_gui_getColor); DEFINE_GSUBR ("get-font", 1, 1, 1, irr_gui_getFont); + DEFINE_GSUBR ("set-color!", 2, 1, 0, irr_gui_setColor); DEFINE_GSUBR ("set-max!", 2, 0, 0, irr_gui_setMax); DEFINE_GSUBR ("set-override-color!", 2, 0, 0, irr_gui_setOverrideColor); } @@ -128,6 +129,34 @@ extern "C" { } } + SCM + irr_gui_setColor (SCM wrapped_obj, + SCM color, + SCM dest_color) + { + if (gui_image_p (wrapped_obj)) + { + // Params: color + unwrap_gui_image (wrapped_obj)->setColor (scm_to_color (color)); + return SCM_UNSPECIFIED; + } + else if (gui_in_out_fader_p (wrapped_obj)) + { + // Params: color and dest_color (optional) + return irr_gui_IGUIInOutFader_setColor (wrapped_obj, color, dest_color); + } + else if (gui_skin_p (wrapped_obj) && !scm_is_false (dest_color)) + { + // Params: which and new_color + return irr_gui_IGUISkin_setColor (wrapped_obj, color, dest_color); + } + else + { + scm_error (scm_arg_type_key, NULL, "Cannot set color to object: ~S", + scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); + } + } + SCM irr_gui_setMax (SCM wrapped_obj, SCM max) diff --git a/src/gui.h b/src/gui.h index d7ccd7d..e713a0a 100644 --- a/src/gui.h +++ b/src/gui.h @@ -44,6 +44,11 @@ extern "C" { SCM filename, SCM rest); + SCM + irr_gui_setColor (SCM wrapped_obj, + SCM color, + SCM dest_color); + SCM irr_gui_setMax (SCM wrapped_obj, SCM max); -- 2.39.2