From: Javier Sancho Date: Sat, 9 May 2020 10:57:34 +0000 (+0200) Subject: gui X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=52befccef863a876940aa575cfa6895506207519;p=guile-irrlicht.git gui --- diff --git a/src/gui-scrollbar.cpp b/src/gui-scrollbar.cpp index c5dbc8a..39dfa36 100644 --- a/src/gui-scrollbar.cpp +++ b/src/gui-scrollbar.cpp @@ -41,6 +41,28 @@ extern "C" { init_gui_scrollbar_type, gui_scrollbar_p, wrap_gui_scrollbar, unwrap_gui_scrollbar); + SCM + irr_gui_setMax (SCM wrapped_obj, + SCM max) + { +#define SET_MAX(OBJ) OBJ->setMax (scm_to_int32 (max)); + + if (gui_editbox_p (wrapped_obj)) + { + SET_MAX (unwrap_gui_editbox (wrapped_obj)); + } + else if (gui_scrollbar_p (wrapped_obj)) + { + SET_MAX (unwrap_gui_scrollbar (wrapped_obj)); + } + else + { + scm_error (scm_arg_type_key, NULL, "Cannot set max to object: ~S", + scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); + } + return SCM_UNSPECIFIED; + } + SCM irr_gui_getPos (SCM wrapped_scrollbar) { diff --git a/src/gui.cpp b/src/gui.cpp index 5a192ec..8b435df 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -21,176 +21,26 @@ #include #include - -#include "color.h" -#include "gsubr.h" #include "gui.h" #include "gui-environment.h" -#include "gui-image.h" #include "gui-in-out-fader.h" #include "gui-listbox.h" #include "gui-scrollbar.h" #include "gui-skin.h" #include "gui-toolbar.h" + extern "C" { void init_gui (void) { - // Init objects init_gui_environment (); - init_gui_image (); init_gui_in_out_fader (); init_gui_listbox (); init_gui_scrollbar (); init_gui_skin (); init_gui_toolbar (); - - // Shared procedures (used by two or more objects) - 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); - } - - SCM - irr_gui_addButton (SCM wrapped_obj, - SCM rectangle, - SCM rest) - { - if (gui_toolbar_p (wrapped_obj)) - { - return irr_gui_IGUIToolBar_addButton (wrapped_obj, rest); - } - else if (gui_environment_p (wrapped_obj)) - { - return irr_gui_IGUIEnvironment_addButton (wrapped_obj, rectangle, rest); - } - else - { - scm_error (scm_arg_type_key, NULL, "Cannot add button to object: ~S", - scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); - } - } - - SCM - irr_gui_getColor (SCM wrapped_obj, - SCM color) - { -#define GET_COLOR(OBJ) scm_from_color (OBJ->getColor ()); - - if (gui_image_p (wrapped_obj)) - { - return GET_COLOR (unwrap_gui_image (wrapped_obj)); - } - else if (gui_in_out_fader_p (wrapped_obj)) - { - return GET_COLOR (unwrap_gui_in_out_fader (wrapped_obj)); - } - else if (gui_skin_p (wrapped_obj)) - { - return irr_gui_IGUISkin_getColor (wrapped_obj, color); - } - else - { - scm_error (scm_arg_type_key, NULL, "Cannot get color from object: ~S", - scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); - } - } - - SCM - irr_gui_getFont (SCM wrapped_obj, - SCM filename, - SCM rest) - { - if (gui_environment_p (wrapped_obj)) - { - return irr_gui_IGUIEnvironment_getFont (wrapped_obj, filename); - } - else if (gui_skin_p (wrapped_obj)) - { - return irr_gui_IGUISkin_getFont (wrapped_obj, rest); - } - else - { - scm_error (scm_arg_type_key, NULL, "Cannot get font from object: ~S", - scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); - } - } - - 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) && dest_color != SCM_UNDEFINED) - { - // 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) - { -#define SET_MAX(OBJ) OBJ->setMax (scm_to_int32 (max)); - - if (gui_editbox_p (wrapped_obj)) - { - SET_MAX (unwrap_gui_editbox (wrapped_obj)); - } - else if (gui_scrollbar_p (wrapped_obj)) - { - SET_MAX (unwrap_gui_scrollbar (wrapped_obj)); - } - else - { - scm_error (scm_arg_type_key, NULL, "Cannot set max to object: ~S", - scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); - } - return SCM_UNSPECIFIED; - } - - SCM - irr_gui_setOverrideColor (SCM wrapped_obj, - SCM color) - { -#define SET_OVERRIDE_COLOR(OBJ) OBJ->setOverrideColor (scm_to_color (color)); - - if (gui_editbox_p (wrapped_obj)) - { - SET_OVERRIDE_COLOR (unwrap_gui_editbox (wrapped_obj)); - } - else if (gui_static_text_p (wrapped_obj)) - { - SET_OVERRIDE_COLOR (unwrap_gui_static_text (wrapped_obj)); - } - else - { - scm_error (scm_arg_type_key, NULL, "Cannot set override color to object: ~S", - scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); - } - return SCM_UNSPECIFIED; } } diff --git a/src/gui.h b/src/gui.h index e713a0a..13b280e 100644 --- a/src/gui.h +++ b/src/gui.h @@ -26,37 +26,8 @@ #include extern "C" { - void init_gui (void); - - SCM - irr_gui_addButton (SCM wrapped_obj, - SCM rectangle, - SCM rest); - - SCM - irr_gui_getColor (SCM wrapped_obj, - SCM color); - - SCM - irr_gui_getFont (SCM wrapped_obj, - 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); - - SCM - irr_gui_setOverrideColor (SCM wrapped_obj, - SCM color); - } #endif