FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
C_objTextList.hpp
1/*
2 * Copyright 2024 Guillaume Guillet
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _FGE_C_OBJTEXTLIST_HPP_INCLUDED
18#define _FGE_C_OBJTEXTLIST_HPP_INCLUDED
19
20#include "FastEngine/fge_extern.hpp"
21#include "FastEngine/C_guiElement.hpp"
22#include "FastEngine/object/C_objRectangleShape.hpp"
23#include "FastEngine/object/C_objText.hpp"
24#include "FastEngine/object/C_object.hpp"
25#include <list>
26
27#define FGE_OBJTEXTLIST_CLASSNAME "FGE:OBJ:TEXTLIST"
28
29namespace fge
30{
31
32class FGE_API ObjTextList : public fge::Object, public fge::Subscriber
33{
34public:
36 ObjTextList(ObjTextList const& r);
37 ~ObjTextList() override = default;
38
39 FGE_OBJ_DEFAULT_COPYMETHOD(fge::ObjTextList)
40
41 void first(fge::Scene& scene) override;
42 void callbackRegister(fge::Event& event, fge::GuiElementHandler* guiElementHandlerPtr) override;
43 FGE_OBJ_DRAW_DECLARE
44
45 char const* getClassName() const override;
46 char const* getReadableClassName() const override;
47
48 fge::RectFloat getGlobalBounds() const override;
49 fge::RectFloat getLocalBounds() const override;
50
51 void addText(tiny_utf8::string string);
52 std::size_t getTextCount() const;
53 fge::ObjText* getText(std::size_t index);
54 fge::ObjText const* getText(std::size_t index) const;
55 void removeAllTexts();
56
57 void setFont(fge::Font font);
58 fge::Font const& getFont() const;
59
60 void setBoxSize(fge::DynamicSize const& size);
61 fge::Vector2f getBoxSize() const;
62
63 void setTextScrollRatio(float ratio);
64 float getTextScrollRatio() const;
65
66 void setMaxTextCount(std::size_t max);
67 std::size_t getMaxTextCount() const;
68
69 void refreshSize();
70
71private:
72 void onGuiResized(fge::GuiElementHandler const& handler, fge::Vector2f const& size);
73 void refreshSize(fge::Vector2f const& targetSize);
74
75 fge::GuiElementHandler* g_guiElementHandler{nullptr};
76
77 mutable fge::ObjRectangleShape g_box{};
78 float g_textScrollRatio{0.0f};
79 fge::DynamicSize g_boxSize;
80
81 fge::Font g_font;
82
83 mutable std::list<fge::ObjText> g_textList;
84 std::size_t g_maxStrings{100};
85};
86
87} // namespace fge
88
89#endif //_FGE_C_OBJTEXTLIST_HPP_INCLUDED
This class is a wrapper for SDL events.
Definition C_event.hpp:59
This class is a wrapper for the font manager to allow easy manipulation.
Definition C_font.hpp:35
A class to handle highest priority selection of GUI elements.
Definition C_guiElement.hpp:235
Definition C_objRectangleShape.hpp:36
Definition C_objTextList.hpp:33
Definition C_objText.hpp:90
The Object class is the base class for all objects in the engine.
Definition C_object.hpp:102
A scene contain a collection of object and handle them.
Definition C_scene.hpp:450
This class is a useful utility to "link" multiple objects around.
Definition C_subscription.hpp:150
Definition C_guiElement.hpp:56