bwidgets/inc/basic_widgets/w/caption.hpp

57 lines
2 KiB
C++
Raw Normal View History

#ifndef BWIDGETS_CAPTION_HPP_
#define BWIDGETS_CAPTION_HPP_
#include <basic_widgets/core/texture.hpp>
#include <basic_widgets/core/type/size.hpp>
#include <basic_widgets/w/base/widget.hpp>
#include <basic_widgets/w/feat/font_handler.hpp>
#include <basic_widgets/w/feat/texture_handler.hpp>
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};
2021-07-19 23:50:50 +02:00
SDL_Color _color_bg {255, 255, 255, SDL_ALPHA_TRANSPARENT};
2021-07-23 20:08:52 +02:00
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;
2021-07-19 23:50:50 +02:00
virtual Caption* color_bg(const SDL_Color&);
virtual Caption* color_fg(const SDL_Color&);
2021-07-23 20:08:52 +02:00
virtual Caption* render_mode(core::Font::RenderMode) noexcept;
virtual const std::string& text() const noexcept;
2021-07-19 23:50:50 +02:00
virtual Caption* text(const std::string&);
2021-07-23 20:08:52 +02:00
virtual core::Size size() const noexcept override;
};
}
#endif