| 7 | namespace recompui { |
| 8 | |
| 9 | Toggle::Toggle(Element *parent) : Element(parent, Events(EventType::Click, EventType::Focus, EventType::Hover, EventType::Enable), "button") { |
| 10 | enable_focus(); |
| 11 | |
| 12 | set_width(162.0f); |
| 13 | set_height(72.0f); |
| 14 | set_border_radius(36.0f); |
| 15 | set_opacity(0.9f); |
| 16 | set_cursor(Cursor::Pointer); |
| 17 | set_border_width(2.0f); |
| 18 | set_border_color(Color{ 177, 76, 34, 255 }); |
| 19 | set_background_color(Color{ 0, 0, 0, 0 }); |
| 20 | checked_style.set_border_color(Color{ 34, 177, 76, 255 }); |
| 21 | hover_style.set_border_color(Color{ 177, 76, 34, 255 }); |
| 22 | hover_style.set_background_color(Color{ 206, 120, 68, 76 }); |
| 23 | focus_style.set_border_color(Color{ 177, 76, 34, 255 }); |
| 24 | focus_style.set_background_color(Color{ 206, 120, 68, 76 }); |
| 25 | checked_hover_style.set_border_color(Color{ 34, 177, 76, 255 }); |
| 26 | checked_hover_style.set_background_color(Color{ 68, 206, 120, 76 }); |
| 27 | checked_focus_style.set_border_color(Color{ 34, 177, 76, 255 }); |
| 28 | checked_focus_style.set_background_color(Color{ 68, 206, 120, 76 }); |
| 29 | disabled_style.set_border_color(Color{ 177, 76, 34, 128 }); |
| 30 | checked_disabled_style.set_border_color(Color{ 34, 177, 76, 128 }); |
| 31 | add_style(&checked_style, checked_state); |
| 32 | add_style(&hover_style, hover_state); |
| 33 | add_style(&focus_style, focus_state); |
| 34 | add_style(&checked_hover_style, { checked_state, hover_state }); |
| 35 | add_style(&checked_focus_style, { checked_state, focus_state }); |
| 36 | add_style(&disabled_style, disabled_state); |
| 37 | add_style(&checked_disabled_style, { checked_state, disabled_state }); |
| 38 | |
| 39 | ContextId context = get_current_context(); |
| 40 | |
| 41 | floater = context.create_element<Element>(this); |
| 42 | floater->set_position(Position::Relative); |
| 43 | floater->set_top(2.0f); |
| 44 | floater->set_width(80.0f); |
| 45 | floater->set_height(64.0f); |
| 46 | floater->set_border_radius(32.0f); |
| 47 | floater->set_background_color(Color{ 177, 76, 34, 255 }); |
| 48 | floater_checked_style.set_background_color(Color{ 34, 177, 76, 255 }); |
| 49 | floater_disabled_style.set_background_color(Color{ 177, 76, 34, 128 }); |
| 50 | floater_disabled_checked_style.set_background_color(Color{ 34, 177, 76, 128 }); |
| 51 | floater->add_style(&floater_checked_style, checked_state); |
| 52 | floater->add_style(&floater_disabled_style, disabled_state); |
| 53 | floater->add_style(&floater_disabled_checked_style, { checked_state, disabled_state }); |
| 54 | |
| 55 | set_checked_internal(false, false, true, false); |
| 56 | } |
| 57 | |
| 58 | void Toggle::set_checked_internal(bool checked, bool animate, bool setup, bool trigger_callbacks) { |
| 59 | if (this->checked != checked || setup) { |
nothing calls this directly
no test coverage detected