libxputty 0.1
Loading...
Searching...
No Matches
xtuner.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 "xtuner.h"
23#include "xtuner_private.h"
24
25void tuner_set_temperament (Widget_t *w, float temp) {
26 XTuner *xt = (XTuner *)w->parent_struct;
27 xt->temperament = temp;
28 if((int)temp == 0) xt->temp_adjust = 3;
29 else if((int)temp == 1) xt->temp_adjust = 6;
30 else if((int)temp == 2) xt->temp_adjust = 7;
31 else if((int)temp == 3) xt->temp_adjust = 9;
32 else if((int)temp == 4) xt->temp_adjust = 15;
33 else xt->temp_adjust = 3;
34}
35
36void tuner_set_ref_freq (Widget_t *w, float ref) {
37 XTuner *xt = (XTuner *)w->parent_struct;
38 xt->ref_freq = ref;
39}
40
41static void xtuner_mem_free(void *w_, void* user_data) {
42 Widget_t *w = (Widget_t*)w_;
43 XTuner *xt = (XTuner *)w->parent_struct;
44 free(xt);
45}
46
47Widget_t* add_tuner(Widget_t *parent, const char * label,
48 int x, int y, int width, int height) {
49
50 XTuner *xt = (XTuner*)malloc(sizeof(XTuner));
51 xt->ref_freq = 440.0;
52 xt->temp_adjust = 3;
53 xt->temperament = 0;
54 xt->move = 0;
55 xt->smove = 0;
56 xt->lang = 0;
57 Widget_t *wid = create_widget(parent->app, parent, x, y, width, height);
58 wid->parent_struct = xt;
59 wid->label = label;
60 wid->adj_y = add_adjustment(wid,20.0, 20.0, 20.0, 20000.0,0.01, CL_CONTINUOS);
61 wid->adj = wid->adj_y;
62 wid->scale.gravity = CENTER;
63 wid->flags &= ~USE_TRANSPARENCY;
64 wid->flags |= HAS_MEM;
65 wid->func.mem_free_callback = xtuner_mem_free;
67 return wid;
68}
xevfunc expose_callback
Definition xwidget.h:85
xevfunc mem_free_callback
Definition xwidget.h:92
Gravity gravity
Definition xwidget.h:347
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
Definition xwidget.h:497
long long flags
Definition xwidget.h:461
const char * label
Definition xwidget.h:463
void * parent_struct
Definition xwidget.h:473
Func_t func
Definition xwidget.h:481
Xputty * app
Definition xwidget.h:465
float temperament
Definition xtuner.h:35
int temp_adjust
Definition xtuner.h:37
int lang
Definition xtuner.h:36
float ref_freq
Definition xtuner.h:34
int smove
Definition xtuner.h:39
int move
Definition xtuner.h:38
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
void tuner_set_ref_freq(Widget_t *w, float ref)
Definition xtuner.c:36
void tuner_set_temperament(Widget_t *w, float temp)
Definition xtuner.c:25
Widget_t * add_tuner(Widget_t *parent, const char *label, int x, int y, int width, int height)
add_tuner - add a tuner widget to a Widget_t
Definition xtuner.c:47
void _draw_tuner(void *w_, void *user_data)
_draw_tuner - draw the tuner on expose call
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
@ CENTER
Definition xwidget.h:320
@ HAS_MEM
Definition xwidget.h:406