libxputty 0.1
Loading...
Searching...
No Matches
xplayhead_private.c
Go to the documentation of this file.
1/*
2 * 0BSD
3 *
4 * BSD Zero Clause License
5 *
6 * Copyright (c) 2019 Hermann Meyer
7 *
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted.
10
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
18 *
19 */
20
21
22#include "xplayhead_private.h"
23
24
25void _create_playhead_image(Widget_t *w, int width, int height) {
26 w->image = cairo_surface_create_similar (w->surface,
27 CAIRO_CONTENT_COLOR_ALPHA, width, height*2);
28 cairo_t *cri = cairo_create (w->image);
30
31 //cairo_rectangle(cri,0.0, 0.0, width, height*2);
32 //cairo_set_source_rgba (cri, c->bg[0], c->bg[1], c->bg[2], c->bg[3]);
33 //cairo_fill(cri);
34
35 cairo_set_source_rgba (cri, c->shadow[0], c->shadow[1], c->shadow[2], c->shadow[3]);
36
37 int h = height ;
38 int ci = h-2;
39
40 int i = 1;
41 for(;i<width;) {
42 cairo_rectangle(cri,i,1,2,ci);
43 cairo_fill(cri);
44 i +=3;
45 }
46
47 cairo_set_source_rgba (cri, c->text[0], c->text[1], c->text[2], c->text[3]);
48
49 i = 1;
50 for(;i<width;) {
51 cairo_rectangle(cri,i,height+1,2,ci);
52 cairo_fill(cri);
53 i +=3;
54 }
55
56 cairo_destroy(cri);
57}
58
59void _draw_playhead(void *w_, void* user_data) {
60 Widget_t *w = (Widget_t*)w_;
61
62 int width, height;
63 os_get_surface_size(w->image, &width, &height);
64 double state = adj_get_state(w->adj);
65 double clip = adj_get_state(w->adj_x);
66 double cut = adj_get_state(w->adj_y);
68 cairo_set_source_surface (w->crb, w->image, 0, 0);
69 cairo_rectangle(w->crb,0, 0, width, height/2);
70 cairo_fill(w->crb);
71 cairo_set_source_surface (w->crb, w->image, 0, -height/2);
72 cairo_rectangle(w->crb, width*state,0,3, height/2);
73 cairo_fill(w->crb);
74
75 cairo_set_source_rgba (w->crb, 0.5, 0.0, 0.0, 0.4);
76 cairo_rectangle(w->crb, 0,0,width*clip, height/2);
77 cairo_fill(w->crb);
78
79 cairo_rectangle(w->crb, width,0,(width*cut)-width, height/2);
80 cairo_fill(w->crb);
81
83}
Color_t - struct used to set cairo color for Widget_t.
Definition xcolor.h:85
double text[4]
Definition xcolor.h:89
double shadow[4]
Definition xcolor.h:90
Widget_t - struct to hold the basic Widget_t info.
Definition xwidget.h:457
Adjustment_t * adj_y
Definition xwidget.h:495
Adjustment_t * adj_x
Definition xwidget.h:493
cairo_surface_t * image
Definition xwidget.h:491
Adjustment_t * adj
Definition xwidget.h:497
cairo_surface_t * surface
Definition xwidget.h:483
cairo_t * crb
Definition xwidget.h:489
float adj_get_state(Adjustment_t *adj)
adj_get_state - get the current state of the Adjustment_t
Colors * get_color_scheme(Widget_t *wid, Color_state st)
get_color_scheme - get pointer to the Colors struct to use in relation to the Color_state
Definition xcolor.c:197
@ NORMAL_
Definition xcolor.h:44
void _draw_playhead(void *w_, void *user_data)
_draw_playhead - internal draw the playhead to the buffer
void _create_playhead_image(Widget_t *w, int width, int height)
_create_playhead_image - internal draw the playhead image to the cairo image surface
void os_get_surface_size(cairo_surface_t *surface, int *width, int *height)
os_get_surface_size - get the size of the cairo surface
void widget_set_scale(Widget_t *w)
widget_set_scale - set scaling mode to scale a image surface to the size of the Widget_t surface
Definition xwidget.c:159
void widget_reset_scale(Widget_t *w)
widget_reset_scale - used to reset scaling mode after a image surface is drawn to the Widget_t surfac...
Definition xwidget.c:155