summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2013-10-23 21:49:30 -0700
committerKristian Høgsberg <krh@bitplanet.net>2013-10-23 21:49:30 -0700
commitc680e904897dfb19331f8f296abbc864f52314cf (patch)
treedf3800d9daaa29cd433d035b6243090ff80e35e7 /shared
parenta83be20d7f0240ce61cf82ab5230529baf9dfe42 (diff)
downloadweston-c680e904897dfb19331f8f296abbc864f52314cf.tar.gz
window.c: Use frame code for drawing menus
This gives us a nice frame and drop shadows for the menus.
Diffstat (limited to 'shared')
-rw-r--r--shared/cairo-util.c26
-rw-r--r--shared/cairo-util.h2
2 files changed, 20 insertions, 8 deletions
diff --git a/shared/cairo-util.c b/shared/cairo-util.c
index 4305ba69..5b4b0ff3 100644
--- a/shared/cairo-util.c
+++ b/shared/cairo-util.c
@@ -320,12 +320,27 @@ load_cairo_surface(const char *filename)
width, height, stride);
}
+void
+theme_set_background_source(struct theme *t, cairo_t *cr, uint32_t flags)
+{
+ cairo_pattern_t *pattern;
+
+ if (flags & THEME_FRAME_ACTIVE) {
+ pattern = cairo_pattern_create_linear(16, 16, 16, 112);
+ cairo_pattern_add_color_stop_rgb(pattern, 0.0, 1.0, 1.0, 1.0);
+ cairo_pattern_add_color_stop_rgb(pattern, 0.2, 0.8, 0.8, 0.8);
+ cairo_set_source(cr, pattern);
+ cairo_pattern_destroy(pattern);
+ } else {
+ cairo_set_source_rgba(cr, 0.75, 0.75, 0.75, 1);
+ }
+}
+
struct theme *
theme_create(void)
{
struct theme *t;
cairo_t *cr;
- cairo_pattern_t *pattern;
t = malloc(sizeof *t);
if (t == NULL)
@@ -352,12 +367,7 @@ theme_create(void)
cr = cairo_create(t->active_frame);
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
- pattern = cairo_pattern_create_linear(16, 16, 16, 112);
- cairo_pattern_add_color_stop_rgb(pattern, 0.0, 1.0, 1.0, 1.0);
- cairo_pattern_add_color_stop_rgb(pattern, 0.2, 0.8, 0.8, 0.8);
- cairo_set_source(cr, pattern);
- cairo_pattern_destroy(pattern);
-
+ theme_set_background_source(t, cr, THEME_FRAME_ACTIVE);
rounded_rect(cr, 0, 0, 128, 128, t->frame_radius);
cairo_fill(cr);
@@ -370,7 +380,7 @@ theme_create(void)
cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 128, 128);
cr = cairo_create(t->inactive_frame);
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
- cairo_set_source_rgba(cr, 0.75, 0.75, 0.75, 1);
+ theme_set_background_source(t, cr, 0);
rounded_rect(cr, 0, 0, 128, 128, t->frame_radius);
cairo_fill(cr);
diff --git a/shared/cairo-util.h b/shared/cairo-util.h
index d679bcbd..a8eb8741 100644
--- a/shared/cairo-util.h
+++ b/shared/cairo-util.h
@@ -64,6 +64,8 @@ enum {
};
void
+theme_set_background_source(struct theme *t, cairo_t *cr, uint32_t flags);
+void
theme_render_frame(struct theme *t,
cairo_t *cr, int width, int height,
const char *title, uint32_t flags);