From 3aead4aa07f2b28c5a4d567d6ab53783a9de5556 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 6 Sep 2012 23:12:03 +0300 Subject: Add theme option for title bar height. Option name: titlebarHeight Default value: 20 px --- src/gui/chatwindow.cpp | 2 -- src/gui/shortcutwindow.cpp | 3 +-- src/gui/theme.cpp | 9 ++++++++- src/gui/widgets/window.cpp | 10 +++------- src/gui/widgets/window.h | 7 ++++++- 5 files changed, 18 insertions(+), 13 deletions(-) (limited to 'src/gui') diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 3d1cd86db..87e89591f 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -179,8 +179,6 @@ ChatWindow::ChatWindow(): if (setupWindow) setupWindow->registerWindowForReset(this); - // no title presented, title bar is padding so window can be moved. - setTitleBarHeight(getPadding() + getTitlePadding()); setShowTitle(false); setResizable(true); setDefaultVisible(true); diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp index 1c9525eeb..3a142cbc2 100644 --- a/src/gui/shortcutwindow.cpp +++ b/src/gui/shortcutwindow.cpp @@ -105,8 +105,7 @@ ShortcutWindow::ShortcutWindow(const std::string &title, std::string skinFile, Window("Window", false, nullptr, skinFile) { setWindowName(title); - // no title presented, title bar is padding so window can be moved. - gcn::Window::setTitleBarHeight(gcn::Window::getPadding() + 1); + setTitleBarHeight(getPadding() + getTitlePadding()); setShowTitle(false); setResizable(true); setDefaultVisible(false); diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 26d1e7402..2d21f1a2b 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -431,6 +431,7 @@ Skin *Theme::readSkin(const std::string &filename, const bool full) memset(&images, 0, sizeof(ImageRect)); int padding = 3; int titlePadding = 4; + int titlebarHeight = 20; int closePadding = 3; std::map *const mOptions = new std::map(); @@ -488,6 +489,11 @@ Skin *Theme::readSkin(const std::string &filename, const bool full) { closePadding = XML::getProperty(partNode, "value", 3); } + else if (name == "titlebarHeight") + { + titlebarHeight = XML::getProperty( + partNode, "value", 16); + } else { (*mOptions)[name] = XML::getProperty( @@ -507,8 +513,9 @@ Skin *Theme::readSkin(const std::string &filename, const bool full) dBorders->decRef(); (*mOptions)["closePadding"] = closePadding; + (*mOptions)["titlebarHeight"] = titlebarHeight; - Skin *const skin = new Skin(border, images, filename, "", padding, + Skin *const skin = new Skin(border, images, filename, "", padding, titlePadding, mOptions); skin->updateAlpha(mMinimumOpacity); return skin; diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 2a417c633..58247870f 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -68,6 +68,7 @@ Window::Window(const std::string &caption, const bool modal, mCaptionOffsetX(7), mCaptionOffsetY(5), mCaptionAlign(gcn::Graphics::LEFT), + mTitlePadding(4), mRedraw(true) { logger->log("Window::Window(\"%s\")", caption.c_str()); @@ -91,6 +92,8 @@ Window::Window(const std::string &caption, const bool modal, if (mSkin) { setPadding(mSkin->getPadding()); + setTitlePadding(mSkin->getTitlePadding()); + setTitleBarHeight(getOption("titlebarHeight")); mCaptionOffsetX = getOption("captionoffsetx"); if (!mCaptionOffsetX) mCaptionOffsetX = 7; @@ -1064,10 +1067,3 @@ bool Window::getOptionBool(std::string name) return mSkin->getOption(name) != 0; return 0; } - -int Window::getTitlePadding() const -{ - if (mSkin) - mSkin->getTitlePadding(); - return 4; -} diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 2c6c0ab8e..9cc6acc54 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -408,7 +408,11 @@ class Window : public gcn::Window, private gcn::WidgetListener bool getOptionBool(std::string name); - int getTitlePadding() const; + void setTitlePadding(int p) + { mTitlePadding = p; } + + int getTitlePadding() const + { return mTitlePadding; } Skin *mSkin; /**< Skin in use by this window */ @@ -472,6 +476,7 @@ class Window : public gcn::Window, private gcn::WidgetListener int mCaptionOffsetX; int mCaptionOffsetY; int mCaptionAlign; + int mTitlePadding; bool mRedraw; gcn::Font *mCaptionFont; }; -- cgit v1.2.3-70-g09d2