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
|
|
|
|
2018-10-09 06:21:12 +00:00
|
|
|
MyGUI::Button* button = nullptr;
|
2014-08-04 15:03:47 +00:00
|
|
|
MyGUI::VectorWidgetPtr widgets = window->getSkinWidgetsByName("Action");
|
2019-03-02 09:27:59 +00:00
|
|
|
for (MyGUI::Widget* widget : widgets)
|
2014-08-04 15:03:47 +00:00
|
|
|
{
|
2019-03-02 09:27:59 +00:00
|
|
|
if (widget->isUserString("HideWindowOnDoubleClick"))
|
|
|
|
button = widget->castType<MyGUI::Button>();
|
2014-08-04 15:03:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|