219 #ifndef ZENI_WIDGET_H
220 #define ZENI_WIDGET_H
241 class Widget_Render_Function;
245 Widget & operator=(
const Widget &);
251 inline const bool & is_busy()
const;
252 inline const bool & is_editable()
const;
253 inline const float & get_layer()
const;
254 inline void set_busy(
const bool &busy_);
255 virtual void set_editable(
const bool &editable_);
256 inline void set_layer(
const float &layer_ = 0.0
f);
264 #if SDL_VERSION_ATLEAST(2,0,0)
273 virtual void on_mouse_button(
const Point2i &pos,
const bool &down,
const int &button) = 0;
274 virtual void on_mouse_motion(
const Point2i &pos) = 0;
275 #if SDL_VERSION_ATLEAST(2,0,0)
276 virtual void on_mouse_wheel(
const Point2i &pos,
const int &up) = 0;
281 inline void render()
const;
288 virtual void render_impl()
const;
296 bool delete_m_renderer;
303 virtual void render_to(
const Widget &widget) = 0;
308 template <
typename T1,
typename T2>
312 const T2 *
const &second_,
const bool &delete_second_);
315 inline const T1 *
const &
first()
const;
316 inline const T2 *
const &
second()
const;
317 inline T1 *
const &
first();
318 inline T2 *
const &
second();
329 bool delete_m_second;
332 template <
typename T1,
typename T2>
334 const T2 *
const &second_,
const bool &delete_second_);
341 virtual void render_to(
const Widget &widget);
355 virtual void render_to(
const Widget &widget);
372 virtual void render_to(
const Widget &widget);
387 const Color &text_normal_,
const Color &text_clicked_,
const Color &text_hovered_strayed_);
390 virtual void render_to(
const Widget &widget);
408 virtual void render_to(
const Widget &widget);
422 virtual void render_to(
const Widget &widget);
435 inline const Point2f & get_upper_left()
const;
436 inline Point2f get_lower_left()
const;
437 inline const Point2f & get_lower_right()
const;
438 inline Point2f get_upper_right()
const;
440 virtual void set_upper_left(
const Point2f &upper_left_);
441 virtual void set_lower_right(
const Point2f &lower_right_);
443 inline float get_height()
const;
444 inline float get_width()
const;
445 inline Point2f get_center()
const;
447 inline bool is_inside(
const Point2i &pos)
const;
456 Widget_Button & operator=(
const Widget_Button &);
459 enum State {NORMAL, CLICKED, HOVERED, STRAYED, UNACTIONABLE};
461 inline Widget_Button(
const Point2f &upper_left_,
const Point2f &lower_right_);
463 inline const State & get_State()
const;
465 virtual void on_mouse_button(
const Point2i &pos,
const bool &down,
const int &button);
466 virtual void on_mouse_motion(
const Point2i &pos);
467 #if SDL_VERSION_ATLEAST(2,0,0)
468 virtual void on_mouse_wheel(
const Point2i &pos,
const int &up);
494 Text_Button & operator=(
const Text_Button &);
497 inline Text_Button(
const Point2f &upper_left_,
const Point2f &lower_right_,
503 Check_Box & operator=(
const Check_Box &);
506 inline Check_Box(
const Point2f &upper_left_,
const Point2f &lower_right_,
507 const bool &checked_ =
false,
const bool &toggleable_ =
true);
509 inline const bool & is_checked()
const;
510 inline void set_checked(
const bool &checked_);
511 inline const bool & is_toggling()
const;
513 virtual void on_accept();
515 virtual void on_click();
516 virtual void on_unstray();
518 virtual void on_reject();
519 virtual void on_stray();
529 Radio_Button_Set & operator=(
const Radio_Button_Set &);
536 virtual void on_mouse_button(
const Point2i &pos,
const bool &down,
const int &button);
537 virtual void on_mouse_motion(
const Point2i &pos);
542 virtual void render_impl()
const;
545 inline void lend_Radio_Button(
Radio_Button &radio_button);
546 inline void unlend_Radio_Button(
Radio_Button &radio_button);
549 #pragma warning( push )
550 #pragma warning( disable : 4251 )
552 std::set<Radio_Button *> m_radio_buttons;
554 #pragma warning( pop )
560 Radio_Button & operator=(
const Radio_Button &);
567 const bool &checked_ =
false,
const bool &toggleable_ =
true);
568 inline ~Radio_Button();
570 virtual void on_accept();
578 Slider & operator=(
const Slider &);
582 const float &slider_radius_,
585 inline Point2f get_end_point_a()
const;
586 inline Point2f get_end_point_b()
const;
587 inline const float & get_slider_radius()
const;
588 inline const float & get_slider_position()
const;
590 inline void set_end_points(
const Point2f &end_point_a_,
const Point2f &end_point_b_);
591 inline void set_slider_radius(
const float &radius_);
592 inline void set_slider_position(
const float &slider_position_);
594 virtual void on_mouse_button(
const Point2i &pos,
const bool &down,
const int &button);
595 virtual void on_mouse_motion(
const Point2i &pos);
596 #if SDL_VERSION_ATLEAST(2,0,0)
597 virtual void on_mouse_wheel(
const Point2i &pos,
const int &up);
600 virtual void on_slide();
601 virtual void on_accept();
603 inline const bool & is_mouse_wheel_inverted()
const;
604 inline void invert_mouse_wheel(
const bool &
invert);
606 inline const float & get_mouse_wheel_continuous_rate()
const;
607 inline void set_mouse_wheel_continuous_rate(
const float &mouse_wheel_continuous_rate);
614 float m_slider_radius;
616 bool m_mouse_wheel_inverted;
617 float m_mouse_wheel_continuous_rate;
619 float m_slider_position;
620 float m_backup_position;
626 Slider_Int & operator=(
const Slider_Int &);
633 const float &slider_radius_,
636 inline const Range & get_range()
const;
637 inline void set_range(
const Range &range_);
639 inline int get_value()
const;
640 inline void set_value(
const int &
value);
642 virtual void on_slide();
643 #if SDL_VERSION_ATLEAST(2,0,0)
644 virtual void on_mouse_wheel(
const Point2i &pos,
const int &up);
646 virtual void on_mouse_button(
const Point2i &pos,
const bool &down,
const int &button);
651 #pragma warning( push )
652 #pragma warning( disable : 4251 )
656 #pragma warning( pop )
662 Selector & operator=(
const Selector &);
664 class ZENI_REST_DLL Normal_Button :
public Text_Button {
665 Normal_Button(
const Normal_Button &);
666 Normal_Button & operator=(
const Normal_Button &);
669 Normal_Button(Selector &selector,
676 Selector * m_selector;
679 class ZENI_REST_DLL Selector_Button :
public Text_Button {
680 Selector_Button(
const Selector_Button &);
681 Selector_Button & operator=(
const Selector_Button &);
684 Selector_Button(Selector &selector,
692 Selector * m_selector;
696 Selector_Slider(
const Selector_Slider &);
697 Selector_Slider & operator=(
const Selector_Slider &);
700 Selector_Slider(Selector &selector,
701 const float &slider_radius_,
702 const std::pair<float, float> &bg_coordinates_);
704 void set_end_points(
const Point2f &end_point_a_,
const Point2f &end_point_b_);
708 void render_impl()
const;
711 Selector * m_selector;
718 const Point2f &expanded_upper_left_,
const Point2f &expanded_lower_right_,
722 const Options & get_options()
const;
727 String get_selected()
const;
730 virtual void on_mouse_button(
const Point2i &pos,
const bool &down,
const int &button);
731 virtual void on_mouse_motion(
const Point2i &pos);
732 #if SDL_VERSION_ATLEAST(2,0,0)
733 virtual void on_mouse_wheel(
const Point2i &pos,
const int &up);
738 virtual void render_impl()
const;
755 inline const String & get_Font()
const;
756 inline void set_font(
const String &font_);
764 float button_height()
const;
765 float vertical_offset()
const;
767 void decide_visible(
const size_t ¢ered);
769 std::pair<Point2f, Point2f> visible_region()
const;
773 void build_selector_buttons();
778 bool delete_m_button_renderer;
780 bool delete_m_slider_renderer;
782 bool delete_m_slider_bg_renderer;
788 #pragma warning( push )
789 #pragma warning( disable : 4251 )
793 #pragma warning( pop )
799 Normal_Button m_normal_button;
801 #pragma warning( push )
802 #pragma warning( disable : 4251 )
804 std::vector<Selector_Button *> m_selector_buttons;
806 #pragma warning( pop )
808 Selector_Slider m_selector_slider;
818 Text_Box & operator=(
const Text_Box &);
829 virtual void on_key(
const SDL_Keysym &keysym,
const bool &down);
832 virtual void on_mouse_button(
const Point2i &pos,
const bool &down,
const int &button);
833 virtual void on_accept();
835 virtual void on_focus();
836 virtual void on_unfocus();
837 virtual void on_change();
839 inline const String & get_font_name()
const;
840 inline const Font & get_Font()
const;
841 inline const String & get_text()
const;
842 inline const Color & get_text_color()
const;
843 inline const JUSTIFY & get_justify()
const;
844 inline size_t get_num_lines()
const;
845 inline size_t get_max_lines()
const;
847 virtual void set_editable(
const bool &editable_);
848 virtual void set_upper_left(
const Point2f &upper_left_);
849 virtual void set_lower_right(
const Point2f &lower_right_);
850 inline void set_font_name(
const String &font_name_);
851 inline void set_text(
const String &text_);
852 inline void set_text_color(
const Color &text_color_);
853 inline void set_justify(
const JUSTIFY &justify_);
854 inline void erase_lines(
const unsigned int &begin,
const unsigned int &
end);
856 const int & get_edit_pos()
const;
857 int get_cursor_pos()
const;
858 int get_max_seek()
const;
859 int get_max_cursor_seek()
const;
861 void seek(
const int &edit_pos);
862 void seek_cursor(
const int &cursor_pos);
863 void set_focus(
const bool &
value);
865 virtual void render_impl()
const;
878 struct ZENI_REST_DLL Word {
879 enum Type {NONSENSE = 0x0, WORD = 0x1, SPACE = 0x2};
881 Word(
const Type &type_ = NONSENSE) : unformatted_glyph_sides(1, 0),
type(type_), splittable(
false), fpsplit(
false) {}
885 #pragma warning( push )
886 #pragma warning( disable : 4251 )
888 std::vector<float> unformatted_glyph_sides;
890 #pragma warning( pop )
897 struct ZENI_REST_DLL Line :
public Word {
898 Line() : glyph_top(0), endled(
false) {}
906 void append_word(
const Word &word);
909 bool delete_m_bg_renderer;
912 String clean_string(
const String &unclean_string)
const;
914 float get_text_width(
const Font &font,
const String &text);
915 float max_line_width()
const;
917 inline void invalidate_edit_pos();
920 #pragma warning( push )
921 #pragma warning( disable : 4251 )
923 std::vector<Line> m_lines;
925 #pragma warning( pop )
938 static void reformat_all();
942 #pragma warning( push )
943 #pragma warning( disable : 4251 )
950 Reinit * duplicate()
const {
959 Reinit(
const Reinit &);
960 Reinit operator=(
const Reinit &);
963 #pragma warning( pop )
966 static std::set<Text_Box *> & get_text_boxes();
971 Widget_Input_Repeater & operator=(
const Widget_Input_Repeater &);
975 inline Widget_Input_Repeater(
Widget &widget_,
979 inline Widget *
const & get_widget()
const;
980 inline const int & get_repeat_delay()
const;
981 inline const int & get_repeat_interval()
const ;
983 inline void set_widget(
Widget &widget_);
988 virtual void on_key(
const SDL_Keysym &keysym,
const bool &down);
993 virtual void on_mouse_button(
const Point2i &pos,
const bool &down,
const int &button);
995 virtual void on_mouse_motion(
const Point2i &pos);
998 virtual void perform_logic();
1001 virtual void render_impl()
const;
1011 int m_repeat_interval;
1013 Time m_last_repeated;
1015 bool m_delay_finished;
1025 Widgets & operator=(
const Widgets &);
1030 inline void lend_Widget(
Widget &widget);
1031 inline void unlend_Widget(
Widget &widget);
1034 virtual void on_key(
const SDL_Keysym &keysym,
const bool &down);
1037 virtual void on_mouse_button(
const Point2i &pos,
const bool &down,
const int &button);
1038 virtual void on_mouse_motion(
const Point2i &pos);
1039 #if SDL_VERSION_ATLEAST(2,0,0)
1040 virtual void on_mouse_wheel(
const Point2i &pos,
const int &up);
1043 virtual void perform_logic();
1045 virtual void render_impl()
const;
1054 #pragma warning( push )
1055 #pragma warning( disable : 4251 )
1057 mutable std::vector<Widget *> m_widgets;
1059 #pragma warning( pop )
#define ZENI_DEFAULT_TAB_SPACES
#define ZENI_DEFAULT_JUSTIFY
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
Widget_Renderer_Pair< T1, T2 > * make_Widget_Renderer_Pair(const T1 *const &first_, const bool &delete_first_, const T2 *const &second_, const bool &delete_second_)
#define ZENI_DEFAULT_TEXTBOX_EDITABLE
static void render(const Vertex_Buffer_Macrorenderer ¯orenderer, std::vector< Vertex_Buffer::Vertex_Buffer_Range * > &descriptors)
static void reformat_all()
Reformat all Text_Box instances.
#define SDL_DEFAULT_REPEAT_DELAY
The SDL keysym structure, used in key events.
#define ZENI_DEFAULT_SLIDER_POSITION
#define SDL_DEFAULT_REPEAT_INTERVAL
Keyboard button event structure (event.key.*)
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum format
std::pair< int, int > Range
Mouse wheel event structure (event.wheel.*)
EGLSurface EGLint void ** value
Mouse motion event structure (event.motion.*)
std::vector< String > Options
A 2D Point represented with floats.
A 2D Point represented with integers.