-
Notifications
You must be signed in to change notification settings - Fork 71
/
GraphicalPointer.cpp
59 lines (53 loc) · 1.55 KB
/
GraphicalPointer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "GraphicalPointer.h"
#include <cairomm/context.h>
WindowPointer::PointerSpec::PointerSpec(int width, int height,
double red, double green, double blue):
width(width), height(height), red(red), green(green), blue(blue)
{
}
WindowPointer::GtkPointerDrawingArea::
GtkPointerDrawingArea(const PointerSpec &pointerspec):
spec(pointerspec)
{
set_size_request(spec.width, spec.height);
}
bool WindowPointer::GtkPointerDrawingArea::
on_expose_event(GdkEventExpose *event)
{
Glib::RefPtr<Gdk::Window> window = get_window();
if (window) {
Cairo::RefPtr<Cairo::Context> cr(new Cairo::Context(gdk_cairo_create(window->gobj()), true));
if (event) {
cr->rectangle(event->area.x, event->area.y,
event->area.width, event->area.height);
cr->clip();
}
cr->set_source_rgb(1.0, 1.0, 1.0);
cr->paint();
cr->set_source_rgb(spec.red, spec.green, spec.blue);
cr->arc(get_width()/2, get_height()/2, get_width()/3, 0, 2*M_PI);
cr->fill();
// Glib::RefPtr<Gdk::GC> gc = Gdk::GC::create(window);
// color.set_blue(100);
// gc->set_foreground(color);
// window->draw_arc(gc, true, 0, 0, get_width(), get_height(), 0, 360*64);
}
return false;
}
WindowPointer::GtkPointerWindow::
GtkPointerWindow(const PointerSpec &pointerspec):
area(pointerspec)
{
add(area);
area.show();
set_decorated(false);
set_keep_above(true);
}
WindowPointer::WindowPointer(const PointerSpec &pointerspec):
pointerwindow(pointerspec)
{
pointerwindow.show();
}
void WindowPointer::setPosition(int x, int y) {
pointerwindow.move(x, y);
}