TGUI 1.8
CanvasBase.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2025 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#ifndef TGUI_CANVAS_BASE_HPP
26#define TGUI_CANVAS_BASE_HPP
27
28#include <TGUI/Widgets/ClickableWidget.hpp>
29
31
32TGUI_MODULE_EXPORT namespace tgui
33{
37 class TGUI_API CanvasBase : public ClickableWidget
38 {
39 public:
40
41 using Ptr = std::shared_ptr<CanvasBase>;
42 using ConstPtr = std::shared_ptr<const CanvasBase>;
43
50 CanvasBase(const char* typeName, bool initRenderer);
51
59 TGUI_DEPRECATED("Use setIgnoreMouseEvents instead") void ignoreMouseEvents(bool ignore = true);
60
66 TGUI_DEPRECATED("Use getIgnoreMouseEvents instead") TGUI_NODISCARD bool isIgnoringMouseEvents() const;
67
74 TGUI_NODISCARD bool canGainFocus() const override;
75
80 TGUI_NODISCARD bool isMouseOnWidget(Vector2f pos) const override;
81
83 protected:
84
88 TGUI_NODISCARD std::unique_ptr<DataIO::Node> save(SavingRenderersMap& renderers) const override;
89
93 void load(const std::unique_ptr<DataIO::Node>& node, const LoadingRenderersMap& renderers) override;
94
96 private:
97
98 bool m_ignoringMouseEvents = false; // TGUI_NEXT: Remove this property
99 };
100}
101
103
104#endif // TGUI_CANVAS_BASE_HPP
bool isMouseOnWidget(Vector2f pos) const override
Returns whether the mouse position (which is relative to the parent widget) lies on top of the widget...
void ignoreMouseEvents(bool ignore=true)
Sets whether the widget should completely ignore mouse events and let them pass to the widgets behind...
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.
std::shared_ptr< CanvasBase > Ptr
Shared widget pointer.
Definition CanvasBase.hpp:41
std::shared_ptr< const CanvasBase > ConstPtr
Shared constant widget pointer.
Definition CanvasBase.hpp:42
bool isIgnoringMouseEvents() const
Returns whether the widget is ignoring mouse events and letting them pass to the widgets behind it.
bool canGainFocus() const override
Returns whether the widget can gain focus.
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:38