wPlot2D version: 0.1.0
A lightweight C++ library for clear and customizable 2D scientific plots.
Loading...
Searching...
No Matches
wTitleEntity.hpp
Go to the documentation of this file.
1/*
2+---------------------------------------------------------------------------------------------------------------------------------------------------+
3Created by Wilfried Koch.
4Copyright @ 2025 Wilfried Koch. All rights reserved.
5+---------------------------------------------------------------------------------------------------------------------------------------------------+
6*/
7
8#ifndef W_TITLE_ENTITY_HPP
9#define W_TITLE_ENTITY_HPP
10
13#include "wFrameEntity.hpp"
14
15#pragma GCC diagnostic push
16#pragma GCC diagnostic ignored "-Wfloat-equal"
17#pragma GCC diagnostic ignored "-Wswitch-default"
18#include <SFML/Graphics.hpp>
19#pragma GCC diagnostic pop
20
21namespace wPlot2D
22{
23
45 {
46 public:
53 TitleEntity( const sf::Font& font, const std::string& title, bool hasFrame = false );
54
61 TitleEntity( const sf::Font& font, const std::wstring& title, bool hasFrame = false );
62
66 virtual ~TitleEntity( ) = default;
67
72 [[nodiscard]] unsigned int getCharacterSize( ) const;
73
78 [[nodiscard]] sf::FloatRect getTextSize( ) const;
79
84 void setTextColor( sf::Color textColor );
85
90 void setOffset( sf::Vector2f offset );
91
96 void setCharacterSize( unsigned int size );
97
103 void setFont( const sf::Font& font );
104
109 [[nodiscard]] sf::Color getFrameOutlineColor( ) const;
110
115 [[nodiscard]] sf::Color getFrameFillColor( ) const;
116
121 [[nodiscard]] float getFrameThickness( ) const;
122
127 [[nodiscard]] sf::Vector2f getPadding( ) const;
128
133 [[nodiscard]] bool isFrameEnabled( ) const;
134
139 void setFrameEnabled( bool enabled );
140
145 void setFrameOutlineColor( const sf::Color& color );
146
151 void setFrameFillColor( const sf::Color& color );
152
157 void setFrameThickness( float thickness );
158
167 void setPadding( sf::Vector2f padding );
168
182 void render( sf::RenderWindow& window );
183
184 private:
185 sf::Text mTitleText;
186 FrameEntity mFrame;
187
193 template < typename T >
194 void init( const T& title );
195 };
196
197} // namespace wPlot2D
198
199#endif
Represents an entity in the ECS (Entity-Component System) architecture.
Definition wEntity.hpp:60
Entity representing a rectangular frame around content.
Definition wFrameEntity.hpp:43
void setFrameEnabled(bool enabled)
Enables or disables the visual frame.
Definition wTitleEntity.cpp:99
TitleEntity(const sf::Font &font, const std::string &title, bool hasFrame=false)
Constructs a title entity with specified font and text (UTF-8).
Definition wTitleEntity.cpp:22
void setCharacterSize(unsigned int size)
Sets the font size (character size) of the title.
Definition wTitleEntity.cpp:81
void setFrameFillColor(const sf::Color &color)
Sets the fill color of the frame.
Definition wTitleEntity.cpp:114
sf::Vector2f getPadding() const
Returns the internal padding of the frame.
Definition wTitleEntity.cpp:144
sf::FloatRect getTextSize() const
Returns the local bounding box of the title text.
Definition wTitleEntity.cpp:64
unsigned int getCharacterSize() const
Returns the current character size.
Definition wTitleEntity.cpp:59
void setOffset(sf::Vector2f offset)
Sets the offset relative to the base anchor position.
Definition wTitleEntity.cpp:75
void setFrameThickness(float thickness)
Sets the thickness of the frame's outline.
Definition wTitleEntity.cpp:119
sf::Color getFrameOutlineColor() const
Returns the current outline color of the frame.
Definition wTitleEntity.cpp:129
float getFrameThickness() const
Returns the frame's outline thickness.
Definition wTitleEntity.cpp:139
void setFont(const sf::Font &font)
Sets the font reference for the title.
Definition wTitleEntity.cpp:86
sf::Color getFrameFillColor() const
Returns the current fill color of the frame.
Definition wTitleEntity.cpp:134
void render(sf::RenderWindow &window)
Renders the title and its frame (if enabled) to the window.
Definition wTitleEntity.cpp:155
void setPadding(sf::Vector2f padding)
Sets the internal padding of the frame (horizontal and vertical).
Definition wTitleEntity.cpp:124
void setTextColor(sf::Color textColor)
Sets the text color.
Definition wTitleEntity.cpp:69
virtual ~TitleEntity()=default
Virtual destructor.
bool isFrameEnabled() const
Returns whether the title has a visible frame.
Definition wTitleEntity.cpp:104
void setFrameOutlineColor(const sf::Color &color)
Sets the frame's outline color.
Definition wTitleEntity.cpp:109
Definition wAxisEntity.cpp:17