1
/* -*- mode: c; c-basic-offset: 4; -*-
3
* parameter-holder.h - A base class for GObjects whose properties include
4
* algorithm parameters that can be serialized to key/value
5
* pairs and interpolated between.
7
* Fyre - rendering and interactive exploration of chaotic functions
8
* Copyright (C) 2004-2005 David Trowbridge and Micah Dowty
10
* This program is free software; you can redistribute it and/or
11
* modify it under the terms of the GNU General Public License
12
* as published by the Free Software Foundation; either version 2
13
* of the License, or (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
#ifndef __PARAMETER_HOLDER_H__
27
#define __PARAMETER_HOLDER_H__
33
#define PARAMETER_HOLDER_TYPE (parameter_holder_get_type ())
34
#define PARAMETER_HOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PARAMETER_HOLDER_TYPE, ParameterHolder))
35
#define PARAMETER_HOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PARAMETER_HOLDER_TYPE, ParameterHolderClass))
36
#define IS_PARAMETER_HOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PARAMETER_HOLDER_TYPE))
37
#define IS_PARAMETER_HOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PARAMETER_HOLDER_TYPE))
39
typedef struct _ParameterHolder ParameterHolder;
40
typedef struct _ParameterHolderClass ParameterHolderClass;
42
typedef struct _ToolInput {
43
double delta_x, delta_y;
44
double absolute_x, absolute_y;
45
double click_relative_x, click_relative_y;
47
GdkModifierType state;
50
struct _ParameterHolder {
54
typedef void (ToolHandlerPH)(ParameterHolder *self, ToolInput *i);
57
TOOL_USE_MOTION_EVENTS = 1 << 0,
58
TOOL_USE_IDLE = 1 << 1,
61
typedef struct _ToolInfoPH {
63
ToolHandlerPH *handler;
67
struct _ParameterHolderClass {
68
GObjectClass parent_class;
70
/* Overrideable methods */
71
ToolInfoPH* (*get_tools) ();
74
typedef void (ParameterInterpolator)(ParameterHolder *self,
78
#define PARAMETER_INTERPOLATOR(x) ((ParameterInterpolator*)(x))
81
ParameterHolder *a, *b;
82
} ParameterHolderPair;
85
/* Custom G_PARAM flags */
86
#define PARAM_SERIALIZED (1 << (G_PARAM_USER_SHIFT + 0)) /* Parameters we're interested in serializing */
87
#define PARAM_INTERPOLATE (1 << (G_PARAM_USER_SHIFT + 1)) /* Parameters we're interested in interpolating */
88
#define PARAM_IN_GUI (1 << (G_PARAM_USER_SHIFT + 2)) /* Parameters that should be visible in the GUI */
90
/* This is attached to the "increments" quark using param_spec_set_increments */
94
} ParameterIncrements;
97
/************************************************************************************/
98
/******************************************************************* Public Methods */
99
/************************************************************************************/
101
GType parameter_holder_get_type ();
102
ParameterHolder* parameter_holder_new ();
104
void parameter_holder_pair_free (ParameterHolderPair *self);
106
void parameter_holder_reset_to_defaults (ParameterHolder *self);
108
void parameter_holder_set (ParameterHolder *self,
109
const gchar *property,
111
void parameter_holder_set_from_line (ParameterHolder *self,
114
void parameter_holder_load_string (ParameterHolder *self,
115
const gchar *params);
117
gchar* parameter_holder_save_string (ParameterHolder *self);
119
void parameter_holder_interpolate_linear (ParameterHolder *self,
121
ParameterHolderPair *p);
123
ToolInfoPH* parameter_holder_get_tools (ParameterHolder *self);
126
* These functions make it easy to assign extra metadata to GParamSpecs
127
* that can be used when automatically building GUIs for ParameterHolder instances.
130
void param_spec_set_group (GParamSpec *pspec,
131
const gchar *group_name);
133
void param_spec_set_increments (GParamSpec *pspec,
138
void param_spec_set_dependency (GParamSpec *pspec,
139
const gchar *dependency_name);
141
const gchar* param_spec_get_group (GParamSpec *pspec);
143
const ParameterIncrements* param_spec_get_increments (GParamSpec *pspec);
145
const gchar* param_spec_get_dependency (GParamSpec *pspec);
150
#endif /* __PARAMETER_HOLDER_H__ */