|
| 1 | +/** |
| 2 | + * MIT License |
| 3 | + * |
| 4 | + * Copyright (c) 2022-2025 Rina Wilk / vokegpu@gmail.com |
| 5 | + * |
| 6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | + * of this software and associated documentation files (the "Software"), to deal |
| 8 | + * in the Software without restriction, including without limitation the rights |
| 9 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | + * copies of the Software, and to permit persons to whom the Software is |
| 11 | + * furnished to do so, subject to the following conditions: |
| 12 | + * |
| 13 | + * The above copyright notice and this permission notice shall be included in all |
| 14 | + * copies or substantial portions of the Software. |
| 15 | + * |
| 16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | + * SOFTWARE. |
| 23 | + */ |
| 24 | +#ifndef EKG_UI_SLIDER_HPP |
| 25 | +#define EKG_UI_SLIDER_HPP |
| 26 | + |
| 27 | +#include "ekg/io/descriptor.hpp" |
| 28 | +#include "ekg/math/geometry.hpp" |
| 29 | + |
| 30 | +namespace ekg { |
| 31 | + struct slider_color_scheme_t { |
| 32 | + public: |
| 33 | + ekg::rgba_t<uint8_t> background {}; |
| 34 | + ekg::rgba_t<uint8_t> outline {}; |
| 35 | + ekg::rgba_t<uint8_t> bar_background {}; |
| 36 | + ekg::rgba_t<uint8_t> bar_highlight {}; |
| 37 | + ekg::rgba_t<uint8_t> bar_active {}; |
| 38 | + ekg::rgba_t<uint8_t> bar_outline {}; |
| 39 | + ekg::rgba_t<uint8_t> text_foreground {}; |
| 40 | + ekg::pixel_thickness_t bar_thickness {25}; |
| 41 | + ekg::pixel_thickness_t bar_target_thickness {25}; |
| 42 | + }; |
| 43 | + |
| 44 | + struct slider_t { |
| 45 | + public: |
| 46 | + struct range { |
| 47 | + protected: |
| 48 | + ekg::value<char[1]> memory_tape_value {}; |
| 49 | + ekg::value<char[8]> memory_tape_minimum_value {}; |
| 50 | + ekg::value<char[8]> memory_tape_maximum_value {}; |
| 51 | + public: |
| 52 | + template<typename t> |
| 53 | + t &value() { |
| 54 | + return ekg::io::any_static_cast<t>( |
| 55 | + this->memory_tape_value.get() |
| 56 | + ); |
| 57 | + } |
| 58 | + |
| 59 | + template<typename t> |
| 60 | + t &value(t *p_ownership_address) { |
| 61 | + this->memory_tape_value.ownership<t>(p_ownership_address); |
| 62 | + return this->value<t>(); |
| 63 | + } |
| 64 | + |
| 65 | + template<typename t> |
| 66 | + t &min() { |
| 67 | + return ekg::io::any_static_cast<t>( |
| 68 | + this->memory_tape_minimum_value.get() |
| 69 | + ); |
| 70 | + } |
| 71 | + |
| 72 | + template<typename t> |
| 73 | + t &min(t *p_ownership_address) { |
| 74 | + this->memory_tape_minimum_value.ownership<t>(p_ownership_address); |
| 75 | + return this->min<t>(); |
| 76 | + } |
| 77 | + |
| 78 | + template<typename t> |
| 79 | + t &max() { |
| 80 | + return ekg::io::any_static_cast<t>( |
| 81 | + this->memory_tape_maximum_value.get() |
| 82 | + ); |
| 83 | + } |
| 84 | + |
| 85 | + template<typename t> |
| 86 | + t &max(t *p_ownership_address) { |
| 87 | + this->memory_tape_maximum_value.ownership<t>(p_ownership_address); |
| 88 | + return this->max<t>(); |
| 89 | + } |
| 90 | + }; |
| 91 | + public: |
| 92 | + static constexpr ekg::type type {ekg::type::slider}; |
| 93 | + static ekg::slider_t not_found; |
| 94 | + public: |
| 95 | + ekg::at_t property_at {}; |
| 96 | + public: |
| 97 | + std::string tag {}; |
| 98 | + ekg::rect_t<float> rect {}; |
| 99 | + ekg::flags_t dock {}; |
| 100 | + std::vector<ekg::slider_t::range> ranges {}; |
| 101 | + ekg::slider_color_scheme_t color_scheme {}; |
| 102 | + public: |
| 103 | + ekg_descriptor(ekg::slider_t); |
| 104 | + }; |
| 105 | +} |
| 106 | + |
| 107 | +#endif |
0 commit comments