Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_gui_curve.h
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 */
19
52
53#ifndef __NILOREA_GUI_CURVE__
54#define __NILOREA_GUI_CURVE__
55
56/* Allegro only: the editor is an N_GUI widget drawn with allegro_primitives. */
57#ifdef HAVE_ALLEGRO
58
59#ifdef __cplusplus
60extern "C" {
61#endif
62
67
68#include "nilorea/n_gui.h"
69
75typedef void (*N_GUI_CURVE_CHANGE)(int widget_id, int dragging, void* user_data);
76
84typedef float (*N_GUI_CURVE_EVAL)(const float* xs, const float* ys, int count, float x, void* user_data);
85
92typedef void (*N_GUI_CURVE_BACKGROUND)(float x, float y, float w, float h, void* user_data);
93
112int n_gui_curve_new(N_GUI_CTX* ctx, int window_id, float x, float y, float w, float h, int max_points, N_GUI_CURVE_CHANGE on_change, void* user_data);
113
129int n_gui_curve_set_points(N_GUI_CTX* ctx, int widget_id, const float* xs, const float* ys, int count);
130
142int n_gui_curve_get_points(N_GUI_CTX* ctx, int widget_id, float* xs, float* ys, int max);
143
152void n_gui_curve_set_eval(N_GUI_CTX* ctx, int widget_id, N_GUI_CURVE_EVAL eval, void* user_data);
153
162void n_gui_curve_set_background(N_GUI_CTX* ctx, int widget_id, N_GUI_CURVE_BACKGROUND draw, void* user_data);
163
173void n_gui_curve_set_point_radius(N_GUI_CTX* ctx, int widget_id, float radius);
174
184float n_gui_curve_eval(N_GUI_CTX* ctx, int widget_id, float x);
185
201float n_gui_curve_eval_points(const float* xs, const float* ys, int count, float x);
202
204
205#ifdef __cplusplus
206}
207#endif
208#endif /* HAVE_ALLEGRO */
209#endif /* __NILOREA_GUI_CURVE__ */
static void on_change(const float rgba[4], void *user_data)
the picker's callback
static void draw(N_GUI_CTX *gui)
draw the whole context into a memory bitmap
The top-level GUI context that holds all windows.
Definition n_gui.h:1669
int n_gui_curve_new(N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, int max_points, N_GUI_CURVE_CHANGE on_change, void *user_data)
Add a curve editor to a window.
int n_gui_curve_get_points(N_GUI_CTX *ctx, int widget_id, float *xs, float *ys, int max)
Read the points.
float(* N_GUI_CURVE_EVAL)(const float *xs, const float *ys, int count, float x, void *user_data)
the caller's curve through the points, for drawing.
Definition n_gui_curve.h:84
float n_gui_curve_eval(N_GUI_CTX *ctx, int widget_id, float x)
The editor's curve at x, as it is drawn.
void n_gui_curve_set_point_radius(N_GUI_CTX *ctx, int widget_id, float radius)
Size of the drawn points, for a display scale.
void n_gui_curve_set_eval(N_GUI_CTX *ctx, int widget_id, N_GUI_CURVE_EVAL eval, void *user_data)
Draw the caller's own curve through the points.
void n_gui_curve_set_background(N_GUI_CTX *ctx, int widget_id, N_GUI_CURVE_BACKGROUND draw, void *user_data)
Draw something behind the grid and the curve.
void(* N_GUI_CURVE_BACKGROUND)(float x, float y, float w, float h, void *user_data)
drawn behind the grid and the curve, such as a histogram.
Definition n_gui_curve.h:92
void(* N_GUI_CURVE_CHANGE)(int widget_id, int dragging, void *user_data)
called on every change of the points.
Definition n_gui_curve.h:75
float n_gui_curve_eval_points(const float *xs, const float *ys, int count, float x)
A monotone cubic Hermite spline through points.
Definition n_gui_curve.c:82
int n_gui_curve_set_points(N_GUI_CTX *ctx, int widget_id, const float *xs, const float *ys, int count)
Replace the points.
GUI system: buttons, sliders, text areas, checkboxes, scrollbars, dropdown menus, windows.