add textures, render the textures color for now too!
This commit is contained in:
parent
0348a2f3ab
commit
25a5b72909
6 changed files with 115 additions and 21 deletions
|
@ -9,7 +9,7 @@ INCLUDES= -I../src
|
||||||
noinst_LTLIBRARIES=libotk.la
|
noinst_LTLIBRARIES=libotk.la
|
||||||
|
|
||||||
libotk_la_SOURCES=rendercontrol.cc truerendercontrol.cc surface.cc \
|
libotk_la_SOURCES=rendercontrol.cc truerendercontrol.cc surface.cc \
|
||||||
rendertexture.cc renderstyle.cc rendercolor.cc \
|
renderstyle.cc rendercolor.cc \
|
||||||
color.cc display.cc font.cc gccache.cc image.cc \
|
color.cc display.cc font.cc gccache.cc image.cc \
|
||||||
property.cc imagecontrol.cc rect.cc screeninfo.cc \
|
property.cc imagecontrol.cc rect.cc screeninfo.cc \
|
||||||
texture.cc timer.cc style.cc \
|
texture.cc timer.cc style.cc \
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
#ifndef __renderstyle_hh
|
#ifndef __renderstyle_hh
|
||||||
#define __renderstyle_hh
|
#define __renderstyle_hh
|
||||||
|
|
||||||
namespace otk {
|
|
||||||
|
|
||||||
#include "rendertexture.hh"
|
#include "rendertexture.hh"
|
||||||
|
|
||||||
|
namespace otk {
|
||||||
|
|
||||||
class RenderStyle {
|
class RenderStyle {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,17 @@ int main(int argc, char **argv)
|
||||||
otk::Application app(argc, argv);
|
otk::Application app(argc, argv);
|
||||||
otk::AppWidget foo(&app);
|
otk::AppWidget foo(&app);
|
||||||
foo.resize(600, 500);
|
foo.resize(600, 500);
|
||||||
|
|
||||||
otk::RenderTexture tex;
|
otk::RenderColor color(0, 0xff, 0x20, 0x20);
|
||||||
|
otk::RenderTexture tex(false,
|
||||||
|
otk::RenderTexture::Flat,
|
||||||
|
false,
|
||||||
|
otk::RenderTexture::Solid,
|
||||||
|
false,
|
||||||
|
&color,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0);
|
||||||
foo.setTexture(&tex);
|
foo.setTexture(&tex);
|
||||||
|
|
||||||
foo.show();
|
foo.show();
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include "../config.h"
|
|
||||||
#endif // HAVE_CONFIG_H
|
|
||||||
|
|
||||||
#include "rendertexture.hh"
|
|
||||||
|
|
||||||
namespace otk {
|
|
||||||
|
|
||||||
}
|
|
|
@ -2,9 +2,107 @@
|
||||||
#ifndef __rendertexture_hh
|
#ifndef __rendertexture_hh
|
||||||
#define __rendertexture_hh
|
#define __rendertexture_hh
|
||||||
|
|
||||||
|
#include "rendercolor.hh"
|
||||||
|
|
||||||
namespace otk {
|
namespace otk {
|
||||||
|
|
||||||
|
//! Superclass for all the Textures
|
||||||
class RenderTexture {
|
class RenderTexture {
|
||||||
|
public:
|
||||||
|
enum ReliefType {
|
||||||
|
Flat,
|
||||||
|
Raised,
|
||||||
|
Sunken
|
||||||
|
};
|
||||||
|
enum BevelType {
|
||||||
|
Bevel1,
|
||||||
|
Bevel2
|
||||||
|
};
|
||||||
|
enum GradientType {
|
||||||
|
Solid,
|
||||||
|
Horizontal,
|
||||||
|
Vertical,
|
||||||
|
Diagonal,
|
||||||
|
CrossDiagonal,
|
||||||
|
PipeCross,
|
||||||
|
Rectangle,
|
||||||
|
Pyramid,
|
||||||
|
Elliptic
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! If true, the texture is not rendered at all, so all options are ignored
|
||||||
|
bool _parent_relative;
|
||||||
|
//! The relief type of the texture
|
||||||
|
ReliefType _relief;
|
||||||
|
//! If a flat border is drawn on the outside, ignored for all ReliefType
|
||||||
|
//! values except ReliefType::Flat
|
||||||
|
bool _border;
|
||||||
|
//! The type of gradient to fill the texture with (if any)
|
||||||
|
GradientType _gradient;
|
||||||
|
//! If interlace lines should be drawn over the texture
|
||||||
|
bool _interlaced;
|
||||||
|
|
||||||
|
//! The base color for the texture, the only color when the texture is solid.
|
||||||
|
//! This must always be defined
|
||||||
|
const RenderColor *_color;
|
||||||
|
//! The shadow color for the bevel. This must be defined if
|
||||||
|
//! RenderTexture::relief is not RenderTexture::ReliefType::Flat
|
||||||
|
const RenderColor *_bevel_dark_color;
|
||||||
|
//! The light color for the bevel. This must be defined if
|
||||||
|
//! RenderTexture::relief is not RenderTexture::ReliefType::Flat
|
||||||
|
const RenderColor *_bevel_light_color;
|
||||||
|
//! The color for the flat border if RenderTexture::border is true. This must
|
||||||
|
//! be defined if it is true
|
||||||
|
const RenderColor *_border_color;
|
||||||
|
|
||||||
|
public:
|
||||||
|
RenderTexture(bool parent_relative, ReliefType relief, bool border,
|
||||||
|
GradientType gradient, bool interlaced,
|
||||||
|
const RenderColor *color, const RenderColor *bevel_dark_color,
|
||||||
|
const RenderColor *bevel_light_color,
|
||||||
|
const RenderColor *border_color)
|
||||||
|
: _parent_relative(parent_relative),
|
||||||
|
_relief(relief),
|
||||||
|
_border(border),
|
||||||
|
_gradient(gradient),
|
||||||
|
_interlaced(interlaced),
|
||||||
|
_color(color),
|
||||||
|
_bevel_dark_color(bevel_dark_color),
|
||||||
|
_bevel_light_color(bevel_light_color),
|
||||||
|
_border_color(border_color)
|
||||||
|
{
|
||||||
|
assert(_relief == Flat || (_bevel_dark_color && _bevel_light_color));
|
||||||
|
assert(!_border || _border_color);
|
||||||
|
assert(_color);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! If true, the texture is not rendered at all, so all options are ignored
|
||||||
|
inline bool parentRelative() const { return _parent_relative; }
|
||||||
|
//! The relief type of the texture
|
||||||
|
inline ReliefType relief() const { return _relief; }
|
||||||
|
//! If a flat border is drawn on the outside, ignored for all ReliefType
|
||||||
|
//! values except ReliefType::Flat
|
||||||
|
inline bool border() const { return _border; }
|
||||||
|
//! The type of gradient to fill the texture with (if any)
|
||||||
|
inline GradientType gradient() const { return _gradient; }
|
||||||
|
//! If interlace lines should be drawn over the texture
|
||||||
|
inline bool interlaced() const { return _interlaced; }
|
||||||
|
|
||||||
|
//! The base color for the texture, the only color when the texture is solid.
|
||||||
|
//! This must always be defined
|
||||||
|
inline const RenderColor& color() const { return *_color; }
|
||||||
|
//! The shadow color for the bevel. This must be defined if
|
||||||
|
//! RenderTexture::relief is not RenderTexture::ReliefType::Flat
|
||||||
|
inline const RenderColor& bevelDarkColor() const
|
||||||
|
{ return *_bevel_dark_color; }
|
||||||
|
//! The light color for the bevel. This must be defined if
|
||||||
|
//! RenderTexture::relief is not RenderTexture::ReliefType::Flat
|
||||||
|
inline const RenderColor& bevelLightColor() const
|
||||||
|
{ return *_bevel_light_color; }
|
||||||
|
//! The color for the flat border if RenderTexture::border is true. This must
|
||||||
|
//! be defined if it is true
|
||||||
|
inline const RenderColor& borderColor() const { return *_border_color; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,7 @@
|
||||||
#include "display.hh"
|
#include "display.hh"
|
||||||
#include "screeninfo.hh"
|
#include "screeninfo.hh"
|
||||||
#include "surface.hh"
|
#include "surface.hh"
|
||||||
|
#include "rendertexture.hh"
|
||||||
#include "rendercolor.hh"
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#ifdef HAVE_STDLIB_H
|
#ifdef HAVE_STDLIB_H
|
||||||
|
@ -103,8 +102,6 @@ static inline void renderPixel(XImage *im, unsigned char *dp,
|
||||||
void TrueRenderControl::drawBackground(Surface& sf,
|
void TrueRenderControl::drawBackground(Surface& sf,
|
||||||
const RenderTexture &texture) const
|
const RenderTexture &texture) const
|
||||||
{
|
{
|
||||||
(void)texture;
|
|
||||||
|
|
||||||
assert(sf._screen == _screen);
|
assert(sf._screen == _screen);
|
||||||
|
|
||||||
int w = sf.width(), h = sf.height();
|
int w = sf.width(), h = sf.height();
|
||||||
|
@ -130,7 +127,8 @@ void TrueRenderControl::drawBackground(Surface& sf,
|
||||||
im->data = (char*) data;
|
im->data = (char*) data;
|
||||||
|
|
||||||
// sf.setPixmap(im);
|
// sf.setPixmap(im);
|
||||||
sf.setPixmap(RenderColor(_screen, 0xff, 0xff, 0));
|
sf.setPixmap(texture.color());
|
||||||
|
// sf.setPixmap(RenderColor(_screen, 0xff, 0xff, 0));
|
||||||
|
|
||||||
delete [] im->data;
|
delete [] im->data;
|
||||||
im->data = NULL;
|
im->data = NULL;
|
||||||
|
|
Loading…
Reference in a new issue