~ubuntu-branches/ubuntu/raring/fyre/raring

« back to all changes in this revision

Viewing changes to src/parameter-holder.h

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Haas
  • Date: 2005-05-25 21:59:19 UTC
  • Revision ID: james.westby@ubuntu.com-20050525215919-jawtso5ic23qb401
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c; c-basic-offset: 4; -*-
 
2
 *
 
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.
 
6
 *
 
7
 * Fyre - rendering and interactive exploration of chaotic functions
 
8
 * Copyright (C) 2004-2005 David Trowbridge and Micah Dowty
 
9
 *
 
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.
 
14
 *
 
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.
 
19
 *
 
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.
 
23
 *
 
24
 */
 
25
 
 
26
#ifndef __PARAMETER_HOLDER_H__
 
27
#define __PARAMETER_HOLDER_H__
 
28
 
 
29
#include <gtk/gtk.h>
 
30
 
 
31
G_BEGIN_DECLS
 
32
 
 
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))
 
38
 
 
39
typedef struct _ParameterHolder      ParameterHolder;
 
40
typedef struct _ParameterHolderClass ParameterHolderClass;
 
41
 
 
42
typedef struct _ToolInput {
 
43
    double delta_x, delta_y;
 
44
    double absolute_x, absolute_y;
 
45
    double click_relative_x, click_relative_y;
 
46
    double delta_time;
 
47
    GdkModifierType state;
 
48
} ToolInput;
 
49
 
 
50
struct _ParameterHolder {
 
51
    GObject object;
 
52
};
 
53
 
 
54
typedef void (ToolHandlerPH)(ParameterHolder *self, ToolInput *i);
 
55
 
 
56
typedef enum {
 
57
    TOOL_USE_MOTION_EVENTS = 1 << 0,
 
58
    TOOL_USE_IDLE          = 1 << 1,
 
59
} ToolFlags;
 
60
 
 
61
typedef struct _ToolInfoPH {
 
62
    gchar *menu_label;
 
63
    ToolHandlerPH *handler;
 
64
    ToolFlags flags;
 
65
} ToolInfoPH;
 
66
 
 
67
struct _ParameterHolderClass {
 
68
    GObjectClass parent_class;
 
69
 
 
70
    /* Overrideable methods */
 
71
    ToolInfoPH* (*get_tools) ();
 
72
};
 
73
 
 
74
typedef void (ParameterInterpolator)(ParameterHolder  *self,
 
75
                                     double   alpha,
 
76
                                     gpointer user_data);
 
77
 
 
78
#define PARAMETER_INTERPOLATOR(x)   ((ParameterInterpolator*)(x))
 
79
 
 
80
typedef struct {
 
81
    ParameterHolder *a, *b;
 
82
} ParameterHolderPair;
 
83
 
 
84
 
 
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 */
 
89
 
 
90
/* This is attached to the "increments" quark using param_spec_set_increments */
 
91
typedef struct {
 
92
    gdouble step, page;
 
93
    int digits;
 
94
} ParameterIncrements;
 
95
 
 
96
 
 
97
/************************************************************************************/
 
98
/******************************************************************* Public Methods */
 
99
/************************************************************************************/
 
100
 
 
101
GType             parameter_holder_get_type           ();
 
102
ParameterHolder*  parameter_holder_new                ();
 
103
 
 
104
void              parameter_holder_pair_free          (ParameterHolderPair *self);
 
105
 
 
106
void              parameter_holder_reset_to_defaults  (ParameterHolder *self);
 
107
 
 
108
void              parameter_holder_set                (ParameterHolder *self,
 
109
                                                       const gchar     *property,
 
110
                                                       const gchar     *value);
 
111
void              parameter_holder_set_from_line      (ParameterHolder *self,
 
112
                                                       const gchar     *line);
 
113
 
 
114
void              parameter_holder_load_string        (ParameterHolder *self,
 
115
                                                       const gchar     *params);
 
116
 
 
117
gchar*            parameter_holder_save_string        (ParameterHolder *self);
 
118
 
 
119
void              parameter_holder_interpolate_linear (ParameterHolder     *self,
 
120
                                                       gdouble              alpha,
 
121
                                                       ParameterHolderPair *p);
 
122
 
 
123
ToolInfoPH*       parameter_holder_get_tools          (ParameterHolder *self);
 
124
 
 
125
/*
 
126
 * These functions make it easy to assign extra metadata to GParamSpecs
 
127
 * that can be used when automatically building GUIs for ParameterHolder instances.
 
128
 */
 
129
 
 
130
void              param_spec_set_group      (GParamSpec  *pspec,
 
131
                                             const gchar *group_name);
 
132
 
 
133
void              param_spec_set_increments (GParamSpec  *pspec,
 
134
                                             gdouble      step,
 
135
                                             gdouble      page,
 
136
                                             int          digits);
 
137
 
 
138
void              param_spec_set_dependency (GParamSpec  *pspec,
 
139
                                             const gchar *dependency_name);
 
140
 
 
141
const gchar*      param_spec_get_group      (GParamSpec  *pspec);
 
142
 
 
143
const ParameterIncrements* param_spec_get_increments (GParamSpec  *pspec);
 
144
 
 
145
const gchar*      param_spec_get_dependency (GParamSpec  *pspec);
 
146
 
 
147
 
 
148
G_END_DECLS
 
149
 
 
150
#endif /* __PARAMETER_HOLDER_H__ */
 
151
 
 
152
/* The End */