1
/* aosd -- OSD with fake transparency, cairo, and pango.
3
* Copyright (C) 2006 Evan Martin <martine@danga.com>
11
#include <cairo/cairo.h>
13
#include <libaosd/aosd.h>
18
cairo_surface_t* foot;
23
round_rect(cairo_t* cr, int x, int y, int w, int h, int r)
25
cairo_move_to(cr, x+r, y);
26
cairo_line_to(cr, x+w-r, y); /* top edge */
27
cairo_curve_to(cr, x+w, y, x+w, y, x+w, y+r);
28
cairo_line_to(cr, x+w, y+h-r); /* right edge */
29
cairo_curve_to(cr, x+w, y+h, x+w, y+h, x+w-r, y+h);
30
cairo_line_to(cr, x+r, y+h); /* bottom edge */
31
cairo_curve_to(cr, x, y+h, x, y+h, x, y+h-r);
32
cairo_line_to(cr, x, y+r); /* left edge */
33
cairo_curve_to(cr, x, y, x, y, x+r, y);
40
render(Aosd* aosd, cairo_t* cr, void* data)
42
RenderData* rdata = data;
44
cairo_set_source_rgba(cr, rdata->alpha, 0, 0, 0.7);
46
round_rect(cr, 0, 0, 180, 230, RADIUS);
49
cairo_set_source_rgba(cr, 1, 1, 1, 1.0);
51
round_rect(cr, 10, 10, 160, 210, RADIUS);
55
cairo_set_source_rgba(cr, 1, 1, 1, 1.0);
56
cairo_set_source_surface(cr, rdata->foot, 20, 20);
62
mouse_callback(Aosd* aosd, AosdMouseEvent* event, void* user_data)
67
int main(int argc, char* argv[])
70
RenderData data = {0};
72
const char* image = "/usr/share/pixmaps/gnome-background-image.png";
73
data.foot = cairo_image_surface_create_from_png(image);
77
aosd_set_transparency(aosd, TRANSPARENCY_COMPOSITE);
78
aosd_set_mouse_event_cb(aosd, mouse_callback, NULL);
79
aosd_set_geometry(aosd, 50, 50, 180, 230);
80
aosd_set_renderer(aosd, render, &data, NULL);
84
aosd_main_iterations(aosd);
89
struct timeval tv_nextupdate;
93
gettimeofday(&tv_nextupdate, NULL);
94
tv_nextupdate.tv_usec += STEP * 1000;
96
aosd_main_until(aosd, &tv_nextupdate);
99
if (data.alpha >= 1.0)
104
else if (data.alpha <= 0.0)
112
cairo_surface_destroy(data.foot);
118
/* vim: set ts=2 sw=2 et : */