diff options
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/container.cpp | 15 | ||||
-rw-r--r-- | src/gui/widgets/container.h | 13 | ||||
-rw-r--r-- | src/gui/widgets/desktop.cpp | 43 | ||||
-rw-r--r-- | src/gui/widgets/desktop.h | 4 | ||||
-rw-r--r-- | src/gui/widgets/popup.cpp | 15 | ||||
-rw-r--r-- | src/gui/widgets/popup.h | 5 | ||||
-rw-r--r-- | src/gui/widgets/resizegrip.cpp | 12 | ||||
-rw-r--r-- | src/gui/widgets/window.cpp | 6 |
8 files changed, 89 insertions, 24 deletions
diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp index e1b99af7..11566a4a 100644 --- a/src/gui/widgets/container.cpp +++ b/src/gui/widgets/container.cpp @@ -54,3 +54,18 @@ ContainerPlacer Container::getPlacer(int x, int y) { return ContainerPlacer(this, &getLayout().at(x, y)); } + + +void Container::updateLayout() +{ + const gcn::Rectangle area = getChildrenArea(); + int w = area.width; + int h = area.height; + getLayout().reflow(w, h); +} + +void Container::clearLayout() +{ + delete mLayoutHelper; + mLayoutHelper = 0; +} diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h index 46b719a1..0f1d1bb7 100644 --- a/src/gui/widgets/container.h +++ b/src/gui/widgets/container.h @@ -44,7 +44,6 @@ class Container : public gcn::Container Container(); ~Container(); - protected: /** * Gets the layout handler for this container. */ @@ -60,6 +59,18 @@ class Container : public gcn::Container */ ContainerPlacer getPlacer(int x, int y); + /** + * Updates the layout to match the available size in the container + * (happens automatically on resizes). + */ + void updateLayout(); + + /** + * Removes the layout, making it forget about any widgets (needed when + * reusing a container with new widgets). + */ + void clearLayout(); + private: LayoutHelper *mLayoutHelper; }; diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 07d1d887..c9974fec 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -32,12 +32,16 @@ #include "resources/image.h" #include "resources/resourcemanager.h" +#include "resources/theme.h" #include "resources/wallpaper.h" #include "utils/stringutils.h" Desktop::Desktop() : mWallpaper(0) + , mBackground(ResourceManager::getInstance()->getImage("graphics/images/bg_image.png")) + , mOverlay(ResourceManager::getInstance()->getImage("graphics/images/bg_overlay.png")) + , mBgSkin(Theme::instance()->load("bg.xml")) { addWidgetListener(this); @@ -59,6 +63,10 @@ Desktop::~Desktop() { if (mWallpaper) mWallpaper->decRef(); + + mBgSkin->instances--; + mBackground->decRef(); + mOverlay->decRef(); } void Desktop::reloadWallpaper() @@ -91,6 +99,41 @@ void Desktop::draw(gcn::Graphics *graphics) getWidth(), getHeight(), false); } + mBgSkin->setAlpha(1.0f); + g->drawImageRect(gcn::Rectangle(5, 5, getWidth() - 10, getHeight() - 10), + mBgSkin->getBorder()); + + gcn::Rectangle innerArea(5 + 64, + 5 + 64, + getWidth() - 10 - 64 * 2, + getHeight() - 10 - 64 * 2); + + if (innerArea.width > 0 && innerArea.height > 0) + { + g->pushClipArea(innerArea); + + float scale = std::max((float) innerArea.width / mBackground->getWidth(), + (float) innerArea.height / mBackground->getHeight()); + + int width = scale * mBackground->getWidth(); + int height = scale * mBackground->getHeight(); + + g->drawRescaledImage(mBackground, 0, 0, + (innerArea.width - width) / 2, + (innerArea.height - height) / 2, + mBackground->getWidth(), + mBackground->getHeight(), + width, height, false); + + g->drawRescaledImage(mOverlay, 0, 0, -1, -1, + mOverlay->getWidth(), + mOverlay->getHeight(), + innerArea.width + 2, + innerArea.height + 2, false); + + g->popClipArea(); + } + // Draw a thin border under the application version... g->setColor(gcn::Color(255, 255, 255, 128)); g->fillRectangle(gcn::Rectangle(mVersionLabel->getDimension())); diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h index 8ecb7e03..e2ff207c 100644 --- a/src/gui/widgets/desktop.h +++ b/src/gui/widgets/desktop.h @@ -29,6 +29,7 @@ #include <guichan/widgetlistener.hpp> class Image; +class Skin; /** * Desktop widget, for drawing a background image and color. @@ -62,6 +63,9 @@ class Desktop : public Container, gcn::WidgetListener void setBestFittingWallpaper(); Image *mWallpaper; + Image *mBackground; + Image *mOverlay; + Skin *mBgSkin; gcn::Label *mVersionLabel; }; diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 1c7cfdd1..f71714ed 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -37,8 +37,8 @@ Popup::Popup(const std::string &name, const std::string &skin): mPopupName(name), - mMinWidth(100), - mMinHeight(40), + mMinWidth(64), + mMinHeight(25), mMaxWidth(graphics->getWidth()), mMaxHeight(graphics->getHeight()) { @@ -47,7 +47,7 @@ Popup::Popup(const std::string &name, const std::string &skin): if (!windowContainer) throw GCN_EXCEPTION("Popup::Popup(): no windowContainer set"); - setPadding(3); + setPadding(8); // Loads the skin mSkin = Theme::instance()->load(skin); @@ -66,11 +66,6 @@ Popup::~Popup() mSkin->instances--; } -void Popup::setWindowContainer(WindowContainer *wc) -{ - windowContainer = wc; -} - void Popup::draw(gcn::Graphics *graphics) { Graphics *g = static_cast<Graphics*>(graphics); @@ -82,7 +77,9 @@ void Popup::draw(gcn::Graphics *graphics) gcn::Rectangle Popup::getChildrenArea() { - return gcn::Rectangle(getPadding(), 0, getWidth() - getPadding() * 2, + return gcn::Rectangle(getPadding(), + getPadding(), + getWidth() - getPadding() * 2, getHeight() - getPadding() * 2); } diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index 5ec6ecd0..0f062ef5 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -65,11 +65,6 @@ class Popup : public Container, public gcn::MouseListener ~Popup(); /** - * Sets the window container to be used by new popups. - */ - static void setWindowContainer(WindowContainer *windowContainer); - - /** * Draws the popup. */ void draw(gcn::Graphics *graphics); diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp index da97ac69..7b37b282 100644 --- a/src/gui/widgets/resizegrip.cpp +++ b/src/gui/widgets/resizegrip.cpp @@ -58,11 +58,11 @@ ResizeGrip::~ResizeGrip() void ResizeGrip::draw(gcn::Graphics *graphics) { - if (config.getFloatValue("guialpha") != mAlpha) - { - mAlpha = config.getFloatValue("guialpha"); - gripImage->setAlpha(mAlpha); - } + //if (config.getFloatValue("guialpha") != mAlpha) + //{ + // mAlpha = config.getFloatValue("guialpha"); + // gripImage->setAlpha(mAlpha); + //} - static_cast<Graphics*>(graphics)->drawImage(gripImage, 0, 0); + //static_cast<Graphics*>(graphics)->drawImage(gripImage, 0, 0); } diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index c8788c75..406f55ef 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -68,8 +68,8 @@ Window::Window(const std::string &caption, bool modal, Window *parent, instances++; setFrameSize(0); - setPadding(3); - setTitleBarHeight(20); + setPadding(5); + setTitleBarHeight(25); // Loads the skin mSkin = Theme::instance()->load(skin); @@ -123,7 +123,7 @@ void Window::draw(gcn::Graphics *graphics) { g->setColor(Theme::getThemeColor(Theme::TEXT)); g->setFont(getFont()); - g->drawText(getCaption(), 7, 5, gcn::Graphics::LEFT); + g->drawText(getCaption(), 7, 10, gcn::Graphics::LEFT); } // Draw Close Button |