fix rendering of bevels for textures with solid textures

This commit is contained in:
rathnor 2004-08-26 16:37:48 +00:00
parent 346a6598a6
commit 0f83e44972
4 changed files with 53 additions and 4 deletions

View file

@ -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: <number>
The number is a scale factor, which is divided into 100 to give

View file

@ -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 <X11/Xlib.h>
#include <cstring>
#include <cctype>
@ -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

View file

@ -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; }

View file

@ -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<FbTk::Texture>::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()) {