#ifndef BWIDGETS_CAPTION_HPP_ #define BWIDGETS_CAPTION_HPP_ #include #include #include #include #include struct SDL_Surface; namespace bwidgets::widget { class Caption : public Widget, public FontHandler, public TextureHandler { public: enum struct Alignment { CENTER, LEFT, RIGHT }; protected: SDL_Color _color_fg {0, 0, 0, SDL_ALPHA_OPAQUE}; SDL_Color _color_bg {255, 255, 255, SDL_ALPHA_TRANSPARENT}; core::Font::RenderMode _render_mode {core::Font::RenderMode::SHADED}; std::string _text; core::Texture* _text_texture {nullptr}; virtual void _handle_font_change(core::Font*) override; virtual void _handle_font_color_change(const SDL_Color&, const SDL_Color&) override; virtual void _handle_geometry_change(const SDL_Rect&) noexcept override; virtual void _handle_renderer_change(core::Renderer*) override; virtual void _handle_rendering() override; virtual void _handle_texture_update() override; public: Alignment alignment {Alignment::LEFT}; core::Size margins {2, 2}; Caption(Widget* parent=nullptr) : Widget(parent) {} ~Caption() noexcept; virtual Caption* color_bg(const SDL_Color&); virtual Caption* color_fg(const SDL_Color&); virtual Caption* render_mode(core::Font::RenderMode) noexcept; virtual const std::string& text() const noexcept; virtual Caption* text(const std::string&); virtual core::Size size() const noexcept override; }; } #endif