| 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 "Math/BsRect2I.h" |
| 7 | |
| 8 | namespace bs |
| 9 | { |
| 10 | /** @addtogroup GUI-Internal |
| 11 | * @{ |
| 12 | */ |
| 13 | |
| 14 | /** |
| 15 | * Contains all attributes that are output by GUI layouts and assigned to GUI elements. This includes element position, |
| 16 | * size and depth. |
| 17 | */ |
| 18 | struct BS_EXPORT GUILayoutData |
| 19 | { |
| 20 | GUILayoutData() |
| 21 | { |
| 22 | setPanelDepth(0); |
| 23 | } |
| 24 | |
| 25 | /** Set widget part of element depth (Most significant part). */ |
| 26 | void setWidgetDepth(UINT8 widgetDepth) |
| 27 | { |
| 28 | UINT32 shiftedDepth = widgetDepth << 24; |
| 29 | |
| 30 | depth = shiftedDepth | (depth & 0x00FFFFFF); |
| 31 | } |
| 32 | |
| 33 | /** Set panel part of element depth. Less significant than widget depth but more than custom element depth. */ |
| 34 | void setPanelDepth(INT16 panelDepth) |
| 35 | { |
| 36 | UINT32 signedDepth = ((INT32)panelDepth + 32768) << 8; |
| 37 | |
| 38 | depth = signedDepth | (depth & 0xFF0000FF);; |
| 39 | } |
| 40 | |
| 41 | /** Retrieve widget part of element depth (Most significant part). */ |
| 42 | UINT8 getWidgetDepth() const |
| 43 | { |
| 44 | return (depth >> 24) & 0xFF; |
| 45 | } |
| 46 | |
| 47 | /** Retrieve panel part of element depth. Less significant than widget depth but more than custom element depth. */ |
| 48 | INT16 getPanelDepth() const |
| 49 | { |
| 50 | return (((INT32)depth >> 8) & 0xFFFF) - 32768; |
| 51 | } |
| 52 | |
| 53 | /** Returns a clip rectangle that is relative to the current bounds. */ |
| 54 | Rect2I getLocalClipRect() const |
| 55 | { |
| 56 | Rect2I localClipRect = clipRect; |
| 57 | localClipRect.x -= area.x; |
| 58 | localClipRect.y -= area.y; |
| 59 | |
| 60 | return localClipRect; |
| 61 | } |
| 62 | |
| 63 | Rect2I area; |
| 64 | Rect2I clipRect; |
| 65 | UINT32 depth = 0; |
| 66 | UINT16 depthRangeMin = -1; |
| 67 | UINT16 depthRangeMax = -1; |
| 68 | }; |
| 69 | |
| 70 | /** @} */ |
| 71 | } |