]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
set-color!
authorJavier Sancho <jsf@jsancho.org>
Sat, 25 Apr 2020 06:38:13 +0000 (08:38 +0200)
committerJavier Sancho <jsf@jsancho.org>
Sat, 25 Apr 2020 06:38:13 +0000 (08:38 +0200)
src/gui-in-out-fader.cpp
src/gui-in-out-fader.h
src/gui-skin.cpp
src/gui-skin.h
src/gui.cpp
src/gui.h

index 35dafe62e7232bc179feadc07f5dd789d055687c..fb8a9e3b512fd539ea858890c429ce71a3576b0b 100644 (file)
@@ -22,6 +22,7 @@
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
 
+#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;
+  }
+
 }
index a6762ff23bb987e84fcc7efdd79408088d0dea46..ee799626c0313793f599f2a40412213c32c37fd3 100644 (file)
@@ -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
index a5bfe2630873709ca0391a8a15685588db92f552..019dfdf4696747447ce479051fd2db011a64bdab 100644 (file)
@@ -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,
index b4ec4c515252a8702e816f7dc81696545f3989be..d2690167318a76ff8144164bee3e970f3dcdd9d3 100644 (file)
@@ -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,
index 6068f3a7eea71546811237d4dc7f20b1a92d7921..c507f1d73f73c49f1bb836e1fa5603bf369f896c 100644 (file)
@@ -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)
index d7ccd7d2ae061a42d9a9e8f5b12e0d3f33814821..e713a0a3ef04a32d2d316f81ef59e102ab611aab 100644 (file)
--- 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);