37 #ifndef DOXYGEN_SHOULD_SKIP_THIS
136 virtual void drawRect(
RenderTarget& target,
const RectF& rect,
float corner, UIFlags flags)
const = 0;
149 virtual void drawText(
RenderTarget& target,
const std::string& text,
unsigned size, Vector2f pos,
float width,
Alignment alignment, UIFlags flags)
const = 0;
177 virtual void drawRect(
RenderTarget& target,
const RectF& rect,
float corner, UIFlags flags)
const override;
179 virtual void drawText(
RenderTarget& target,
const std::string& text,
unsigned size, Vector2f pos,
float width,
Alignment alignment, UIFlags flags)
const override;
311 bool beginScrollArea(
const std::string& name,
const RectF& area,
float *scroll);
359 bool button(
const std::string& text,
bool enabled =
true);
368 bool item(
const std::string& text,
bool enabled =
true);
380 bool check(
const std::string& text,
bool checked,
bool enabled =
true);
392 bool collapse(
const std::string& text,
bool checked,
bool enabled =
true);
403 void label(
const std::string& text);
413 void value(
const std::string& text);
428 bool slider(
const std::string& text,
float *val,
float vmin,
float vmax,
float vinc,
bool enabled =
true);
440 bool cycle(
const std::vector<std::string>& choices, std::size_t choice,
bool enabled =
true);
448 enum class CommandType {
460 std::vector<Command> m_commands;
462 enum class ScissorAction {
467 struct ScissorCommand {
468 ScissorAction action;
472 std::vector<ScissorCommand> m_scissorCommands;
479 std::vector<RectCommand> m_rectCommands;
489 std::vector<TextCommand> m_textCommands;
496 std::vector<IconCommand> m_iconCommands;
498 void resetCommandQueue();
499 void addScissorCommand(ScissorAction action,
const RectF& rect = RectF
());
500 void addRectCommand(
const RectF& rect,
float corner, UIFlags flags);
501 void addTextCommand(Vector2f pos,
float width,
const std::string& text,
unsigned size,
Alignment alignment, UIFlags flags);
502 void addIconCommand(Vector2f pos,
UIIcon icon, UIFlags flags);
509 uint64_t generateId();
515 Vector2i m_mouseCursor;
531 bool m_insideCurrentScroll;
535 float *m_scrollValue;
538 bool m_insideScrollArea;
542 bool isAnyActive()
const {
543 return m_active != 0;
546 bool isActive(uint64_t id)
const {
547 return m_active == id;
550 bool isHot(uint64_t id)
const {
554 bool inWidget(
const RectF& rect,
bool checkScroll =
true)
const;
557 m_leftPressed =
false;
558 m_leftReleased =
false;
567 void setActive(uint64_t id) {
572 void setHot(uint64_t id) {
576 bool processWidget(uint64_t id,
bool over);
577 RectF reserveWidget(
float height,
bool spacing =
true);
581 #ifndef DOXYGEN_SHOULD_SKIP_THIS
585 #ifndef DOXYGEN_SHOULD_SKIP_THIS
588 static constexpr bool value =
true;
bool check(const std::string &text, bool checked, bool enabled=true)
Add a checkbox.
float checkCorner
The corner size of a check.
Definition: UI.h:90
virtual void drawText(RenderTarget &target, const std::string &text, unsigned size, Vector2f pos, float width, Alignment alignment, UIFlags flags) const override
Draw a text.
void clear()
Clear the internal state for this frame.
float sliderCorner
The corner size of a slider.
Definition: UI.h:91
float cycleCorner
The corner size of a cycle.
Definition: UI.h:93
void update(const Event &event)
Update the internal state with an event.
DefaultUIRenderer(gf::Font &font)
Constructor.
Base class for all render targets (window, texture, ...)
Definition: RenderTarget.h:65
Define the states used for drawing to a RenderTarget.
Definition: RenderStates.h:82
Bitfield relying on an enumeration.
Definition: Flags.h:60
A check icon (generally a cross)
A collapsed icon (generally a triangle pointing sideways)
void separatorLine()
Add a separator line.
bool button(const std::string &text, bool enabled=true)
Add a button.
An immediate mode user interface class.
Definition: UI.h:270
float checkSize
The size of a check.
Definition: UI.h:89
bool slider(const std::string &text, float *val, float vmin, float vmax, float vinc, bool enabled=true)
Add a slider.
bool beginScrollArea(const std::string &name, const RectF &area, float *scroll)
Define the main widget.
Layout of a user interface.
Definition: UI.h:78
float scrollAreaCorner
The corner size of the scroll area.
Definition: UI.h:85
Abstract base class for objects that can be drawn to a render window.
Definition: Drawable.h:79
UIProperties
Properties of a user interface.
Definition: UI.h:49
void endScrollArea()
End the main widget.
float indentSize
The indent size.
Definition: UI.h:95
virtual ~UIRenderer()
Virtual destructor.
The widget is underlying.
void separator()
Add an invisible separator.
float areaHeader
The height of the area header.
Definition: UI.h:83
virtual void drawIcon(RenderTarget &target, Vector2f pos, UIIcon icon, UIFlags flags) const override
Draw an icon.
An expanded icon (generally a triangle pointing downwards)
bool cycle(const std::vector< std::string > &choices, std::size_t choice, bool enabled=true)
Add a cycle.
float textHeight
The size of the text.
Definition: UI.h:81
A renderer for a user interface.
Definition: UI.h:121
void value(const std::string &text)
Add a value.
void indent()
Increase the indent size.
The widget is selectable.
virtual void drawText(RenderTarget &target, const std::string &text, unsigned size, Vector2f pos, float width, Alignment alignment, UIFlags flags) const =0
Draw a text.
A character font.
Definition: Font.h:130
bool collapse(const std::string &text, bool checked, bool enabled=true)
Add a disclosure widget.
virtual void draw(RenderTarget &target, RenderStates states) override
Draw the object to a render target.
float widgetHeight
The height of the widgets.
Definition: UI.h:80
virtual void drawIcon(RenderTarget &target, Vector2f pos, UIIcon icon, UIFlags flags) const =0
Draw an icon.
float defaultSpacing
The default spacing between widgets.
Definition: UI.h:82
UIIcon
An icon of a user interface.
Definition: UI.h:104
Alignment
The alignement of a text.
Definition: Alignment.h:32
float scrollAreaPadding
The padding of the scroll area.
Definition: UI.h:84
The default renderer for user interface.
Definition: UI.h:168
constexpr Rect() noexcept
Default constructor.
Definition: Rect.h:111
void label(const std::string &text)
Add a label.
float itemCorner
The corner size of an item.
Definition: UI.h:88
virtual void drawRect(RenderTarget &target, const RectF &rect, float corner, UIFlags flags) const =0
Draw a rectangle.
float buttonCorner
The corner size of a button.
Definition: UI.h:87
Defines a system event and its parameters.
Definition: Event.h:115
#define GF_API
Definition: Portability.h:35
UI(const UIRenderer &renderer, const UILayout &layout)
Constructor.
bool item(const std::string &text, bool enabled=true)
Add an item.
float sliderMarkerWidth
The width of a marker.
Definition: UI.h:92
virtual void drawRect(RenderTarget &target, const RectF &rect, float corner, UIFlags flags) const override
Draw a rectangle.
void unindent()
Decrease the indent size.