TGUI  1.3-dev
Loading...
Searching...
No Matches
CanvasBase.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2024 Bruno Van de Velde (vdv_b@tgui.eu)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25
26#ifndef TGUI_CANVAS_BASE_HPP
27#define TGUI_CANVAS_BASE_HPP
28
29#include <TGUI/Widgets/ClickableWidget.hpp>
30
32
33TGUI_MODULE_EXPORT namespace tgui
34{
38 class TGUI_API CanvasBase : public ClickableWidget
39 {
40 public:
41
42 using Ptr = std::shared_ptr<CanvasBase>;
43 using ConstPtr = std::shared_ptr<const CanvasBase>;
44
51 CanvasBase(const char* typeName, bool initRenderer);
52
60 void ignoreMouseEvents(bool ignore = true);
61
67 TGUI_NODISCARD bool isIgnoringMouseEvents() const;
68
75 TGUI_NODISCARD bool canGainFocus() const override;
76
81 TGUI_NODISCARD bool isMouseOnWidget(Vector2f pos) const override;
82
84 protected:
85
89 TGUI_NODISCARD std::unique_ptr<DataIO::Node> save(SavingRenderersMap& renderers) const override;
90
94 void load(const std::unique_ptr<DataIO::Node>& node, const LoadingRenderersMap& renderers) override;
95
97 private:
98
99 bool m_ignoringMouseEvents = false;
100 };
101}
102
104
105#endif // TGUI_CANVAS_BASE_HPP
This class is used as base class for the backend-specific canvas widgets.
Definition CanvasBase.hpp:39
void ignoreMouseEvents(bool ignore=true)
Sets whether the widget should completely ignore mouse events and let them pass to the widgets behind...
TGUI_NODISCARD bool isIgnoringMouseEvents() const
Returns whether the widget is ignoring mouse events and letting them pass to the widgets behind it.
std::shared_ptr< CanvasBase > Ptr
Shared widget pointer.
Definition CanvasBase.hpp:42
std::shared_ptr< const CanvasBase > ConstPtr
Shared constant widget pointer.
Definition CanvasBase.hpp:43
TGUI_NODISCARD std::unique_ptr< DataIO::Node > save(SavingRenderersMap &renderers) const override
Saves the widget as a tree node in order to save it to a file.
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
TGUI_NODISCARD bool canGainFocus() const override
Returns whether the widget can gain focus.
TGUI_NODISCARD bool isMouseOnWidget(Vector2f pos) const override
Returns whether the mouse position (which is relative to the parent widget) lies on top of the widget...
Clickable widget.
Definition ClickableWidget.hpp:40
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:39