libxputty 0.1
Loading...
Searching...
No Matches
xslider.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 "xslider.h"
23#include "xslider_private.h"
24
26 Slider_t *slider = (Slider_t*)w->private_struct;
27 slider->frames = count;
28}
29
30Widget_t* add_vslider(Widget_t *parent, const char * label,
31 int x, int y, int width, int height) {
32
33 Widget_t *wid = create_widget(parent->app, parent, x, y, width, height);
34 Slider_t *slider;
35 slider = (Slider_t*)malloc(sizeof(Slider_t));
36 slider->frames = 101;
37 wid->private_struct = slider;
38 wid->flags |= HAS_MEM;
39 wid->label = label;
40 wid->adj_y = add_adjustment(wid,0.0, 0.0, 0.0, 1.0,0.01, CL_CONTINUOS);
41 wid->adj = wid->adj_y;
42 wid->scale.gravity = ASPECT;
48 return wid;
49}
50
51Widget_t* add_hslider(Widget_t *parent, const char * label,
52 int x, int y, int width, int height) {
53
54 Widget_t *wid = create_widget(parent->app, parent, x, y, width, height);
55 Slider_t *slider;
56 slider = (Slider_t*)malloc(sizeof(Slider_t));
57 slider->frames = 101;
58 wid->private_struct = slider;
59 wid->flags |= HAS_MEM;
60 wid->label = label;
61 wid->adj_x = add_adjustment(wid,0.0, 0.0, 0.0, 1.0,0.01, CL_CONTINUOS);
62 wid->adj = wid->adj_x;
63 wid->scale.gravity = ASPECT;
69 return wid;
70}
71
72void slider_mem_free(void *w_, void* user_data) {
73 Widget_t *w = (Widget_t*)w_;
74 Slider_t *slider = (Slider_t*)w->private_struct;
75 free(slider);
76}
evfunc button_release_callback
Definition xwidget.h:101
xevfunc expose_callback
Definition xwidget.h:85
xevfunc leave_callback
Definition xwidget.h:88
xevfunc mem_free_callback
Definition xwidget.h:92
xevfunc enter_callback
Definition xwidget.h:87
Gravity gravity
Definition xwidget.h:347
int frames
Definition xslider.h:33
Widget_t - struct to hold the basic Widget_t info.
Definition xwidget.h:457
Resize_t scale
Definition xwidget.h:525
Adjustment_t * adj_y
Definition xwidget.h:495
Adjustment_t * adj_x
Definition xwidget.h:493
Adjustment_t * adj
Definition xwidget.h:497
long long flags
Definition xwidget.h:461
void * private_struct
Definition xwidget.h:475
const char * label
Definition xwidget.h:463
Func_t func
Definition xwidget.h:481
Xputty * app
Definition xwidget.h:465
Adjustment_t * add_adjustment(Widget_t *w, float std_value, float value, float min_value, float max_value, float step, CL_type type)
*add_adjustment - adding a adjustment to a Widget_t
Definition xadjustment.c:25
@ CL_CONTINUOS
Definition xadjustment.h:49
Widget_t * add_vslider(Widget_t *parent, const char *label, int x, int y, int width, int height)
add_vslider - add a vertical slider to a Widget_t connect to func.value_changed_callback to implement...
Definition xslider.c:30
void set_slider_image_frame_count(Widget_t *w, int count)
set_slider_image_frame_count - set the number of sprites in the Slider Image
Definition xslider.c:25
Widget_t * add_hslider(Widget_t *parent, const char *label, int x, int y, int width, int height)
add_hslider - add a horizontal slider to a Widget_t connect to func.value_changed_callback to impleme...
Definition xslider.c:51
void slider_mem_free(void *w_, void *user_data)
Definition xslider.c:72
void _slider_released(void *w_, void *button_, void *user_data)
_slider_released - redraw the slider when button released
void _draw_hslider(void *w_, void *user_data)
_draw_hslider - internal draw the slider to the buffer
void _draw_vslider(void *w_, void *user_data)
_draw_vslider - internal draw the slider to the buffer
void os_transparent_draw(void *w_, void *user_data)
os_transparent_draw - Draw the Widget_t to the back buffer
Widget_t * create_widget(Xputty *app, Widget_t *win, int x, int y, int width, int height)
*create_widget - create a widget A Widget_t could only be created as child of a other Widget_t To...
Definition xwidget.c:265
@ ASPECT
Definition xwidget.h:322
@ HAS_MEM
Definition xwidget.h:406