1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-27 21:35:24 +00:00
OpenMW/apps/openmw/mwgui/windowpinnablebase.cpp

60 lines
1.7 KiB
C++
Raw Normal View History

#include "windowpinnablebase.hpp"
2015-01-10 02:50:43 +01:00
#include <MyGUI_Button.h>
#include "exposedwindow.hpp"
2013-04-17 18:56:48 -04:00
namespace MWGui
{
2013-04-17 18:56:48 -04:00
WindowPinnableBase::WindowPinnableBase(const std::string& parLayout)
: WindowBase(parLayout), mPinned(false)
2013-04-17 18:56:48 -04:00
{
2014-09-13 04:07:40 +02:00
ExposedWindow* window = mMainWidget->castType<ExposedWindow>();
2013-04-17 18:56:48 -04:00
mPinButton = window->getSkinWidget ("Button");
mPinButton->eventMouseButtonPressed += MyGUI::newDelegate(this, &WindowPinnableBase::onPinButtonPressed);
MyGUI::Button* button = NULL;
MyGUI::VectorWidgetPtr widgets = window->getSkinWidgetsByName("Action");
for (MyGUI::VectorWidgetPtr::iterator it = widgets.begin(); it != widgets.end(); ++it)
{
if ((*it)->isUserString("HideWindowOnDoubleClick"))
button = (*it)->castType<MyGUI::Button>();
}
if (button)
button->eventMouseButtonDoubleClick += MyGUI::newDelegate(this, &WindowPinnableBase::onDoubleClick);
2013-04-17 18:56:48 -04:00
}
void WindowPinnableBase::onPinButtonPressed(MyGUI::Widget* _sender, int left, int top, MyGUI::MouseButton id)
2013-04-17 18:56:48 -04:00
{
if (id != MyGUI::MouseButton::Left)
return;
2013-04-17 18:56:48 -04:00
mPinned = !mPinned;
2013-04-17 18:56:48 -04:00
if (mPinned)
mPinButton->changeWidgetSkin ("PinDown");
else
mPinButton->changeWidgetSkin ("PinUp");
2013-04-17 18:56:48 -04:00
onPinToggled();
}
void WindowPinnableBase::onDoubleClick(MyGUI::Widget *_sender)
{
onTitleDoubleClicked();
}
void WindowPinnableBase::setPinned(bool pinned)
{
if (pinned != mPinned)
onPinButtonPressed(mPinButton, 0, 0, MyGUI::MouseButton::Left);
}
void WindowPinnableBase::setPinButtonVisible(bool visible)
{
mPinButton->setVisible(visible);
}
}