|
libxputty
0.1
A damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces
|
|
Go to the source code of this file.
◆ _draw_hslider()
void _draw_hslider |
( |
void * |
w_, |
|
|
void * |
user_data |
|
) |
| |
_draw_hslider - internal draw the slider to the buffer
- Parameters
-
*w_ | - void pointer to the Widget_t button |
*user_data | - void pointer to attached user_data |
- Returns
- void
Definition at line 117 of file xslider_private.c.
119 XWindowAttributes attrs;
120 XGetWindowAttributes(w->
app->
dpy, (Window)w->
widget, &attrs);
121 int width = attrs.width-2;
122 int height = attrs.height-2;
123 float center = (float)height/2;
124 float upcenter = (float)height;
126 if (attrs.map_state != IsViewable)
return;
131 cairo_move_to (w->
crb, center, center);
132 cairo_line_to(w->
crb,width-center-10,center);
133 cairo_set_line_cap (w->
crb,CAIRO_LINE_CAP_ROUND);
134 cairo_set_line_width(w->
crb,center);
135 cairo_stroke(w->
crb);
138 cairo_move_to (w->
crb, center, center);
139 cairo_line_to(w->
crb,width-center-10,center);
140 cairo_set_line_width(w->
crb,center/10);
141 cairo_stroke(w->
crb);
144 cairo_arc(w->
crb, (center) +
145 ((width-10-upcenter) * sliderstate),center, center/2, 0, 2 * M_PI );
146 cairo_fill_preserve(w->
crb);
147 cairo_set_line_width(w->
crb,1);
148 cairo_stroke(w->
crb);
151 cairo_arc(w->
crb, (center) +
152 ((width-10-upcenter) * sliderstate),center, center/3, 0, 2 * M_PI );
153 cairo_fill_preserve(w->
crb);
155 cairo_set_line_width(w->
crb,center/15);
156 cairo_stroke(w->
crb);
157 cairo_new_path (w->
crb);
159 cairo_text_extents_t extents;
164 cairo_text_extents(w->
crb,w->
label , &extents);
166 cairo_move_to (w->
crb, width/2-extents.width/2, height );
168 cairo_new_path (w->
crb);
172 const char* format[] = {
"%.1f",
"%.2f",
"%.3f"};
175 snprintf(s, 63,
"%d", (
int) value);
176 }
else if (fabs(w->
adj->
step)>0.09) {
177 snprintf(s, 63, format[1-1], value);
179 snprintf(s, 63, format[2-1], value);
181 cairo_text_extents(w->
crb,s , &extents);
182 cairo_move_to (w->
crb, width/2-extents.width/2, extents.height );
183 cairo_show_text(w->
crb, s);
184 cairo_new_path (w->
crb);
References _pattern_hslider(), Widget_t::adj, adj_get_state(), adj_get_value(), Widget_t::adj_x, Widget_t::app, Resize_t::ascale, Widget_t::crb, Xputty::dpy, get_color_state(), Widget_t::label, NORMAL_, Xputty::normal_font, Widget_t::scale, Xputty::small_font, Adjustment_t::step, use_bg_color_scheme(), use_fg_color_scheme(), use_shadow_color_scheme(), use_text_color_scheme(), and Widget_t::widget.
◆ _draw_vslider()
void _draw_vslider |
( |
void * |
w_, |
|
|
void * |
user_data |
|
) |
| |
_draw_vslider - internal draw the slider to the buffer
- Parameters
-
*w_ | - void pointer to the Widget_t button |
*user_data | - void pointer to attached user_data |
- Returns
- void
Definition at line 47 of file xslider_private.c.
49 XWindowAttributes attrs;
50 XGetWindowAttributes(w->
app->
dpy, (Window)w->
widget, &attrs);
51 int width = attrs.width-2;
52 int height = attrs.height-2;
53 float center = (float)width/2;
54 float upcenter = (float)width;
56 if (attrs.map_state != IsViewable)
return;
61 cairo_move_to (w->
crb, center, center);
62 cairo_line_to(w->
crb,center,height-center-10);
63 cairo_set_line_cap (w->
crb,CAIRO_LINE_CAP_ROUND);
64 cairo_set_line_width(w->
crb,center);
68 cairo_move_to (w->
crb, center, center);
69 cairo_line_to(w->
crb,center,height-center-10);
70 cairo_set_line_width(w->
crb,center/10);
74 cairo_arc(w->
crb,center, (height-center-10) -
75 ((height-10-upcenter) * sliderstate), center/2, 0, 2 * M_PI );
76 cairo_fill_preserve(w->
crb);
77 cairo_set_line_width(w->
crb,1);
82 cairo_arc(w->
crb,center, (height-center-10) -
83 ((height-10-upcenter) * sliderstate), center/3, 0, 2 * M_PI );
84 cairo_fill_preserve(w->
crb);
86 cairo_set_line_width(w->
crb,center/15);
88 cairo_new_path (w->
crb);
90 cairo_text_extents_t extents;
94 cairo_set_font_size (w->
crb, center/1.8);
95 cairo_text_extents(w->
crb,w->
label , &extents);
97 cairo_move_to (w->
crb, center-extents.width/2, height-center/2.1);
99 cairo_new_path (w->
crb);
102 const char* format[] = {
"%.1f",
"%.2f",
"%.3f"};
105 snprintf(s, 63,
"%d", (
int) value);
106 }
else if (fabs(w->
adj->
step)>0.09) {
107 snprintf(s, 63, format[1-1], value);
109 snprintf(s, 63, format[2-1], value);
111 cairo_text_extents(w->
crb,s , &extents);
112 cairo_move_to (w->
crb, center-extents.width/2, extents.height );
113 cairo_show_text(w->
crb, s);
114 cairo_new_path (w->
crb);
References _pattern_vslider(), Widget_t::adj, adj_get_state(), adj_get_value(), Widget_t::adj_y, Widget_t::app, Widget_t::crb, Xputty::dpy, get_color_state(), Widget_t::label, NORMAL_, Adjustment_t::step, use_bg_color_scheme(), use_fg_color_scheme(), use_shadow_color_scheme(), use_text_color_scheme(), and Widget_t::widget.
◆ _pattern_hslider()
_pattern_hslider - set pattern for the slider base
- Parameters
-
*w_ | - void pointer to the Widget_t button |
st | - the Widget_t Color_t mode to use |
width | - the width of the base |
- Returns
- void
Definition at line 36 of file xslider_private.c.
39 cairo_pattern_t *pat = cairo_pattern_create_linear (2, 2, 2, height);
40 cairo_pattern_add_color_stop_rgba(pat, 0.0, c->
base[0], c->
base[1], c->
base[2], c->
base[3]);
41 cairo_pattern_add_color_stop_rgba(pat, 0.5, 0.0, 0.0, 0.0, 0.0);
42 cairo_pattern_add_color_stop_rgba(pat, 1.0, c->
base[0], c->
base[1], c->
base[2], c->
base[3]);
43 cairo_set_source(w->
crb, pat);
44 cairo_pattern_destroy (pat);
References Widget_t::app, Colors::base, Widget_t::crb, and get_color_scheme().
◆ _pattern_vslider()
_pattern_vslider - set pattern for the slider base
- Parameters
-
*w_ | - void pointer to the Widget_t button |
st | - the Widget_t Color_t mode to use |
width | - the width of the base |
- Returns
- void
Definition at line 25 of file xslider_private.c.
28 cairo_pattern_t *pat = cairo_pattern_create_linear (2, 2, width, 2);
29 cairo_pattern_add_color_stop_rgba(pat, 0.0, c->
base[0], c->
base[1], c->
base[2], c->
base[3]);
30 cairo_pattern_add_color_stop_rgba(pat, 0.5, 0.0, 0.0, 0.0, 0.0);
31 cairo_pattern_add_color_stop_rgba(pat, 1.0, c->
base[0], c->
base[1], c->
base[2], c->
base[3]);
32 cairo_set_source(w->
crb, pat);
33 cairo_pattern_destroy (pat);
References Widget_t::app, Colors::base, Widget_t::crb, and get_color_scheme().
◆ _slider_released()
void _slider_released |
( |
void * |
w_, |
|
|
void * |
button_, |
|
|
void * |
user_data |
|
) |
| |
_slider_released - redraw the slider when button released
- Parameters
-
*w_ | - void pointer to the Widget_t button |
*user_data | - void pointer to attached user_data |
- Returns
- void
Definition at line 187 of file xslider_private.c.
References expose_widget().
void use_text_color_scheme(Widget_t *w, Color_state st)
use_text_color_scheme - use text Colors to paint on Widget_t
void _pattern_vslider(Widget_t *w, Color_state st, int width)
_pattern_vslider - set pattern for the slider base
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_shadow_color_scheme(Widget_t *w, Color_state st)
use_shadow_color_scheme - use shadow Colors to paint on Widget_t
float adj_get_value(Adjustment_t *adj)
adj_get_value - get the current value of the Adjustment_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_bg_color_scheme(Widget_t *w, Color_state st)
use_bg_color_scheme - use background Colors to paint on Widget_t
Color_t - struct used to set cairo color for Widget_t.
void _pattern_hslider(Widget_t *w, Color_state st, int height)
_pattern_hslider - set pattern for the slider base
Colors * get_color_scheme(Xputty *main, Color_state st)
get_color_scheme - get pointer to the Colors struct to use in relation to the Color_state