* Don't use a single cairo_pattern to store the window gradient for ''all'' windows
* Use a separate cairo_pattern for each window to store the window gradient in git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6007 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
a2a22b3804
commit
c661cb9bc4
|
@ -24,8 +24,9 @@
|
||||||
#if defined(LIB_COMPILE)
|
#if defined(LIB_COMPILE)
|
||||||
# include <cairo.h>
|
# include <cairo.h>
|
||||||
#else
|
#else
|
||||||
// Forward declaration to allow pointers
|
// Forward declarations to allow pointers
|
||||||
typedef struct _cairo cairo_t;
|
typedef struct _cairo cairo_t;
|
||||||
|
typedef struct _cairo_pattern cairo_pattern_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // __INCLUDED_BETAWIDGET_INTERNAL_CAIRO_H__
|
#endif // __INCLUDED_BETAWIDGET_INTERNAL_CAIRO_H__
|
||||||
|
|
|
@ -26,7 +26,6 @@ static vector *windowVector = NULL;
|
||||||
static int screenWidth = -1, screenHeight = -1;
|
static int screenWidth = -1, screenHeight = -1;
|
||||||
|
|
||||||
static const float borderRadius = 20;
|
static const float borderRadius = 20;
|
||||||
cairo_pattern_t *windowPattern = NULL;
|
|
||||||
|
|
||||||
const classInfo windowClassInfo =
|
const classInfo windowClassInfo =
|
||||||
{
|
{
|
||||||
|
@ -64,30 +63,17 @@ static void windowInitVtbl(window *self)
|
||||||
self->vtbl = &vtbl;
|
self->vtbl = &vtbl;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void windowInitOnce()
|
|
||||||
{
|
|
||||||
static bool initialised = false;
|
|
||||||
|
|
||||||
if (!initialised)
|
|
||||||
{
|
|
||||||
// Patterns initialization
|
|
||||||
windowPattern = cairo_pattern_create_linear(0, 0, 0, 384);
|
|
||||||
cairo_pattern_add_color_stop_rgba(windowPattern, 0, 0.000000, 0.000000, 0.235294, 0.75);
|
|
||||||
cairo_pattern_add_color_stop_rgba(windowPattern, 0.2, 0.176470, 0.176470, 0.372549, 0.8);
|
|
||||||
cairo_pattern_add_color_stop_rgba(windowPattern, 0.6, 0.176470, 0.176470, 0.372549, 0.7);
|
|
||||||
cairo_pattern_add_color_stop_rgba(windowPattern, 1, 0.176470, 0.176470, 0.372549, 0.7);
|
|
||||||
|
|
||||||
initialised = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void windowInit(window *self, const char *id, int w, int h)
|
void windowInit(window *self, const char *id, int w, int h)
|
||||||
{
|
{
|
||||||
// Init our parent
|
// Init our parent
|
||||||
widgetInit(WIDGET(self), id);
|
widgetInit(WIDGET(self), id);
|
||||||
|
|
||||||
// Prepare things only have to be initialized once
|
// Patterns initialization
|
||||||
windowInitOnce();
|
self->windowPattern = cairo_pattern_create_linear(0, 0, 0, 384);
|
||||||
|
cairo_pattern_add_color_stop_rgba(self->windowPattern, 0, 0.000000, 0.000000, 0.235294, 0.75);
|
||||||
|
cairo_pattern_add_color_stop_rgba(self->windowPattern, 0.2, 0.176470, 0.176470, 0.372549, 0.8);
|
||||||
|
cairo_pattern_add_color_stop_rgba(self->windowPattern, 0.6, 0.176470, 0.176470, 0.372549, 0.7);
|
||||||
|
cairo_pattern_add_color_stop_rgba(self->windowPattern, 1, 0.176470, 0.176470, 0.372549, 0.7);
|
||||||
|
|
||||||
// Prepare our vtable
|
// Prepare our vtable
|
||||||
windowInitVtbl(self);
|
windowInitVtbl(self);
|
||||||
|
@ -121,6 +107,9 @@ void windowDestroyImpl(widget *self)
|
||||||
vectorRemoveAt(windowVector, i);
|
vectorRemoveAt(windowVector, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove our pattern
|
||||||
|
cairo_pattern_destroy(WINDOW(self)->windowPattern);
|
||||||
|
|
||||||
// Call our parents destructor
|
// Call our parents destructor
|
||||||
widgetDestroyImpl(self);
|
widgetDestroyImpl(self);
|
||||||
|
@ -185,7 +174,7 @@ void windowDoDrawImpl(widget *self)
|
||||||
cairo_t *cr = WIDGET(self)->cr;
|
cairo_t *cr = WIDGET(self)->cr;
|
||||||
|
|
||||||
// Select window gradient
|
// Select window gradient
|
||||||
cairo_set_source(cr, windowPattern);
|
cairo_set_source(cr, WINDOW(self)->windowPattern);
|
||||||
|
|
||||||
// Do the rounded rectangle path
|
// Do the rounded rectangle path
|
||||||
windowDoWindowPath(self, cr);
|
windowDoWindowPath(self, cr);
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#define WINDOW_H_
|
#define WINDOW_H_
|
||||||
|
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
|
#include "internal-cairo.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Forward declarations
|
* Forward declarations
|
||||||
|
@ -47,6 +48,11 @@ struct _window
|
||||||
* Our vtable
|
* Our vtable
|
||||||
*/
|
*/
|
||||||
windowVtbl *vtbl;
|
windowVtbl *vtbl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Window gradient to use when drawing the window.
|
||||||
|
*/
|
||||||
|
cairo_pattern_t* windowPattern;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue