From 639d8883192accdc502ec11ea2bfee474320c06e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 31 May 2013 13:35:05 +0300 Subject: improve desktop class. --- src/gui/widgets/desktop.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 7f3532381..455b36554 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -45,8 +45,7 @@ Desktop::Desktop(const Widget2 *const widget) : Wallpaper::loadWallpapers(); - std::string appName = branding.getValue("appName", std::string()); - + const std::string appName = branding.getValue("appName", std::string()); if (appName.empty()) { mVersionLabel = new Label(this, FULL_VERSION); @@ -86,11 +85,16 @@ void Desktop::draw(gcn::Graphics *graphics) BLOCK_START("Desktop::draw") Graphics *const g = static_cast(graphics); - if (!mWallpaper || (getWidth() > mWallpaper->getWidth() || - getHeight() > mWallpaper->getHeight())) + const gcn::Rectangle &rect = mDimension; + const int width = rect.width; + const int height = rect.height; + const int wallpWidth = mWallpaper->getWidth(); + const int wallpHeight = mWallpaper->getHeight(); + + if (!mWallpaper || (width > wallpWidth || height > wallpHeight)) { g->setColor(mBackgroundGrayColor); - g->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); + g->fillRectangle(gcn::Rectangle(0, 0, width, height)); } if (mWallpaper) @@ -98,14 +102,14 @@ void Desktop::draw(gcn::Graphics *graphics) if (!imageHelper->useOpenGL()) { g->drawImage(mWallpaper, - (getWidth() - mWallpaper->getWidth()) / 2, - (getHeight() - mWallpaper->getHeight()) / 2); + (width - wallpWidth) / 2, + (height - wallpHeight) / 2); } else { g->drawRescaledImage(mWallpaper, 0, 0, 0, 0, - mWallpaper->getWidth(), mWallpaper->getHeight(), - getWidth(), getHeight(), false); + wallpWidth, wallpHeight, + width, height, false); } } @@ -132,13 +136,17 @@ void Desktop::setBestFittingWallpaper() if (mWallpaper) mWallpaper->decRef(); + const gcn::Rectangle &rect = mDimension; + const int width = rect.width; + const int height = rect.height; + if (!imageHelper->useOpenGL() - && (nWallPaper->getWidth() != getWidth() - || nWallPaper->getHeight() != getHeight())) + && (nWallPaper->getWidth() != width + || nWallPaper->getHeight() != height)) { // We rescale to obtain a fullscreen wallpaper... Image *const newRsclWlPpr = ResourceManager::getInstance() - ->getRescaled(nWallPaper, getWidth(), getHeight()); + ->getRescaled(nWallPaper, width, height); // We replace the resource in the resource manager nWallPaper->decRef(); -- cgit v1.2.3-70-g09d2