2021-08-06 14:22:56 +02:00
|
|
|
#ifndef BWIDGETS_CAPTION_HPP
|
|
|
|
#define BWIDGETS_CAPTION_HPP
|
2021-07-18 18:26:12 +02:00
|
|
|
|
2021-08-17 11:00:18 +02:00
|
|
|
#include <basic_widgets/w/base/widget.hpp>
|
2021-07-18 18:26:12 +02:00
|
|
|
#include <basic_widgets/w/feat/font_handler.hpp>
|
|
|
|
#include <basic_widgets/w/feat/texture_handler.hpp>
|
|
|
|
|
|
|
|
struct SDL_Surface;
|
|
|
|
|
2021-08-06 14:22:56 +02:00
|
|
|
namespace bwidgets
|
2021-07-18 18:26:12 +02:00
|
|
|
{
|
2021-08-17 11:00:18 +02:00
|
|
|
class Caption : public virtual Widget,
|
2021-08-19 15:00:44 +02:00
|
|
|
public virtual FontHandler,
|
|
|
|
public virtual TextureHandler
|
2021-07-18 18:26:12 +02:00
|
|
|
{
|
2021-07-29 16:06:03 +02:00
|
|
|
public:
|
|
|
|
enum struct Alignment
|
|
|
|
{
|
|
|
|
CENTER,
|
|
|
|
LEFT,
|
|
|
|
RIGHT
|
|
|
|
};
|
2021-08-06 14:22:56 +02:00
|
|
|
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};
|
2021-08-08 14:30:56 +02:00
|
|
|
inline static const Size default_margins = {3, 3};
|
2021-07-29 16:06:03 +02:00
|
|
|
|
2021-08-27 01:21:25 +02:00
|
|
|
// Text horizontal alignment on the caption viewport.
|
2021-08-06 14:22:56 +02:00
|
|
|
Alignment alignment {Alignment::LEFT};
|
2021-08-17 11:00:18 +02:00
|
|
|
Size margins {default_margins};
|
2021-07-29 16:06:03 +02:00
|
|
|
|
2021-08-17 11:00:18 +02:00
|
|
|
using Widget::Widget;
|
2021-07-29 16:06:03 +02:00
|
|
|
|
2021-08-27 01:21:25 +02:00
|
|
|
// Set caption text rendering mode.
|
2021-08-21 20:59:39 +02:00
|
|
|
virtual void render_mode(Font::RenderMode) = 0;
|
2021-08-23 23:50:14 +02:00
|
|
|
// Get caption text.
|
2021-08-21 20:59:39 +02:00
|
|
|
[[nodiscard]] virtual auto text() const noexcept -> std::string_view = 0;
|
2021-08-23 23:50:14 +02:00
|
|
|
// Set caption text.
|
2021-08-21 20:59:39 +02:00
|
|
|
virtual void text(std::string) = 0;
|
2021-07-18 18:26:12 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|