Split window caption bars so that the caption can be transparent (Fixes #531)
Fix transparent window background not applying to the header bar (Fixes #2294)openmw-35
parent
60f722b0a9
commit
4921c6ef9e
@ -0,0 +1,58 @@
|
||||
#include "windowcaption.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace Gui
|
||||
{
|
||||
|
||||
WindowCaption::WindowCaption()
|
||||
: mLeft(NULL)
|
||||
, mRight(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
void WindowCaption::initialiseOverride()
|
||||
{
|
||||
Base::initialiseOverride();
|
||||
|
||||
assignWidget(mLeft, "Left");
|
||||
assignWidget(mRight, "Right");
|
||||
|
||||
assignWidget(mClient, "Client");
|
||||
if (!mClient)
|
||||
throw std::runtime_error("WindowCaption needs an EditBox Client widget in its skin");
|
||||
}
|
||||
|
||||
void WindowCaption::setCaption(const MyGUI::UString &_value)
|
||||
{
|
||||
EditBox::setCaption(_value);
|
||||
align();
|
||||
}
|
||||
|
||||
void WindowCaption::setSize(const MyGUI::IntSize& _value)
|
||||
{
|
||||
Base::setSize(_value);
|
||||
align();
|
||||
}
|
||||
|
||||
void WindowCaption::setCoord(const MyGUI::IntCoord& _value)
|
||||
{
|
||||
Base::setCoord(_value);
|
||||
align();
|
||||
}
|
||||
|
||||
void WindowCaption::align()
|
||||
{
|
||||
MyGUI::IntSize textSize = getTextSize();
|
||||
MyGUI::Widget* caption = mClient;
|
||||
caption->setSize(textSize.width + 24, caption->getHeight());
|
||||
|
||||
int barwidth = (getWidth()-caption->getWidth())/2;
|
||||
caption->setPosition(barwidth, caption->getTop());
|
||||
if (mLeft)
|
||||
mLeft->setCoord(0, mLeft->getTop(), barwidth, mLeft->getHeight());
|
||||
if (mRight)
|
||||
mRight->setCoord(barwidth + caption->getWidth(), mRight->getTop(), barwidth, mRight->getHeight());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
#ifndef OPENMW_WIDGETS_WINDOWCAPTION_H
|
||||
#define OPENMW_WIDGETS_WINDOWCAPTION_H
|
||||
|
||||
#include <MyGUI_EditBox.h>
|
||||
|
||||
namespace Gui
|
||||
{
|
||||
|
||||
/// Window caption that automatically adjusts "Left" and "Right" widgets in its skin
|
||||
/// based on the text size of the caption in the middle
|
||||
class WindowCaption : public MyGUI::EditBox
|
||||
{
|
||||
MYGUI_RTTI_DERIVED(WindowCaption)
|
||||
public:
|
||||
WindowCaption();
|
||||
|
||||
virtual void setCaption(const MyGUI::UString &_value);
|
||||
virtual void initialiseOverride();
|
||||
|
||||
virtual void setSize(const MyGUI::IntSize& _value);
|
||||
virtual void setCoord(const MyGUI::IntCoord& _value);
|
||||
|
||||
private:
|
||||
MyGUI::Widget* mLeft;
|
||||
MyGUI::Widget* mRight;
|
||||
|
||||
void align();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue