Add basic windows pinning
Create WindowPinnableBase class for windows which should be allowed to be pinned. Add skin for pinnable windows - currently just a copy of normal window with 1 extra button (hopefully this can be improved later). Handle clicking on PinToggle button (pinning/unpinning a window).actorid
parent
ed58e9e553
commit
d09f0610ea
@ -0,0 +1,31 @@
|
||||
#include "window_pinnable_base.hpp"
|
||||
#include "window_manager.hpp"
|
||||
|
||||
using namespace MWGui;
|
||||
|
||||
WindowPinnableBase::WindowPinnableBase(const std::string& parLayout, WindowManager& parWindowManager)
|
||||
: WindowBase(parLayout, parWindowManager), mIsPinned(false)
|
||||
{
|
||||
MyGUI::WindowPtr t = static_cast<MyGUI::WindowPtr>(mMainWidget);
|
||||
t->eventWindowButtonPressed += MyGUI::newDelegate(this, &WindowPinnableBase::onWindowButtonPressed);
|
||||
}
|
||||
|
||||
void WindowPinnableBase::setVisible(bool b)
|
||||
{
|
||||
// Pinned windows can not be hidden
|
||||
if (mIsPinned && !b)
|
||||
return;
|
||||
|
||||
WindowBase::setVisible(b);
|
||||
}
|
||||
|
||||
void WindowPinnableBase::onWindowButtonPressed(MyGUI::Window* sender, const std::string& eventName)
|
||||
{
|
||||
if ("PinToggle" == eventName)
|
||||
{
|
||||
mIsPinned = !mIsPinned;
|
||||
}
|
||||
|
||||
eventDone(this);
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
#ifndef MWGUI_WINDOW_PINNABLE_BASE_H
|
||||
#define MWGUI_WINDOW_PINNABLE_BASE_H
|
||||
|
||||
#include "window_base.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
class WindowManager;
|
||||
|
||||
class WindowPinnableBase: public WindowBase
|
||||
{
|
||||
public:
|
||||
WindowPinnableBase(const std::string& parLayout, WindowManager& parWindowManager);
|
||||
void setVisible(bool b);
|
||||
|
||||
private:
|
||||
void onWindowButtonPressed(MyGUI::Window* sender, const std::string& eventName);
|
||||
|
||||
bool mIsPinned;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue