From 0f83e449727a16c178b47262f170e879a22c0981 Mon Sep 17 00:00:00 2001 From: rathnor Date: Thu, 26 Aug 2004 16:37:48 +0000 Subject: fix rendering of bevels for textures with solid textures --- ChangeLog | 2 ++ src/FbTk/Texture.cc | 43 ++++++++++++++++++++++++++++++++++++++++++- src/FbTk/Texture.hh | 4 +++- src/FbTk/ThemeItems.hh | 8 ++++++-- 4 files changed, 53 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 117e7b2..1139bfa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ (Format: Year/Month/Day) Changes for 0.9.10: *04/08/26: + * Fix bevel on solid colour textures (Simon) + FbTk/Texture.hh/cc FbTk/ThemeItems.hh * Make arrow in toolbar buttons scalable size (Simon) - new theme item: toolbar.button.scale: The number is a scale factor, which is divided into 100 to give diff --git a/src/FbTk/Texture.cc b/src/FbTk/Texture.cc index 41314ce..dbf9cf5 100644 --- a/src/FbTk/Texture.cc +++ b/src/FbTk/Texture.cc @@ -22,10 +22,12 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Texture.cc,v 1.8 2004/01/11 21:04:21 fluxgen Exp $ +// $Id: Texture.cc,v 1.9 2004/08/26 16:37:48 rathnor Exp $ +#include "App.hh" #include "Texture.hh" +#include #include #include @@ -100,4 +102,43 @@ void Texture::setFromString(const char * const texture_str) { delete [] ts; } +void Texture::calcHiLoColors(int screen_num) { + Display *disp = FbTk::App::instance()->display(); + XColor xcol; + Colormap colm = DefaultColormap(disp, screen_num); + + xcol.red = (unsigned int) (m_color.red() + + (m_color.red() >> 1)); + if (xcol.red >= 0xff) xcol.red = 0xffff; + else xcol.red *= 0xff; + xcol.green = (unsigned int) (m_color.green() + + (m_color.green() >> 1)); + if (xcol.green >= 0xff) xcol.green = 0xffff; + else xcol.green *= 0xff; + xcol.blue = (unsigned int) (m_color.blue() + + (m_color.blue() >> 1)); + if (xcol.blue >= 0xff) xcol.blue = 0xffff; + else xcol.blue *= 0xff; + + if (! XAllocColor(disp, colm, &xcol)) + xcol.pixel = 0; + + m_hicolor.setPixel(xcol.pixel); + + xcol.red = + (unsigned int) ((m_color.red() >> 2) + + (m_color.red() >> 1)) * 0xff; + xcol.green = + (unsigned int) ((m_color.green() >> 2) + + (m_color.green() >> 1)) * 0xff; + xcol.blue = + (unsigned int) ((m_color.blue() >> 2) + + (m_color.blue() >> 1)) * 0xff; + + if (! XAllocColor(disp, colm, &xcol)) + xcol.pixel = 0; + + m_locolor.setPixel(xcol.pixel); +} + }; // end namespace FbTk diff --git a/src/FbTk/Texture.hh b/src/FbTk/Texture.hh index 336086a..1ee3e79 100644 --- a/src/FbTk/Texture.hh +++ b/src/FbTk/Texture.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Texture.hh,v 1.6 2003/12/16 17:06:52 fluxgen Exp $ +// $Id: Texture.hh,v 1.7 2004/08/26 16:37:48 rathnor Exp $ #ifndef FBTK_TEXTURE_HH #define FBTK_TEXTURE_HH @@ -83,6 +83,8 @@ public: FbPixmap &pixmap() { return m_pixmap; } + void calcHiLoColors(int screen_num); + const Color &color() const { return m_color; } const Color &colorTo() const { return m_color_to; } const Color &hiColor() const { return m_hicolor; } diff --git a/src/FbTk/ThemeItems.hh b/src/FbTk/ThemeItems.hh index 57a5f11..f17cba6 100644 --- a/src/FbTk/ThemeItems.hh +++ b/src/FbTk/ThemeItems.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ThemeItems.hh,v 1.6 2004/04/26 15:04:37 rathnor Exp $ +// $Id: ThemeItems.hh,v 1.7 2004/08/26 16:37:48 rathnor Exp $ /// @file implements common theme items @@ -128,7 +128,11 @@ void ThemeItem::load(const std::string *o_name, const std::string if (!m_value.colorTo().setFromString(colorto_name.c_str(), m_tm.screenNum())) m_value.colorTo().setFromString("white", m_tm.screenNum()); - + + + if ((m_value.type() & FbTk::Texture::SOLID) != 0 && (m_value.type() & FbTk::Texture::FLAT) == 0) + m_value.calcHiLoColors(m_tm.screenNum()); + StringUtil::removeFirstWhitespace(pixmap_name); StringUtil::removeTrailingWhitespace(pixmap_name); if (pixmap_name.empty()) { -- cgit v0.11.2