summaryrefslogtreecommitdiff
path: root/src/program.h
blob: 51e40bf4fb8a95653a77bf3f6f9acc096e8cda9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/*
 * Copyright 2009 VMware, Inc.
 * All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * on the rights to use, copy, modify, merge, publish, distribute, sub
 * license, and/or sell copies of the Software, and to permit persons to whom
 * the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
 * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
 * USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#ifndef _RBUG_GUI_PROGRAM_H_
#define _RBUG_GUI_PROGRAM_H_

#include <gtk/gtk.h>
#include <gtk/gtkgl.h>

#include "rbug/rbug.h"

struct program;
struct texture_action_read;
struct shader_action_info;

struct rbug_event
{
	gboolean (*func)(struct rbug_event *, struct rbug_header *, struct program *);
};

enum columns {
	COLUMN_ID = 0,
	COLUMN_TYPE,
	COLUMN_TYPENAME,
	COLUMN_PIXBUF,
};

enum types {
	TYPE_NONE = 0,
	TYPE_SCREEN,
	TYPE_CONTEXT,
	TYPE_TEXTURE,
	TYPE_SHADER,
};

enum ctx_view_id {
	CTX_VIEW_FRAGMENT = 0,
	CTX_VIEW_VERTEX,
	CTX_VIEW_GEOM,
	CTX_VIEW_ZS,
	CTX_VIEW_COLOR0,
	CTX_VIEW_COLOR1,
	CTX_VIEW_COLOR2,
	CTX_VIEW_COLOR3,
	CTX_VIEW_COLOR4,
	CTX_VIEW_COLOR5,
	CTX_VIEW_COLOR6,
	CTX_VIEW_COLOR7,
	CTX_VIEW_NUM,
};

struct program
{
	struct {
		GtkWidget *window;
		GtkWidget *entry_host;
		GtkWidget *entry_port;
		GtkAdjustment *adjustment_port;

		char *host;
		uint16_t port;
	} ask;

	struct {
		uint32_t width;
		uint32_t height;
		GdkGLConfig *config;
	} draw;

	struct {
		GtkWidget *window;
		GtkWidget *context_view;
		GtkTextView *textview;
		GtkWidget *textview_scrolled;
		GtkTreeView *treeview;
		GtkTreeStore *treestore;
		GtkDrawingArea *draw;

		GtkTreeIter top;
	} main;

	struct {
		GtkTreeIter iter;
		enum types type;
		guint64 parent;
		guint64 id;
	} selected;

	struct {
		GtkTreeIter iter;
		enum types type;
		guint64 parent;
		guint64 id;
	} viewed;

	struct {
		GtkWidget *break_before;
		GtkWidget *break_after;
		GtkWidget *step;
		GtkWidget *separator;

		GtkWidget *back;
		GtkWidget *forward;
		GtkWidget *background;
		GtkWidget *alpha;
		GtkWidget *automatic;

		GtkWidget *enable;
		GtkWidget *disable;
		GtkWidget *save;
		GtkWidget *revert;
	} tool;

	struct {
		/* signal ids */
		gulong sid[16];

		GObject *ra[12];

		enum ctx_view_id view_id;

		struct rbug_event blocked_event;
	} context;

	struct {
		gulong id[8];

		struct shader_action_info *info;
	} shader;

	struct {
		struct texture_action_read *read;

		/* current texture loaded */
		gboolean alpha;
		rbug_texture_t id;
		unsigned width;
		unsigned height;

		gulong tid[3];
		gboolean automatic;
		int back;

		int levels[16];
	} texture;

	struct {
		int socket;
		struct rbug_connection *con;
		GIOChannel *channel;
		gint event;
		GHashTable *hash_event;
		GHashTable *hash_reply;
	} rbug;

	struct {
		GHashTable *hash;
	} icon;
};


/* src/ask.c */
void ask_window_create(struct program *p);
gboolean ask_connect(struct program *p);


/* src/main.c */
void main_window_create(struct program *p);
void main_quit(struct program *p);
gboolean main_find_id(guint64 id, GtkTreeIter *out, struct program *p);
void main_set_viewed(GtkTreeIter *iter, gboolean force_update, struct program *p);
void icon_add(const char *filename, const char *name, struct program *p);
GdkPixbuf* icon_get(const char *name, struct program *p);


/* src/rbug.c */
void rbug_add_reply(struct rbug_event *e, uint32_t serial, struct program *p);
void rbug_add_event(struct rbug_event *e, int16_t op, struct program *p);
void rbug_glib_io_watch(struct program *p);
void rbug_finish_and_emit_events(struct program *p);


/* src/context.c */
void context_unselected(struct program *p);
void context_selected(struct program *p);
void context_init(struct program *p);
void context_list(GtkTreeStore *store,
                  GtkTreeIter *parent,
                  struct program *p);


/* src/texture.c */
void texture_list(GtkTreeStore *store, GtkTreeIter *parent, struct program *p);
void texture_unselected(struct program *p);
void texture_selected(struct program *p);
void texture_unviewed(struct program *p);
void texture_viewed(struct program *p);
void texture_refresh(struct program *p);
void texture_draw(struct program *p);


/* src/shader.c */
void shader_unselected(struct program *p);
void shader_selected(struct program *p);
void shader_unviewed(struct program *p);
void shader_viewed(struct program *p);
void shader_refresh(struct program *p);
void shader_list(GtkTreeStore *store,
                 GtkTreeIter *parent,
                 rbug_context_t ctx,
                 struct program *p);


/* src/draw.c */
void draw_setup(GtkDrawingArea *draw, struct program *p);
gboolean draw_gl_begin(struct program *p);
void draw_gl_end(struct program *p);
void draw_checker(guint width, guint height, struct program *p);
void draw_ortho_top_left(struct program *p);


#endif