56 lines
1.7 KiB
C++
56 lines
1.7 KiB
C++
#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
|
|
{
|
|
class Caption : public Widget,
|
|
public FontHandler,
|
|
public TextureHandler
|
|
{
|
|
protected:
|
|
Font::RenderMode _render_mode {Font::RenderMode::SHADED};
|
|
std::string _text;
|
|
Texture* _text_texture {nullptr};
|
|
|
|
void _handle_font_change(Font*) override;
|
|
void _handle_font_color_change(const Color&, const Color&) override;
|
|
void _handle_geometry_change(const SDL_Rect&) noexcept override;
|
|
void _handle_renderer_change(Renderer*) override;
|
|
void _handle_rendering() override;
|
|
void _handle_texture_update() override;
|
|
|
|
public:
|
|
enum struct Alignment
|
|
{
|
|
CENTER,
|
|
LEFT,
|
|
RIGHT
|
|
};
|
|
|
|
inline static const Color default_color_bg = {255, 255, 255, SDL_ALPHA_OPAQUE};
|
|
inline static const Color default_color_fg = {0, 0, 0, SDL_ALPHA_OPAQUE};
|
|
|
|
Alignment alignment {Alignment::LEFT};
|
|
Size margins {3, 3};
|
|
|
|
Caption(Widget* parent = nullptr);
|
|
~Caption() noexcept override;
|
|
|
|
virtual auto render_mode(Font::RenderMode) noexcept -> Caption*;
|
|
[[nodiscard]] virtual auto text() const noexcept -> const std::string&;
|
|
virtual auto text(const std::string&) -> Caption*;
|
|
|
|
[[nodiscard]] auto size() const noexcept -> Size override;
|
|
};
|
|
}
|
|
|
|
#endif
|