libxputty 0.1
Loading...
Searching...
No Matches
Functions
xwaveview_private.c File Reference

Go to the source code of this file.

Functions

void _rounded_view (cairo_t *cr, float x, float y, float w, float h, float lsize)
 
void _draw_waveview (void *w_, void *user_data)
 

Function Documentation

◆ _draw_waveview()

void _draw_waveview ( void *  w_,
void *  user_data 
)

Definition at line 39 of file xwaveview_private.c.

39 {
40 Widget_t *w = (Widget_t*)w_;
41 WaveView_t *wave_view = (WaveView_t*)w->private_struct;
42 Metrics_t metrics;
43 os_get_window_metrics(w, &metrics);
44 int width_t = metrics.width;
45 int height_t = metrics.height;
46 if (!metrics.visible) return;
47 int half_height_t = height_t/2;
48
49 cairo_text_extents_t extents;
50 cairo_set_font_size (w->crb, w->app->normal_font/w->scale.ascale);
51 cairo_text_extents(w->crb,w->label , &extents);
52
53 cairo_set_line_width(w->crb,2);
55 _rounded_view(w->crb, 2, 5, width_t-4, height_t-7, extents.width+15);
56 cairo_fill_preserve(w->crb);
58 cairo_stroke(w->crb);
59 cairo_move_to(w->crb,2,half_height_t);
60 cairo_line_to(w->crb, width_t-4, half_height_t);
61 cairo_stroke(w->crb);
62
64 cairo_move_to (w->crb, 30, extents.height);
65 cairo_show_text(w->crb, w->label);
66 cairo_new_path (w->crb);
67
68 if (wave_view->size<1) return;
69 float step = (float)(width_t-10)/(float)wave_view->size+1;
70 float lstep = (float)(half_height_t-10.0);
71 cairo_set_line_width(w->cr,2);
73 int i = 0;
74 for (;i<wave_view->size;i++) {
75 cairo_line_to(w->crb, (float)(i+0.5)*step,(float)(half_height_t)+ -wave_view->wave[i]*lstep);
76 }
77 cairo_line_to(w->crb, width_t, half_height_t);
78 cairo_line_to(w->crb, 2, half_height_t);
79 cairo_close_path(w->crb);
81 cairo_fill_preserve(w->crb);
83 cairo_stroke(w->crb);
84 i = 0;
85 for (;i<wave_view->size;i++) {
86 cairo_line_to(w->crb, (float)(i+0.5)*step,(float)(half_height_t)+ wave_view->wave[i]*lstep);
87 }
88 cairo_line_to(w->crb, width_t, half_height_t);
89 cairo_line_to(w->crb, 2, half_height_t);
90 cairo_close_path(w->crb);
92 cairo_fill_preserve(w->crb);
94 cairo_stroke(w->crb);
95}
Metrics_t - struct to receive window size, position & visibility Pass this struct to os_get_window_...
Widget_t - struct to hold the basic Widget_t info.
Definition xwidget.h:457
void * private_struct
Definition xwidget.h:475
void use_frame_color_scheme(Widget_t *w, Color_state st)
use_frame_color_scheme - use frame Colors to paint on Widget_t
Definition xcolor.c:280
Color_state get_color_state(Widget_t *wid)
get_color_state - get the Color_state to use in relation to the Widget_t state
Definition xcolor.c:222
void use_text_color_scheme(Widget_t *w, Color_state st)
use_text_color_scheme - use text Colors to paint on Widget_t
Definition xcolor.c:266
void use_bg_color_scheme(Widget_t *w, Color_state st)
use_bg_color_scheme - use background Colors to paint on Widget_t
Definition xcolor.c:252
void use_fg_color_scheme(Widget_t *w, Color_state st)
use_fg_color_scheme - use forground Colors to paint on Widget_t
Definition xcolor.c:245
void use_light_color_scheme(Widget_t *w, Color_state st)
use_light_color_scheme - use light Colors to paint on Widget_t
Definition xcolor.c:287
@ NORMAL_
Definition xcolor.h:44
void _rounded_view(cairo_t *cr, float x, float y, float w, float h, float lsize)
void os_get_window_metrics(Widget_t *w, Metrics_t *metrics)
os_get_window_metrics - Get the Merics_t struct related to a Widget_t

References _rounded_view(), Widget_t::app, Resize_t::ascale, Widget_t::cr, Widget_t::crb, get_color_state(), Metrics_t::height, Widget_t::label, NORMAL_, Xputty::normal_font, os_get_window_metrics(), Widget_t::private_struct, Widget_t::scale, WaveView_t::size, use_bg_color_scheme(), use_fg_color_scheme(), use_frame_color_scheme(), use_light_color_scheme(), use_text_color_scheme(), Metrics_t::visible, WaveView_t::wave, and Metrics_t::width.

Referenced by add_waveview().

◆ _rounded_view()

void _rounded_view ( cairo_t *  cr,
float  x,
float  y,
float  w,
float  h,
float  lsize 
)

Definition at line 25 of file xwaveview_private.c.

25 {
26 cairo_new_path (cr);
27 float r = 20.0;
28 cairo_move_to(cr, x+lsize+r,y);
29 cairo_line_to(cr, x+w-r,y);
30 cairo_curve_to(cr, x+w,y,x+w,y,x+w,y+r);
31 cairo_line_to(cr, x+w,y+h-r);
32 cairo_curve_to(cr, x+w,y+h,x+w,y+h,x+w-r,y+h);
33 cairo_line_to(cr, x+r,y+h);
34 cairo_curve_to(cr, x,y+h,x,y+h,x,y+h-r);
35 cairo_line_to(cr, x,y+r);
36 cairo_curve_to(cr, x,y,x,y,x+r,y);
37}

Referenced by _draw_waveview().