1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-06 00:55:50 +00:00
OpenMW/apps/openmw/mwgui/windowpinnablebase.cpp
2022-09-22 21:35:26 +03:00

43 lines
1.1 KiB
C++

#include "windowpinnablebase.hpp"
#include "exposedwindow.hpp"
namespace MWGui
{
WindowPinnableBase::WindowPinnableBase(const std::string& parLayout)
: WindowBase(parLayout)
, mPinned(false)
{
Window* window = mMainWidget->castType<Window>();
mPinButton = window->getSkinWidget("Button");
mPinButton->eventMouseButtonPressed += MyGUI::newDelegate(this, &WindowPinnableBase::onPinButtonPressed);
}
void WindowPinnableBase::onPinButtonPressed(MyGUI::Widget* _sender, int left, int top, MyGUI::MouseButton id)
{
if (id != MyGUI::MouseButton::Left)
return;
mPinned = !mPinned;
if (mPinned)
mPinButton->changeWidgetSkin("PinDown");
else
mPinButton->changeWidgetSkin("PinUp");
onPinToggled();
}
void WindowPinnableBase::setPinned(bool pinned)
{
if (pinned != mPinned)
onPinButtonPressed(mPinButton, 0, 0, MyGUI::MouseButton::Left);
}
void WindowPinnableBase::setPinButtonVisible(bool visible)
{
mPinButton->setVisible(visible);
}
}