diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-02-18 14:34:32 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-02-18 14:34:32 +0000 |
commit | b7d7883ff0f662836b69e132759c78142d1488c4 (patch) | |
tree | ab157ae850d682779c9b668b0321f9bc9cc68af5 | |
parent | 3ac7f63f4ccc7c6dcd6c1b29b4da958c0ef863a6 (diff) | |
download | mana-client-b7d7883ff0f662836b69e132759c78142d1488c4.tar.gz mana-client-b7d7883ff0f662836b69e132759c78142d1488c4.tar.bz2 mana-client-b7d7883ff0f662836b69e132759c78142d1488c4.tar.xz mana-client-b7d7883ff0f662836b69e132759c78142d1488c4.zip |
Improve window borders and speed up alpha property by not setting alpha each
time the images are drawn.
-rw-r--r-- | src/gui/window.cpp | 36 | ||||
-rw-r--r-- | src/resources/image.cpp | 11 |
2 files changed, 23 insertions, 24 deletions
diff --git a/src/gui/window.cpp b/src/gui/window.cpp index f06866d5..310da823 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -50,10 +50,10 @@ Window::Window(const std::string& text, bool modal, Window *parent): dBorders = resman->getImage("core/graphics/gui/vscroll_grey.png"); dBackground = resman->getImage("core/graphics/gui/bg_quad_dis.png"); - dUpperBorder = dBorders->getSubImage(4,0,1,3); - dLeftBorder = dBorders->getSubImage(0,4,3,1); - dRightBorder = dBorders->getSubImage(8,4,3,1); - dLowerBorder = dBorders->getSubImage(8,15,1,3); + dUpperBorder = dBorders->getSubImage(4, 0, 3, 4); + dLeftBorder = dBorders->getSubImage(0, 4, 4, 10); + dRightBorder = dBorders->getSubImage(7, 4, 4, 10); + dLowerBorder = dBorders->getSubImage(4, 15, 3, 4); dBackground->setAlpha(0.7f); dBorders->setAlpha(0.7f); @@ -99,26 +99,26 @@ void Window::setWindowContainer(WindowContainer *wc) void Window::draw(gcn::Graphics* graphics) { - int x, y; getAbsolutePosition(x, y); // Draw the background - dBackground->drawPattern(screen, x, y, getWidth(), getHeight()); + dBackground->drawPattern( + screen, x + 4, y + 4, getWidth() - 8, getHeight() - 8); + // Draw the borders - dBorders->draw(screen, 0, 0, x-1, y-1, 4, 4); // Top-Left - dBorders->draw(screen, 7, 0, x+getWidth()-3, y-1, 4, 4); // Top-Right - dBorders->draw(screen, 7, 15, x+getWidth()-3, y+getHeight()-3, 4, 4); // Bottom-Right - dBorders->draw(screen, 0, 15, x-1, y+getHeight()-3, 4, 4); // Bottom-Left + dBorders->draw(screen, 0, 0, x, y, 4, 4); // Top-Left + dBorders->draw(screen, 7, 0, x + getWidth() - 4, y, 4, 4); // Top-Right + dBorders->draw(screen, 7, 15, + x + getWidth() - 4, y + getHeight() - 4, 4, 4); // Bottom-Right + dBorders->draw(screen, 0, 15, x, y + getHeight() - 4, 4, 4); // Bottom-Left - // Upper Border - dUpperBorder->drawPattern(screen, x+3, y-1, getWidth()-4-2, 3); - // Left Border - dLeftBorder->drawPattern(screen, x-1, y+3, 3, getHeight()-4-2); - // Right Border - dRightBorder->drawPattern(screen, x+getWidth()-2, y+3, 3, getHeight()-4-2); - // Lower Border - dLowerBorder->drawPattern(screen, x+3, y+getHeight()-2, getWidth()-4-2, 3); + dUpperBorder->drawPattern(screen, x + 4, y, getWidth() - 8, 4); + dLeftBorder->drawPattern(screen, x, y + 4, 4, getHeight() - 8); + dRightBorder->drawPattern( + screen, x + getWidth() - 4, y + 4, 4, getHeight() - 8); + dLowerBorder->drawPattern( + screen, x + 4, y + getHeight() - 4, getWidth() - 8, 4); // Draw title graphics->setFont(getFont()); diff --git a/src/resources/image.cpp b/src/resources/image.cpp index efd126b1..2ec867ec 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -252,9 +252,6 @@ bool Image::draw(SDL_Surface *screen, int srcX, int srcY, int dstX, int dstY, // Check that preconditions for blitting are met. if (screen == NULL || image == NULL) return false; - // Set the alpha value this image is drawn at - SDL_SetAlpha(image, SDL_SRCALPHA, (int)(255 * alpha)); - SDL_Rect dstRect; SDL_Rect srcRect; dstRect.x = dstX; dstRect.y = dstY; @@ -330,6 +327,11 @@ void Image::drawPattern(SDL_Surface *screen, int x, int y, int w, int h) void Image::setAlpha(float alpha) { this->alpha = alpha; + +#ifndef USE_OPENGL + // Set the alpha value this image is drawn at + SDL_SetAlpha(image, SDL_SRCALPHA | SDL_RLEACCEL, (int)(255 * alpha)); +#endif } float Image::getAlpha() @@ -391,9 +393,6 @@ bool SubImage::draw(SDL_Surface *screen, int srcX, int srcY, // Check that preconditions for blitting are met. if (screen == NULL || image == NULL) return false; - // Set the alpha value this image is drawn at - SDL_SetAlpha(image, SDL_SRCALPHA, (int)(255 * alpha)); - SDL_Rect dstRect; SDL_Rect srcRect; dstRect.x = dstX; dstRect.y = dstY; |