1 #ifndef SWITCH_H 2 #define SWITCH_H 3 4 #include "panel.h" 5 #include "svg.h" 6 7 #include "../ui.h" 8 9 10 11 #include <stdbool.h> 12 #include <stdint.h> 13 14 typedef struct uiswitch UISWITCH; 15 struct uiswitch { 16 PANEL panel; 17 18 SVG_IMG style_outer; 19 SVG_IMG style_toggle; 20 SVG_IMG style_icon_off; 21 SVG_IMG style_icon_on; 22 23 // Width/height of the toggle and the icons. Used for centering. 24 int toggle_w, toggle_h, icon_off_w, icon_off_h, icon_on_w, icon_on_h; 25 26 // Background RGB color, when Idle/Hovered/Pressed respectively. 27 uint32_t bg_color, // Switch normal background color 28 sw_color, // Switch 'toggle' color 29 hover_color, // Switch mouse over color 30 press_color, // Switch mouse down color 31 disabled_color; // Switch disabled bg color 32 33 MAYBE_I18NAL_STRING tooltip_text; 34 35 bool switch_on; 36 bool mouseover, mousedown, disabled, nodraw; 37 38 void (*onright)(void); // called when right mouse uiswitch goes down 39 void (*on_mup)(void); 40 void (*update)(UISWITCH *s); 41 }; 42 43 void switch_draw(UISWITCH *s, int x, int y, int width, int height); 44 bool switch_mmove(UISWITCH *s, int x, int y, int width, int height, int mx, int my, int dx, int dy); 45 bool switch_mdown(UISWITCH *s); 46 bool switch_mright(UISWITCH *s); 47 bool switch_mwheel(UISWITCH *s, int height, double d, bool smooth); 48 bool switch_mup(UISWITCH *s); 49 bool switch_mleave(UISWITCH *s); 50 void switch_update(UISWITCH *s); 51 52 #endif 53