2013-04-10 04:32:05 +00:00
|
|
|
#include "windowpinnablebase.hpp"
|
|
|
|
|
2015-01-10 01:50:43 +00:00
|
|
|
#include <MyGUI_Button.h>
|
|
|
|
|
2013-04-10 04:32:05 +00:00
|
|
|
#include "exposedwindow.hpp"
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
namespace MWGui
|
2013-04-10 04:32:05 +00:00
|
|
|
{
|
2013-04-17 22:56:48 +00:00
|
|
|
WindowPinnableBase::WindowPinnableBase(const std::string& parLayout)
|
2013-08-07 21:30:08 +00:00
|
|
|
: WindowBase(parLayout), mPinned(false)
|
2013-04-17 22:56:48 +00:00
|
|
|
{
|
2014-09-13 02:07:40 +00:00
|
|
|
ExposedWindow* window = mMainWidget->castType<ExposedWindow>();
|
2013-04-17 22:56:48 +00:00
|
|
|
mPinButton = window->getSkinWidget ("Button");
|
2013-04-10 04:32:05 +00:00
|
|
|
|
2015-01-31 15:26:34 +00:00
|
|
|
mPinButton->eventMouseButtonPressed += MyGUI::newDelegate(this, &WindowPinnableBase::onPinButtonPressed);
|
2014-08-04 15:03:47 +00:00
|
|
|
|
|
|
|
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 22:56:48 +00:00
|
|
|
}
|
2013-04-10 04:32:05 +00:00
|
|
|
|
2015-01-31 15:26:34 +00:00
|
|
|
void WindowPinnableBase::onPinButtonPressed(MyGUI::Widget* _sender, int left, int top, MyGUI::MouseButton id)
|
2013-04-17 22:56:48 +00:00
|
|
|
{
|
2015-01-31 15:26:34 +00:00
|
|
|
if (id != MyGUI::MouseButton::Left)
|
|
|
|
return;
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
mPinned = !mPinned;
|
2013-04-10 04:32:05 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
if (mPinned)
|
|
|
|
mPinButton->changeWidgetSkin ("PinDown");
|
|
|
|
else
|
|
|
|
mPinButton->changeWidgetSkin ("PinUp");
|
2013-04-10 04:32:05 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
onPinToggled();
|
|
|
|
}
|
2013-08-07 21:30:08 +00:00
|
|
|
|
2014-08-04 15:03:47 +00:00
|
|
|
void WindowPinnableBase::onDoubleClick(MyGUI::Widget *_sender)
|
|
|
|
{
|
|
|
|
onTitleDoubleClicked();
|
|
|
|
}
|
|
|
|
|
2014-06-10 15:47:59 +00:00
|
|
|
void WindowPinnableBase::setPinned(bool pinned)
|
|
|
|
{
|
|
|
|
if (pinned != mPinned)
|
2015-01-31 15:26:34 +00:00
|
|
|
onPinButtonPressed(mPinButton, 0, 0, MyGUI::MouseButton::Left);
|
2014-06-10 15:47:59 +00:00
|
|
|
}
|
|
|
|
|
2013-08-07 21:30:08 +00:00
|
|
|
void WindowPinnableBase::setPinButtonVisible(bool visible)
|
|
|
|
{
|
|
|
|
mPinButton->setVisible(visible);
|
|
|
|
}
|
2013-04-10 04:32:05 +00:00
|
|
|
}
|