From bfab477aead2b4376e9caa193dca2c62c2ff26f9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 8 May 2012 01:03:20 +0300 Subject: Add titlepadding option to theme file. Now used only in shortcuts window without title bar. --- src/gui/shortcutwindow.cpp | 11 ++++++++++- src/gui/theme.cpp | 13 +++++++++---- src/gui/theme.h | 6 +++++- src/gui/widgets/window.h | 3 ++- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp index 0e968efef..4d7443037 100644 --- a/src/gui/shortcutwindow.cpp +++ b/src/gui/shortcutwindow.cpp @@ -26,6 +26,7 @@ #include "logger.h" #include "gui/setup.h" +#include "gui/theme.h" #include "gui/widgets/layout.h" #include "gui/widgets/scrollarea.h" @@ -59,7 +60,15 @@ ShortcutWindow::ShortcutWindow(const std::string &title, { setWindowName(title); // no title presented, title bar is padding so window can be moved. - gcn::Window::setTitleBarHeight(gcn::Window::getPadding() + 1); + if (mSkin) + { + gcn::Window::setTitleBarHeight(gcn::Window::getPadding() + + mSkin->getTitlePadding()); + } + else + { + gcn::Window::setTitleBarHeight(gcn::Window::getPadding()); + } setShowTitle(false); setResizable(true); setDefaultVisible(false); diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 4112a702f..311863f41 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -65,7 +65,7 @@ static void initDefaultThemePath() Skin::Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown, const std::string &filePath, - const std::string &name, int padding): + const std::string &name, int padding, int titlePadding): instances(0), mFilePath(filePath), mName(name), @@ -73,8 +73,10 @@ Skin::Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown, mCloseImage(close), mStickyImageUp(stickyUp), mStickyImageDown(stickyDown), - mPadding(padding) -{} + mPadding(padding), + mTitlePadding(titlePadding) +{ +} Skin::~Skin() { @@ -337,6 +339,7 @@ Skin *Theme::readSkin(const std::string &filename) ImageRect border; memset(&border, 0, sizeof(ImageRect)); int padding = 3; + int titlePadding = 4; // iterate 's for_each_xml_child_node(widgetNode, rootNode) @@ -485,6 +488,8 @@ Skin *Theme::readSkin(const std::string &filename) partNode, "name", ""); if (name == "padding") padding = XML::getProperty(partNode, "value", 3); + else if (name == "titlePadding") + titlePadding = XML::getProperty(partNode, "value", 4); } } } @@ -514,7 +519,7 @@ Skin *Theme::readSkin(const std::string &filename) } Skin *skin = new Skin(border, closeImage, stickyImageUp, stickyImageDown, - filename, "", padding); + filename, "", padding, titlePadding); skin->updateAlpha(mMinimumOpacity); return skin; } diff --git a/src/gui/theme.h b/src/gui/theme.h index c547e5351..8c5675454 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -44,7 +44,7 @@ class Skin public: Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown, const std::string &filePath, const std::string &name = "", - int padding = 3); + int padding = 3, int titlePadding = 4); ~Skin(); @@ -98,6 +98,9 @@ class Skin int getPadding() const { return mPadding; } + int getTitlePadding() const + { return mTitlePadding; } + int instances; private: @@ -108,6 +111,7 @@ class Skin Image *mStickyImageUp; /**< Sticky Button Image */ Image *mStickyImageDown; /**< Sticky Button Image */ int mPadding; + int mTitlePadding; }; class Theme : public Palette, public ConfigListener diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 6fa47dedc..13883980e 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -403,6 +403,8 @@ class Window : public gcn::Window, gcn::WidgetListener protected: bool canMove(); + Skin *mSkin; /**< Skin in use by this window */ + private: enum ResizeHandles { @@ -452,7 +454,6 @@ class Window : public gcn::Window, gcn::WidgetListener static int mouseResize; /**< Active resize handles */ static int instances; /**< Number of Window instances */ - Skin *mSkin; /**< Skin in use by this window */ /** * The width of the resize border. Is independent of the actual window -- cgit v1.2.3-70-g09d2