Make the "lock window" button to change state visually

actorid
Emanuel Guevel 12 years ago
parent 43d6392921
commit 3ba3c71556

@ -30,7 +30,7 @@ add_openmw_dir (mwgui
formatting inventorywindow container hud countdialog tradewindow settingswindow
confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu
itemselection spellbuyingwindow loadingscreen levelupdialog waitdialog spellcreationdialog
enchantingdialog trainingwindow travelwindow imagebutton
enchantingdialog trainingwindow travelwindow imagebutton exposedwindow
)
add_openmw_dir (mwdialogue

@ -0,0 +1,26 @@
#include "exposedwindow.hpp"
#include "MyGUI_Window.h"
namespace MWGui
{
MyGUI::VectorWidgetPtr ExposedWindow::getSkinWidgetsByName (const std::string &name)
{
return MyGUI::Widget::getSkinWidgetsByName (name);
}
MyGUI::Widget* ExposedWindow::getSkinWidget(const std::string & _name, bool _throw)
{
MyGUI::VectorWidgetPtr widgets = getSkinWidgetsByName (_name);
if (widgets.empty())
{
MYGUI_ASSERT( ! _throw, "widget name '" << _name << "' not found in skin of layout '" << getName() << "'");
return nullptr;
}
else
{
return widgets[0];
}
}
}

@ -0,0 +1,26 @@
#ifndef MWGUI_EXPOSEDWINDOW_H
#define MWGUI_EXPOSEDWINDOW_H
#include "MyGUI_Window.h"
namespace MWGui
{
/**
* @brief subclass to provide access to some Widget internals.
*/
class ExposedWindow : public MyGUI::Window
{
MYGUI_RTTI_DERIVED(ExposedWindow)
public:
MyGUI::VectorWidgetPtr getSkinWidgetsByName (const std::string &name);
MyGUI::Widget* getSkinWidget(const std::string & _name, bool _throw = true);
///< Get a widget defined in the inner skin of this window.
};
}
#endif

@ -2,6 +2,8 @@
#include "../mwbase/windowmanager.hpp"
#include "exposedwindow.hpp"
using namespace MWGui;
WindowPinnableBase::WindowPinnableBase(const std::string& parLayout, MWBase::WindowManager& parWindowManager)
@ -9,6 +11,9 @@ WindowPinnableBase::WindowPinnableBase(const std::string& parLayout, MWBase::Win
{
MyGUI::WindowPtr t = static_cast<MyGUI::WindowPtr>(mMainWidget);
t->eventWindowButtonPressed += MyGUI::newDelegate(this, &WindowPinnableBase::onWindowButtonPressed);
ExposedWindow* window = static_cast<ExposedWindow*>(mMainWidget);
mPinButton = window->getSkinWidget ("Button");
}
void WindowPinnableBase::onWindowButtonPressed(MyGUI::Window* sender, const std::string& eventName)
@ -16,6 +21,12 @@ void WindowPinnableBase::onWindowButtonPressed(MyGUI::Window* sender, const std:
if ("PinToggle" == eventName)
{
mPinned = !mPinned;
if (mPinned)
mPinButton->changeWidgetSkin ("PinDown");
else
mPinButton->changeWidgetSkin ("PinUp");
onPinToggled();
}

@ -19,6 +19,7 @@ namespace MWGui
protected:
virtual void onPinToggled() = 0;
MyGUI::Widget* mPinButton;
bool mPinned;
bool mVisible;
};

@ -52,6 +52,7 @@
#include "enchantingdialog.hpp"
#include "trainingwindow.hpp"
#include "imagebutton.hpp"
#include "exposedwindow.hpp"
using namespace MWGui;
@ -127,6 +128,7 @@ WindowManager::WindowManager(
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::AutoSizedTextBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::AutoSizedButton>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::ImageButton>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::ExposedWindow>("Widget");
MyGUI::LanguageManager::getInstance().eventRequestTag = MyGUI::newDelegate(this, &WindowManager::onRetrieveTag);

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<Widget type="Window" skin="MW_Window_Pinnable" layer="Windows" position="0 0 600 300" name="_Main">
<Widget type="ExposedWindow" skin="MW_Window_Pinnable" layer="Windows" position="0 0 600 300" name="_Main">
<Widget type="Widget" skin="" position="0 0 224 223" align="Left Top" name="LeftPane">

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<Widget type="Window" skin="MW_Window_Pinnable" layer="Windows" position="0 0 300 300" name="_Main">
<Widget type="ExposedWindow" skin="MW_Window_Pinnable" layer="Windows" position="0 0 300 300" name="_Main">
<!-- Local map -->
<Widget type="ScrollView" skin="MW_MapView" position="0 0 284 264" align="ALIGN_STRETCH" name="LocalMap">

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<Widget type="Window" skin="MW_Window_Pinnable" layer="Windows" position="0 0 300 600" name="_Main">
<Widget type="ExposedWindow" skin="MW_Window_Pinnable" layer="Windows" position="0 0 300 600" name="_Main">
<!-- Effect box-->
<Widget type="Widget" skin="MW_Box" position="8 8 268 24" align="Left Top HStretch">

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<Widget type="Window" skin="MW_Window_Pinnable" layer="Windows" position="0 0 500 342" name="_Main">
<Widget type="ExposedWindow" skin="MW_Window_Pinnable" layer="Windows" position="0 0 500 342" name="_Main">
<Widget type="Widget" skin="" name="LeftPane" position="0 0 220 342">

@ -8,6 +8,18 @@
</BasisSkin>
</Skin>
<!-- Define the background for pin button -->
<Skin name = "PinUp" size = "16 16" texture = "textures\menu_rightbuttondown_center.dds">
<BasisSkin type="MainSkin" offset = "0 0 16 16">
<State name="normal" offset = "0 0 16 16"/>
</BasisSkin>
</Skin>
<Skin name = "PinDown" size = "8 8" texture = "transparent.png">
<BasisSkin type="MainSkin" offset = "0 0 8 8">
<State name="normal" offset = "0 0 8 8"/>
</BasisSkin>
</Skin>
<!-- Defines a pure black background -->
<Skin name = "DialogBG" size = "8 8" texture = "black.png">
<BasisSkin type="MainSkin" offset = "0 0 8 8">
@ -473,7 +485,7 @@
<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">
<Child type="Button" skin="PinUp" offset="230 4 21 19" align="ALIGN_RIGHT ALIGN_TOP" name="Button">
<Property key="Event" value="PinToggle"/>
</Child>
</Skin>

Loading…
Cancel
Save