17#ifndef _FGE_C_OBJWINDOW_HPP_INCLUDED
18#define _FGE_C_OBJWINDOW_HPP_INCLUDED
20#include "FastEngine/fge_extern.hpp"
21#include "FastEngine/C_scene.hpp"
22#include "FastEngine/object/C_object.hpp"
24#include "FastEngine/C_guiElement.hpp"
25#include "FastEngine/C_tileset.hpp"
26#include "FastEngine/object/C_objSprite.hpp"
27#include "FastEngine/object/C_objSpriteBatches.hpp"
28#include "FastEngine/object/C_objText.hpp"
30#define FGE_WINDOW_DEFAULT_PRIORITY (FGE_GUI_ELEMENT_PRIORITY_DEFAULT + 1)
31#define FGE_WINDOW_DEFAULT_SIZE_X 120.0f
32#define FGE_WINDOW_DEFAULT_SIZE_Y 200.0f
33#define FGE_WINDOW_PIXEL_SIZE 6
35#define FGE_OBJWINDOW_CLASSNAME "FGE:OBJ:WINDOW"
36#define FGE_OBJWINDOW_SCENE_PARENT_PROPERTY "_OBJWINDOW_PARENT_"
44 enum class ResizeModes
58 fge::
GuiElement* getGuiElement()
override {
return this; }
64 FGE_OBJ_UPDATE_DECLARE
73 void setHeight(
float height);
74 void setSize(fge::Vector2f
const& size);
75 fge::Vector2f
const& getSize()
const;
76 fge::Vector2f getDrawAreaSize()
const;
78 void showExitButton(
bool enable);
79 void makeMovable(
bool enable);
80 void makeResizable(
bool enable);
82 void setResizeMode(ObjWindow::ResizeModes modeX, ObjWindow::ResizeModes modeY);
84 void setViewCenterOffset(fge::Vector2f
const& offset);
85 fge::Vector2f
const& getViewCenterOffset()
const;
102 void refreshRectBounds();
103 void refreshTextures();
107 mutable std::shared_ptr<fge::View> _windowView;
116 void onMouseButtonReleased(
fge::Event const& evt, SDL_MouseButtonEvent
const& arg);
117 void onMouseMoved(
fge::Event const& evt, SDL_MouseMotionEvent
const& arg);
119 void onPlanUpdate(
fge::Scene& scene, fge::ObjectPlan plan);
120 void onObjectAdded(
fge::Scene& scene, fge::ObjectDataShared
const&
object);
122 void onRefreshGlobalScale(fge::Vector2f
const& scale);
124 bool g_movingWindowFlag{
false};
125 bool g_resizeWindowFlag{
false};
126 fge::Vector2f g_mouseClickLastPosition;
127 fge::Vector2f g_mouseClickLastSize;
128 fge::Vector2f g_size{FGE_WINDOW_DEFAULT_SIZE_X, FGE_WINDOW_DEFAULT_SIZE_Y};
130 bool g_showCloseButton{
true};
131 bool g_makeMovable{
true};
132 bool g_makeResizable{
true};
134 fge::ObjWindow::ResizeModes g_resizeModeX{fge::ObjWindow::ResizeModes::MODE_FREE};
135 fge::ObjWindow::ResizeModes g_resizeModeY{fge::ObjWindow::ResizeModes::MODE_FREE};
139 fge::Vector2f g_viewCenterOffset;
145 fge::TileSet g_tileSetWindow{{}, {FGE_WINDOW_PIXEL_SIZE, FGE_WINDOW_PIXEL_SIZE}};
This class is used to handle callbacks in a safe way.
Definition C_callback.hpp:189
This class is a wrapper for SDL events.
Definition C_event.hpp:59
A class to handle highest priority selection of GUI elements.
Definition C_guiElement.hpp:235
Definition C_guiElement.hpp:224
A base class for all GUI elements.
Definition C_guiElement.hpp:120
Definition C_objSpriteBatches.hpp:38
Definition C_objSprite.hpp:30
Definition C_objWindow.hpp:42
char const * getReadableClassName() const override
Get a readable version of the class name.
fge::RectFloat getGlobalBounds() const override
Get the global bounds of the object.
void first(fge::Scene &scene) override
Method called when the object is added to a scene for initialization purposes.
void removed(fge::Scene &scene) override
Method called when the object is removed from a scene.
fge::RectFloat getLocalBounds() const override
Get the local bounds of the object (without any transformations)
void callbackRegister(fge::Event &event, fge::GuiElementHandler *guiElementHandlerPtr) override
Ask the object to register all callbacks it needs to receive events.
char const * getClassName() const override
Get the unique class name of the object.
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
This class is a wrapper for the texture manager to allow easy manipulation.
Definition C_texture.hpp:36
A class that represent a set of tiles that can be used in a TileLayer.
Definition C_tileset.hpp:68
Definition C_guiElement.hpp:45