From: Javier Sancho Date: Sun, 10 May 2020 06:55:16 +0000 (+0200) Subject: gui-skin X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=79089024921211289013205616d5706eb0132981;p=guile-irrlicht.git gui-skin --- diff --git a/src/gui-skin.cpp b/src/gui-skin.cpp index 019dfdf..b6e0ae1 100644 --- a/src/gui-skin.cpp +++ b/src/gui-skin.cpp @@ -21,217 +21,210 @@ #include #include - #include "color.h" #include "gsubr.h" -#include "gui-font.h" #include "gui-skin.h" -#include "wrapped.h" -extern "C" { - void - init_gui_skin (void) - { - init_gui_skin_type (); - DEFINE_GSUBR ("set-font!", 2, 0, 1, irr_gui_setFont); - } +using namespace irr; - DEFINE_WRAPPED_TYPE (irr::gui::IGUISkin*, "gui-skin", - init_gui_skin_type, gui_skin_p, - wrap_gui_skin, unwrap_gui_skin); - SCM - irr_gui_IGUISkin_getColor (SCM wrapped_gui_skin, - SCM color) - { - irr::gui::IGUISkin* skin = unwrap_gui_skin (wrapped_gui_skin); - irr::video::SColor scolor = skin->getColor (scm_to_default_color (color)); - return scm_from_color (scolor); - } +SCM +irr_gui_IGUISkin_getColor (SCM gui_skin, + SCM color) +{ + gui::IGUISkin* skin = (gui::IGUISkin*) scm_to_pointer (gui_skin); + video::SColor scolor = skin->getColor (scm_to_default_color (color)); + return scm_from_color (scolor); +} - SCM - irr_gui_IGUISkin_getFont (SCM wrapped_gui_skin, - SCM rest) - { - SCM which = scm_from_utf8_symbol ("default"); - scm_c_bind_keyword_arguments ("get-font", rest, (scm_t_keyword_arguments_flags)0, - scm_from_utf8_keyword ("which"), &which, - SCM_UNDEFINED); +SCM +irr_gui_IGUISkin_getFont (SCM gui_skin, + SCM which) +{ + gui::IGUISkin* skin = (gui::IGUISkin*) scm_to_pointer (gui_skin); + gui::IGUIFont* font = skin->getFont (scm_to_default_font (which)); + return scm_from_pointer ((void*) font, NULL); +} - irr::gui::IGUISkin* skin = unwrap_gui_skin (wrapped_gui_skin); - irr::gui::IGUIFont* font = skin->getFont (scm_to_default_font (which)); - 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_IGUISkin_setColor (SCM gui_skin, + SCM which, + SCM new_color) +{ + gui::IGUISkin* skin = (gui::IGUISkin*) scm_to_pointer (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, - SCM rest) - { - SCM which = scm_from_utf8_symbol ("default"); - scm_c_bind_keyword_arguments ("set-font!", rest, (scm_t_keyword_arguments_flags)0, - scm_from_utf8_keyword ("which"), &which, - SCM_UNDEFINED); +SCM +irr_gui_IGUISkin_setFont (SCM gui_skin, + SCM font, + SCM which) +{ + gui::IGUISkin* skin = (gui::IGUISkin*) scm_to_pointer (gui_skin); + skin->setFont ((gui::IGUIFont*) scm_to_pointer (font), + scm_to_default_font (which)); + return SCM_UNSPECIFIED; +} - irr::gui::IGUISkin* skin = unwrap_gui_skin (wrapped_gui_skin); - skin->setFont (unwrap_gui_font (font), - scm_to_default_font (which)); - return SCM_UNSPECIFIED; - } - irr::gui::EGUI_DEFAULT_COLOR - scm_to_default_color (SCM default_color) - { - char* color = scm_to_utf8_stringn (scm_symbol_to_string (default_color), NULL); - if (!strcmp (color, "3d-dark-shadow")) - { - return irr::gui::EGDC_3D_DARK_SHADOW; - } - else if (!strcmp (color, "3d-shadow")) - { - return irr::gui::EGDC_3D_SHADOW; - } - else if (!strcmp (color, "3d-face")) - { - return irr::gui::EGDC_3D_FACE; - } - else if (!strcmp (color, "3d-high-light")) - { - return irr::gui::EGDC_3D_HIGH_LIGHT; - } - else if (!strcmp (color, "3d-light")) - { - return irr::gui::EGDC_3D_LIGHT; - } - else if (!strcmp (color, "active-border")) - { - return irr::gui::EGDC_ACTIVE_BORDER; - } - else if (!strcmp (color, "active-caption")) - { - return irr::gui::EGDC_ACTIVE_CAPTION; - } - else if (!strcmp (color, "app-workspace")) - { - return irr::gui::EGDC_APP_WORKSPACE; - } - else if (!strcmp (color, "button-text")) - { - return irr::gui::EGDC_BUTTON_TEXT; - } - else if (!strcmp (color, "gray-text")) - { - return irr::gui::EGDC_GRAY_TEXT; - } - else if (!strcmp (color, "high-light")) - { - return irr::gui::EGDC_HIGH_LIGHT; - } - else if (!strcmp (color, "high-light-text")) - { - return irr::gui::EGDC_HIGH_LIGHT_TEXT; - } - else if (!strcmp (color, "inactive-border")) - { - return irr::gui::EGDC_INACTIVE_BORDER; - } - else if (!strcmp (color, "inactive-caption")) - { - return irr::gui::EGDC_INACTIVE_CAPTION; - } - else if (!strcmp (color, "tooltip")) - { - return irr::gui::EGDC_TOOLTIP; - } - else if (!strcmp (color, "tooltip-background")) - { - return irr::gui::EGDC_TOOLTIP_BACKGROUND; - } - else if (!strcmp (color, "scrollbar")) - { - return irr::gui::EGDC_SCROLLBAR; - } - else if (!strcmp (color, "window")) - { - return irr::gui::EGDC_WINDOW; - } - else if (!strcmp (color, "window-symbol")) - { - return irr::gui::EGDC_WINDOW_SYMBOL; - } - else if (!strcmp (color, "icon")) - { - return irr::gui::EGDC_ICON; - } - else if (!strcmp (color, "icon-high-light")) - { - return irr::gui::EGDC_ICON_HIGH_LIGHT; - } - else if (!strcmp (color, "gray-window-symbol")) - { - return irr::gui::EGDC_GRAY_WINDOW_SYMBOL; - } - else if (!strcmp (color, "editable")) - { - return irr::gui::EGDC_EDITABLE; - } - else if (!strcmp (color, "gray-editable")) - { - return irr::gui::EGDC_GRAY_EDITABLE; - } - else if (!strcmp (color, "focused-editable")) - { - return irr::gui::EGDC_FOCUSED_EDITABLE; - } - else - { - scm_error (scm_arg_type_key, NULL, "Wrong default color: ~S", - scm_list_1 (default_color), scm_list_1 (default_color)); - } - } +extern "C" { - irr::gui::EGUI_DEFAULT_FONT - scm_to_default_font (SCM default_font) + void + init_gui_skin (void) { - char* font = scm_to_utf8_stringn (scm_symbol_to_string (default_font), NULL); - if (!strcmp (font, "default")) - { - return irr::gui::EGDF_DEFAULT; - } - else if (!strcmp (font, "button")) - { - return irr::gui::EGDF_BUTTON; - } - else if (!strcmp (font, "window")) - { - return irr::gui::EGDF_WINDOW; - } - else if (!strcmp (font, "menu")) - { - return irr::gui::EGDF_MENU; - } - else if (!strcmp (font, "tooltip")) - { - return irr::gui::EGDF_TOOLTIP; - } - else - { - scm_error (scm_arg_type_key, NULL, "Wrong default font: ~S", - scm_list_1 (default_font), scm_list_1 (default_font)); - } + DEFINE_GSUBR ("irr_gui_IGUISkin_getColor", 2, 0, 0, irr_gui_IGUISkin_getColor); + DEFINE_GSUBR ("irr_gui_IGUISkin_getFont", 2, 0, 0, irr_gui_IGUISkin_getFont); + DEFINE_GSUBR ("irr_gui_IGUISkin_setColor", 3, 0, 0, irr_gui_IGUISkin_setColor); + DEFINE_GSUBR ("irr_gui_IGUISkin_setFont", 3, 0, 0, irr_gui_IGUISkin_setFont); } + +} + +gui::EGUI_DEFAULT_COLOR +scm_to_default_color (SCM default_color) +{ + char* color = scm_to_utf8_stringn (scm_symbol_to_string (default_color), NULL); + if (!strcmp (color, "3d-dark-shadow")) + { + return gui::EGDC_3D_DARK_SHADOW; + } + else if (!strcmp (color, "3d-shadow")) + { + return gui::EGDC_3D_SHADOW; + } + else if (!strcmp (color, "3d-face")) + { + return gui::EGDC_3D_FACE; + } + else if (!strcmp (color, "3d-high-light")) + { + return gui::EGDC_3D_HIGH_LIGHT; + } + else if (!strcmp (color, "3d-light")) + { + return gui::EGDC_3D_LIGHT; + } + else if (!strcmp (color, "active-border")) + { + return gui::EGDC_ACTIVE_BORDER; + } + else if (!strcmp (color, "active-caption")) + { + return gui::EGDC_ACTIVE_CAPTION; + } + else if (!strcmp (color, "app-workspace")) + { + return gui::EGDC_APP_WORKSPACE; + } + else if (!strcmp (color, "button-text")) + { + return gui::EGDC_BUTTON_TEXT; + } + else if (!strcmp (color, "gray-text")) + { + return gui::EGDC_GRAY_TEXT; + } + else if (!strcmp (color, "high-light")) + { + return gui::EGDC_HIGH_LIGHT; + } + else if (!strcmp (color, "high-light-text")) + { + return gui::EGDC_HIGH_LIGHT_TEXT; + } + else if (!strcmp (color, "inactive-border")) + { + return gui::EGDC_INACTIVE_BORDER; + } + else if (!strcmp (color, "inactive-caption")) + { + return gui::EGDC_INACTIVE_CAPTION; + } + else if (!strcmp (color, "tooltip")) + { + return gui::EGDC_TOOLTIP; + } + else if (!strcmp (color, "tooltip-background")) + { + return gui::EGDC_TOOLTIP_BACKGROUND; + } + else if (!strcmp (color, "scrollbar")) + { + return gui::EGDC_SCROLLBAR; + } + else if (!strcmp (color, "window")) + { + return gui::EGDC_WINDOW; + } + else if (!strcmp (color, "window-symbol")) + { + return gui::EGDC_WINDOW_SYMBOL; + } + else if (!strcmp (color, "icon")) + { + return gui::EGDC_ICON; + } + else if (!strcmp (color, "icon-high-light")) + { + return gui::EGDC_ICON_HIGH_LIGHT; + } + else if (!strcmp (color, "gray-window-symbol")) + { + return gui::EGDC_GRAY_WINDOW_SYMBOL; + } + else if (!strcmp (color, "editable")) + { + return gui::EGDC_EDITABLE; + } + else if (!strcmp (color, "gray-editable")) + { + return gui::EGDC_GRAY_EDITABLE; + } + else if (!strcmp (color, "focused-editable")) + { + return gui::EGDC_FOCUSED_EDITABLE; + } + else + { + scm_error (scm_arg_type_key, NULL, "Wrong default color: ~S", + scm_list_1 (default_color), scm_list_1 (default_color)); + } +} + + +gui::EGUI_DEFAULT_FONT +scm_to_default_font (SCM default_font) +{ + char* font = scm_to_utf8_stringn (scm_symbol_to_string (default_font), NULL); + if (!strcmp (font, "default")) + { + return gui::EGDF_DEFAULT; + } + else if (!strcmp (font, "button")) + { + return gui::EGDF_BUTTON; + } + else if (!strcmp (font, "window")) + { + return gui::EGDF_WINDOW; + } + else if (!strcmp (font, "menu")) + { + return gui::EGDF_MENU; + } + else if (!strcmp (font, "tooltip")) + { + return gui::EGDF_TOOLTIP; + } + else + { + scm_error (scm_arg_type_key, NULL, "Wrong default font: ~S", + scm_list_1 (default_font), scm_list_1 (default_font)); + } } diff --git a/src/gui-skin.h b/src/gui-skin.h index d269016..6b3a3d8 100644 --- a/src/gui-skin.h +++ b/src/gui-skin.h @@ -24,40 +24,16 @@ #include #include -#include "wrapped.h" extern "C" { - void init_gui_skin (void); +} - DECLARE_WRAPPED_TYPE (irr::gui::IGUISkin*, init_gui_skin_type, - gui_skin_p, wrap_gui_skin, unwrap_gui_skin); - - SCM - irr_gui_IGUISkin_getColor (SCM wrapped_gui_skin, - SCM color); - - SCM - 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, - SCM rest); - - irr::gui::EGUI_DEFAULT_COLOR - scm_to_default_color (SCM default_color); - - irr::gui::EGUI_DEFAULT_FONT - scm_to_default_font (SCM default_font); +irr::gui::EGUI_DEFAULT_COLOR +scm_to_default_color (SCM default_color); -} +irr::gui::EGUI_DEFAULT_FONT +scm_to_default_font (SCM default_font); #endif