24static void _show_label(
Widget_t *w,
int width,
int height) {
26 cairo_text_extents_t extents;
29 cairo_text_extents(w->
crb,w->
label , &extents);
30 cairo_move_to (w->
crb, (width*0.5)-(extents.width/2), height-(extents.height/4));
32 cairo_new_path (w->
crb);
38 double x = (double)width_t/(
double)height;
39 double y = (double)height/(
double)width_t;
41 int findex = (int)(((width/height)-1) * knobstate);
43 int posy = (height_t/2 - ((height*x)/2));
44 if (width_t > height_t) {
45 x = (double)height_t/(
double)height;
46 y = (double)height/(
double)height_t;
47 posx = (width_t/2 -((height*x)/2));
51 cairo_scale(w->
crb, x,x);
52 cairo_translate(w->
crb, posx * ((1-x)/x), posy * ((1-x)/x));
53 cairo_set_source_surface (w->
crb, w->
image, -height*findex + posx, posy);
54 cairo_rectangle(w->
crb, posx, posy, height, height);
56 cairo_scale(w->
crb, y,y);
57 cairo_restore(w->
crb);
70 int width = metrics.
width-2;
71 int height = metrics.
height-2;
74 const double scale_zero = 20 * (M_PI/180);
79 int grow = (width > height) ? height:width;
84 int knobx = (width - knob_x) * 0.5;
85 int knobx1 = width* 0.5;
87 int knoby = (height - knob_y) * 0.5;
88 int knoby1 = height * 0.5;
94 double angle = scale_zero + knobstate * 2 * (M_PI - scale_zero);
96 double pointer_off =knob_x/6;
97 double radius = min(knob_x-pointer_off, knob_y-pointer_off) / 2;
98 double lengh_x = (knobx+radius+pointer_off/2) - radius * sin(angle);
99 double lengh_y = (knoby+radius+pointer_off/2) + radius * cos(angle);
100 double radius_x = (knobx+radius+pointer_off/2) - radius/ 1.24 * sin(angle);
101 double radius_y = (knoby+radius+pointer_off/2) + radius/ 1.24 * cos(angle);
103 cairo_arc(w->
crb,knobx1+arc_offset, knoby1+arc_offset, knob_x/2.1, 0, 2 * M_PI );
107 cairo_new_path (w->
crb);
110 cairo_arc(w->
crb,knobx1+arc_offset, knoby1+arc_offset, knob_x/3.1, 0, 2 * M_PI );
111 cairo_fill_preserve(w->
crb);
113 cairo_set_line_width(w->
crb, min(3.0, knobx1/15));
114 cairo_stroke(w->
crb);
115 cairo_new_path (w->
crb);
118 cairo_set_line_cap(w->
crb, CAIRO_LINE_CAP_ROUND);
119 cairo_set_line_join(w->
crb, CAIRO_LINE_JOIN_BEVEL);
120 cairo_move_to(w->
crb, radius_x, radius_y);
121 cairo_line_to(w->
crb,lengh_x,lengh_y);
122 cairo_set_line_width(w->
crb,min(6.0, knobx1/7));
124 cairo_stroke(w->
crb);
125 cairo_new_path (w->
crb);
128 cairo_text_extents_t extents;
132 const char* format[] = {
"%.1f",
"%.2f",
"%.3f"};
135 snprintf(s, 63,
"%d", (
int) value);
136 }
else if (fabs(w->
adj->
step)>0.09) {
137 snprintf(s, 63, format[1-1], value);
139 snprintf(s, 63, format[2-1], value);
142 cairo_text_extents(w->
crb, s, &extents);
143 cairo_move_to (w->
crb, knobx1-extents.width/2, knoby1+extents.height/2);
144 cairo_show_text(w->
crb, s);
145 cairo_new_path (w->
crb);
148 _show_label(w, width, height);
Metrics_t - struct to receive window size, position & visibility Pass this struct to os_get_window_...
float adj_get_value(Adjustment_t *adj)
adj_get_value - get the current value of the Adjustment_t
float adj_get_state(Adjustment_t *adj)
adj_get_state - get the current state of the Adjustment_t
Color_state get_color_state(Widget_t *wid)
get_color_state - get the Color_state to use in relation to the Widget_t state
void use_text_color_scheme(Widget_t *w, Color_state st)
use_text_color_scheme - use text Colors to paint on Widget_t
void use_bg_color_scheme(Widget_t *w, Color_state st)
use_bg_color_scheme - use background Colors to paint on Widget_t
void use_fg_color_scheme(Widget_t *w, Color_state st)
use_fg_color_scheme - use forground Colors to paint on Widget_t
void use_shadow_color_scheme(Widget_t *w, Color_state st)
use_shadow_color_scheme - use shadow Colors to paint on Widget_t
void _draw_knob_image(void *w_, void *user_data)
_draw_knob_image - internal draw the knob to the buffer
void _draw_knob(void *w_, void *user_data)
_draw_knob - internal draw the knob to the buffer
void _knob_released(void *w_, void *button_, void *user_data)
_knob_released - redraw the slider when buttob released
void _draw_image_knob(Widget_t *w, int width_t, int height_t)
_draw_image_knob - internal draw the knob from image to the buffer