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#include "GUI/BsGUIElementContainer.h"
4#include "GUI/BsGUISkin.h"
5#include "GUI/BsGUIManager.h"
6
7namespace bs
8{
9 GUIElementContainer::GUIElementContainer(const GUIDimensions& dimensions, const String& style,
10 GUIElementOptions options)
11 :GUIElement(style, dimensions, options)
12 {
13 mOptionFlags.set(GUIElementOption::ClickThrough);
14 }
15
16 UINT32 GUIElementContainer::_getNumRenderElements() const
17 {
18 return 0;
19 }
20
21 const SpriteMaterialInfo& GUIElementContainer::_getMaterial(UINT32 renderElementIdx, SpriteMaterial** material) const
22 {
23 BS_EXCEPT(InvalidStateException, "Trying to retrieve a material from an element with no render elements.");
24 static SpriteMaterialInfo dummy;
25 return dummy;
26 }
27
28 void GUIElementContainer::_getMeshInfo(UINT32 renderElementIdx, UINT32& numVertices, UINT32& numIndices, GUIMeshType& type) const
29 {
30 numVertices = 0;
31 numIndices = 0;
32 type = GUIMeshType::Triangle;
33 }
34
35 void GUIElementContainer::_fillBuffer(UINT8* vertices, UINT32* indices, UINT32 vertexOffset, UINT32 indexOffset,
36 UINT32 maxNumVerts, UINT32 maxNumIndices, UINT32 renderElementIdx) const
37 { }
38
39 Vector2I GUIElementContainer::_getOptimalSize() const
40 {
41 return Vector2I();
42 }
43
44 void GUIElementContainer::setFocus(bool enabled, bool clear)
45 {
46 if(mFocusElement)
47 mFocusElement->setFocus(enabled, clear);
48 else
49 GUIElement::setFocus(enabled, clear);
50 }
51
52 bool GUIElementContainer::_commandEvent(const GUICommandEvent& ev)
53 {
54 // Make sure to pass through focus events to elements below
55 if (ev.getType() == GUICommandEventType::FocusGained)
56 return false;
57 else if (ev.getType() == GUICommandEventType::FocusLost)
58 return false;
59
60 return GUIElement::_commandEvent(ev);
61 }
62}