| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #include "GUI/BsGUIWindowFrameWidget.h"
- #include "RTTI/BsGUIWindowFrameWidgetRTTI.h"
- #include "GUI/BsGUIPanel.h"
- #include "GUI/BsCGUIWidget.h"
- #include "GUI/BsGUILayout.h"
- #include "GUI/BsGUITexture.h"
- #include "GUI/BsGUIWindowFrame.h"
- #include "RenderAPI/BsRenderWindow.h"
- #include "Platform/BsPlatform.h"
- namespace bs
- {
- const UINT32 WindowFrameWidget::RESIZE_BORDER_WIDTH = 3;
- WindowFrameWidget::WindowFrameWidget(const HSceneObject& parent, bool allowResize, const SPtr<Camera>& camera, RenderWindow* parentWindow, const HGUISkin& skin)
- :CGUIWidget(parent, camera), mAllowResize(allowResize), mWindowFramePanel(nullptr), mParentWindow(parentWindow)
- {
- setSkin(skin);
- GUIPanel* backgroundPanel = getPanel()->addNewElement<GUIPanel>(500);
- backgroundPanel->addElement(GUITexture::create(TextureScaleMode::RepeatToFit,
- GUIOptions(GUIOption::flexibleWidth(), GUIOption::flexibleHeight()), "WindowBackground"));
- mWindowFramePanel = getPanel()->addNewElement<GUIPanel>(499);
- mWindowFrame = GUIWindowFrame::create("WindowFrame");
- mWindowFramePanel->addElement(mWindowFrame);
- refreshNonClientAreas();
- }
- void WindowFrameWidget::ownerWindowFocusChanged()
- {
- mWindowFrame->setFocused(mParentWindow->getProperties().hasFocus);
- CGUIWidget::ownerWindowFocusChanged();
- }
- void WindowFrameWidget::ownerTargetResized()
- {
- CGUIWidget::ownerTargetResized();
- refreshNonClientAreas();
- }
- void WindowFrameWidget::refreshNonClientAreas() const
- {
- if (!mAllowResize)
- return;
- INT32 x = 0;
- INT32 y = 0;
- UINT32 width = getTarget()->getPixelArea().width;
- UINT32 height = getTarget()->getPixelArea().height;
- Vector<NonClientResizeArea> nonClientAreas(8);
- nonClientAreas[0].type = NonClientAreaBorderType::TopLeft;
- nonClientAreas[0].area = Rect2I(x, y,
- RESIZE_BORDER_WIDTH, RESIZE_BORDER_WIDTH);
- nonClientAreas[1].type = NonClientAreaBorderType::Top;
- nonClientAreas[1].area = Rect2I(x + RESIZE_BORDER_WIDTH, y,
- width - 2 * RESIZE_BORDER_WIDTH, RESIZE_BORDER_WIDTH);
- nonClientAreas[2].type = NonClientAreaBorderType::TopRight;
- nonClientAreas[2].area = Rect2I(x + width - RESIZE_BORDER_WIDTH, y,
- RESIZE_BORDER_WIDTH, RESIZE_BORDER_WIDTH);
- nonClientAreas[3].type = NonClientAreaBorderType::Left;
- nonClientAreas[3].area = Rect2I(x, y + RESIZE_BORDER_WIDTH,
- RESIZE_BORDER_WIDTH, height - 2 * RESIZE_BORDER_WIDTH);
- nonClientAreas[4].type = NonClientAreaBorderType::Right;
- nonClientAreas[4].area = Rect2I(x + width - RESIZE_BORDER_WIDTH, y + RESIZE_BORDER_WIDTH,
- RESIZE_BORDER_WIDTH, height - 2 * RESIZE_BORDER_WIDTH);
- nonClientAreas[5].type = NonClientAreaBorderType::BottomLeft;
- nonClientAreas[5].area = Rect2I(x, y + height - RESIZE_BORDER_WIDTH,
- RESIZE_BORDER_WIDTH, RESIZE_BORDER_WIDTH);
- nonClientAreas[6].type = NonClientAreaBorderType::Bottom;
- nonClientAreas[6].area = Rect2I(x + RESIZE_BORDER_WIDTH, y + height - RESIZE_BORDER_WIDTH,
- width - 2 * RESIZE_BORDER_WIDTH, RESIZE_BORDER_WIDTH);
- nonClientAreas[7].type = NonClientAreaBorderType::BottomRight;
- nonClientAreas[7].area = Rect2I(x + width - RESIZE_BORDER_WIDTH, y + height - RESIZE_BORDER_WIDTH,
- RESIZE_BORDER_WIDTH, RESIZE_BORDER_WIDTH);
- Platform::setResizeNonClientAreas(*mParentWindow->getCore(), nonClientAreas);
- }
- RTTITypeBase* WindowFrameWidget::getRTTIStatic()
- {
- return WindowFrameWidgetRTTI::instance();
- }
- RTTITypeBase* WindowFrameWidget::getRTTI() const
- {
- return WindowFrameWidget::getRTTIStatic();
- }
- }
|