1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
3 | #pragma once |
4 | |
5 | #include "BsPrerequisites.h" |
6 | #include "GUI/BsGUITexture.h" |
7 | |
8 | namespace bs |
9 | { |
10 | /** @addtogroup GUI |
11 | * @{ |
12 | */ |
13 | |
14 | /** |
15 | * Allows you to display a render texture in the GUI. Has the same functionality as GUITexture, but also forwards any |
16 | * input to underlying GUI elements being rendered on the provided render texture. |
17 | */ |
18 | class BS_EXPORT GUIRenderTexture : public GUITexture |
19 | { |
20 | public: |
21 | /** Returns type name of the GUI element used for finding GUI element styles. */ |
22 | static const String& getGUITypeName(); |
23 | |
24 | /** |
25 | * Creates a new element with the provided render texture. |
26 | * |
27 | * @param[in] texture Render texture to display. |
28 | * @param[in] transparent Determines should the texture be rendered with transparency active. |
29 | * @param[in] styleName Optional style to use for the element. Style will be retrieved from GUISkin of the |
30 | * GUIWidget the element is used on. If not specified default style is used. |
31 | */ |
32 | static GUIRenderTexture* create(const SPtr<RenderTexture>& texture, bool transparent, |
33 | const String& styleName = StringUtil::BLANK); |
34 | |
35 | /** |
36 | * Creates a new element with the provided render texture. |
37 | * |
38 | * @param[in] texture Render texture to display. |
39 | * @param[in] transparent Determines should the texture be rendered with transparency active. |
40 | * @param[in] options Options that allow you to control how is the element positioned and sized. |
41 | * This will override any similar options set by style. |
42 | * @param[in] styleName Optional style to use for the element. Style will be retrieved from GUISkin of the |
43 | * GUIWidget the element is used on. If not specified default style is used. |
44 | */ |
45 | static GUIRenderTexture* create(const SPtr<RenderTexture>& texture, bool transparent, const GUIOptions& options, |
46 | const String& styleName = StringUtil::BLANK); |
47 | |
48 | /** |
49 | * Creates a new element with the provided render texture. |
50 | * |
51 | * @param[in] texture Render texture to display. |
52 | * @param[in] styleName Optional style to use for the element. Style will be retrieved from GUISkin of the |
53 | * GUIWidget the element is used on. If not specified default style is used. |
54 | */ |
55 | static GUIRenderTexture* create(const SPtr<RenderTexture>& texture, const String& styleName = StringUtil::BLANK); |
56 | |
57 | /** |
58 | * Creates a new element with the provided render texture. |
59 | * |
60 | * @param[in] texture Render texture to display. |
61 | * @param[in] options Options that allow you to control how is the element positioned and sized. |
62 | * This will override any similar options set by style. |
63 | * @param[in] styleName Optional style to use for the element. Style will be retrieved from GUISkin of the |
64 | * GUIWidget the element is used on. If not specified default style is used. |
65 | */ |
66 | static GUIRenderTexture* create(const SPtr<RenderTexture>& texture, const GUIOptions& options, |
67 | const String& styleName = StringUtil::BLANK); |
68 | |
69 | /** Changes the active render texture whose contents to display in the GUI element. */ |
70 | void setRenderTexture(const SPtr<RenderTexture>& texture); |
71 | |
72 | protected: |
73 | GUIRenderTexture(const String& styleName, const SPtr<RenderTexture>& texture, bool transparent, |
74 | const GUIDimensions& dimensions); |
75 | virtual ~GUIRenderTexture(); |
76 | |
77 | /** @copydoc GUIElement::updateRenderElementsInternal */ |
78 | virtual void updateRenderElementsInternal() override; |
79 | |
80 | SPtr<RenderTexture> mSourceTexture; |
81 | bool mTransparent; |
82 | }; |
83 | |
84 | /** @} */ |
85 | } |