mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-01 20:06:40 +00:00
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).
This commit is contained in:
parent
ed58e9e553
commit
d09f0610ea
7 changed files with 141 additions and 5 deletions
|
@ -12,7 +12,7 @@ using namespace MWGui;
|
||||||
const int StatsWindow::lineHeight = 18;
|
const int StatsWindow::lineHeight = 18;
|
||||||
|
|
||||||
StatsWindow::StatsWindow (WindowManager& parWindowManager)
|
StatsWindow::StatsWindow (WindowManager& parWindowManager)
|
||||||
: WindowBase("openmw_stats_window_layout.xml", parWindowManager)
|
: WindowPinnableBase("openmw_stats_window_layout.xml", parWindowManager)
|
||||||
, skillAreaWidget(NULL)
|
, skillAreaWidget(NULL)
|
||||||
, skillClientWidget(NULL)
|
, skillClientWidget(NULL)
|
||||||
, skillScrollerWidget(NULL)
|
, skillScrollerWidget(NULL)
|
||||||
|
|
|
@ -9,13 +9,13 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "../mwmechanics/stat.hpp"
|
#include "../mwmechanics/stat.hpp"
|
||||||
#include "window_base.hpp"
|
#include "window_pinnable_base.hpp"
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
class WindowManager;
|
class WindowManager;
|
||||||
|
|
||||||
class StatsWindow : public WindowBase
|
class StatsWindow : public WindowPinnableBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::pair<std::string, int> Faction;
|
typedef std::pair<std::string, int> Faction;
|
||||||
|
|
31
apps/openmw/mwgui/window_pinnable_base.cpp
Normal file
31
apps/openmw/mwgui/window_pinnable_base.cpp
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
|
24
apps/openmw/mwgui/window_pinnable_base.hpp
Normal file
24
apps/openmw/mwgui/window_pinnable_base.hpp
Normal file
|
@ -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
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<MyGUI type="Layout">
|
<MyGUI type="Layout">
|
||||||
<Widget type="Window" skin="MW_Window" layer="Windows" position="0 0 500 342" name="_Main">
|
<Widget type="Window" skin="MW_Window_Pinnable" layer="Windows" position="0 0 500 342" name="_Main">
|
||||||
|
|
||||||
<!-- Player health stats -->
|
<!-- Player health stats -->
|
||||||
<Widget type="Widget" skin="MW_Box" position="8 8 212 62">
|
<Widget type="Widget" skin="MW_Box" position="8 8 212 62">
|
||||||
|
|
|
@ -289,6 +289,87 @@
|
||||||
</Child>
|
</Child>
|
||||||
</Skin>
|
</Skin>
|
||||||
|
|
||||||
|
<Skin name = "MW_Window_Pinnable" size = "256 54">
|
||||||
|
<Property key="FontName" value = "Default" />
|
||||||
|
<Property key="TextAlign" value = "ALIGN_CENTER" />
|
||||||
|
<Property key="TextColour" value = "0.8 0.8 0.8" />
|
||||||
|
<Property key="Snap" value = "true" />
|
||||||
|
|
||||||
|
<Child type="Widget" skin="BlackBG" offset = "8 28 240 18" align = "ALIGN_STRETCH" name = "Client"/>
|
||||||
|
|
||||||
|
<!-- Outer borders -->
|
||||||
|
<Child type="Widget" skin="TB_T" offset="4 0 248 4" align="ALIGN_TOP ALIGN_HSTRETCH" name="Action">
|
||||||
|
<Property key="Scale" value = "0 1 0 -1"/>
|
||||||
|
</Child>
|
||||||
|
<Child type="Widget" skin="TB_L" offset="0 4 4 46" align="ALIGN_LEFT ALIGN_VSTRETCH" name="Action">
|
||||||
|
<Property key="Scale" value = "1 0 -1 0"/>
|
||||||
|
</Child>
|
||||||
|
<Child type="Widget" skin="TB_B" offset="4 50 248 4" align="ALIGN_BOTTOM ALIGN_HSTRETCH" name="Action">
|
||||||
|
<Property key="Scale" value = "0 0 0 1"/>
|
||||||
|
</Child>
|
||||||
|
<Child type="Widget" skin="TB_R" offset="252 4 4 46" align="ALIGN_RIGHT ALIGN_VSTRETCH" name="Action">
|
||||||
|
<Property key="Scale" value = "0 0 1 0"/>
|
||||||
|
</Child>
|
||||||
|
|
||||||
|
<Child type="Widget" skin="TB_BR" offset="252 50 4 4" align="ALIGN_RIGHT ALIGN_BOTTOM" name="Action">
|
||||||
|
<Property key="Scale" value = "0 0 1 1"/>
|
||||||
|
</Child>
|
||||||
|
<Child type="Widget" skin="TB_BL" offset="0 50 4 4" align="ALIGN_LEFT ALIGN_BOTTOM" name="Action">
|
||||||
|
<Property key="Scale" value = "1 0 -1 1"/>
|
||||||
|
</Child>
|
||||||
|
<Child type="Widget" skin="TB_TR" offset="252 0 4 4" align="ALIGN_RIGHT ALIGN_TOP" name="Action">
|
||||||
|
<Property key="Scale" value = "0 1 1 -1"/>
|
||||||
|
</Child>
|
||||||
|
<Child type="Widget" skin="TB_TL" offset="0 0 4 4" align="ALIGN_LEFT ALIGN_TOP" name="Action">
|
||||||
|
<Property key="Scale" value = "1 1 -1 -1"/>
|
||||||
|
</Child>
|
||||||
|
|
||||||
|
<!-- Inner borders -->
|
||||||
|
<Child type="Widget" skin="TB_T" offset="8 24 240 4" align="ALIGN_TOP ALIGN_HSTRETCH" name="Action">
|
||||||
|
<Property key="Scale" value = "0 1 0 -1"/>
|
||||||
|
</Child>
|
||||||
|
<Child type="Widget" skin="TB_L" offset="4 28 4 18" align="ALIGN_LEFT ALIGN_VSTRETCH" name="Action">
|
||||||
|
<Property key="Scale" value = "1 0 -1 0"/>
|
||||||
|
</Child>
|
||||||
|
<Child type="Widget" skin="TB_B" offset="8 46 240 4" align="ALIGN_BOTTOM ALIGN_HSTRETCH" name="Action">
|
||||||
|
<Property key="Scale" value = "0 0 0 1"/>
|
||||||
|
</Child>
|
||||||
|
<Child type="Widget" skin="TB_R" offset="248 28 4 18" align="ALIGN_RIGHT ALIGN_VSTRETCH" name="Action">
|
||||||
|
<Property key="Scale" value = "0 0 1 0"/>
|
||||||
|
</Child>
|
||||||
|
<Child type="Widget" skin="TB_BR" offset="248 46 4 4" align="ALIGN_BOTTOM ALIGN_RIGHT" name="Action">
|
||||||
|
<Property key="Scale" value = "0 0 1 1"/>
|
||||||
|
</Child>
|
||||||
|
<Child type="Widget" skin="TB_BL" offset="4 46 4 4" align="ALIGN_BOTTOM ALIGN_LEFT" name="Action">
|
||||||
|
<Property key="Scale" value = "1 0 -1 1"/>
|
||||||
|
</Child>
|
||||||
|
<Child type="Widget" skin="TB_TR" offset="248 24 4 4" align="ALIGN_TOP ALIGN_RIGHT" name="Action">
|
||||||
|
<Property key="Scale" value = "0 1 1 -1"/>
|
||||||
|
</Child>
|
||||||
|
<Child type="Widget" skin="TB_TL" offset="4 24 4 4" align="ALIGN_TOP ALIGN_LEFT" name="Action">
|
||||||
|
<Property key="Scale" value = "1 1 -1 -1"/>
|
||||||
|
</Child>
|
||||||
|
|
||||||
|
<!-- Caption -->
|
||||||
|
|
||||||
|
<Child type="Widget" skin="HB_ALL" offset="4 4 248 20" align = "ALIGN_TOP ALIGN_HSTRETCH">
|
||||||
|
<Property key="Scale" value = "1 1 0 0"/>
|
||||||
|
</Child>
|
||||||
|
|
||||||
|
<Child type="TextBox" skin="MW_Caption" offset = "80 4 88 20" align = "ALIGN_HCENTER ALIGN_TOP" name = "Caption">
|
||||||
|
</Child>
|
||||||
|
|
||||||
|
<!-- This invisible button makes it possible to move the
|
||||||
|
window by dragging the caption. -->
|
||||||
|
<Child type="Button" offset="4 4 248 20" align="ALIGN_HSTRETCH ALIGN_TOP" name="Action">
|
||||||
|
<Property key="Scale" value = "1 1 0 0"/>
|
||||||
|
</Child>
|
||||||
|
|
||||||
|
<Child type="Button" skin="BlackBG" offset="230 4 21 19" align="ALIGN_RIGHT ALIGN_TOP" name="Button">
|
||||||
|
<Property key="Event" value="PinToggle"/>
|
||||||
|
</Child>
|
||||||
|
</Skin>
|
||||||
|
|
||||||
<Skin name = "MW_Dialog" size = "256 54">
|
<Skin name = "MW_Dialog" size = "256 54">
|
||||||
<Property key="FontName" value = "Default" />
|
<Property key="FontName" value = "Default" />
|
||||||
<Property key="TextAlign" value = "ALIGN_CENTER" />
|
<Property key="TextAlign" value = "ALIGN_CENTER" />
|
||||||
|
|
|
@ -103,7 +103,7 @@ namespace GUI
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setVisible(bool b)
|
virtual void setVisible(bool b)
|
||||||
{
|
{
|
||||||
mMainWidget->setVisible(b);
|
mMainWidget->setVisible(b);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue