diff options
author | Jakob Bornecrantz <jakob@vmware.com> | 2009-06-04 23:43:46 +0100 |
---|---|---|
committer | Jakob Bornecrantz <jakob@vmware.com> | 2009-06-04 23:43:46 +0100 |
commit | 28f37b190453b71c389550e75f4a51ed79380610 (patch) | |
tree | c264d4cf9adb1ea7ea9be251edbe92124d993979 | |
parent | e5ff1c8f64df27558c4ccd8f619b6cdc4a141aff (diff) |
Add context view and manipulation
-rw-r--r-- | res/main.xml | 249 | ||||
-rw-r--r-- | src/context.c | 310 | ||||
-rw-r--r-- | src/draw.c | 2 | ||||
-rw-r--r-- | src/main.c | 92 | ||||
-rw-r--r-- | src/program.h | 41 | ||||
-rw-r--r-- | src/shader.c | 11 | ||||
-rw-r--r-- | src/texture.c | 4 |
7 files changed, 695 insertions, 14 deletions
diff --git a/res/main.xml b/res/main.xml index 7772398..c208043 100644 --- a/res/main.xml +++ b/res/main.xml @@ -36,15 +36,53 @@ </packing> </child> <child> - <object class="GtkSeparatorToolItem" id="separator"> + <object class="GtkSeparatorToolItem" id="_separatortoolitem1"> <property name="visible">True</property> </object> <packing> <property name="expand">False</property> + </packing> + </child> + <child> + <object class="GtkToggleToolButton" id="tool_break_before"> + <property name="label" translatable="yes">Break Before</property> + <property name="use_underline">True</property> + <property name="stock_id">gtk-stop</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToggleToolButton" id="tool_break_after"> + <property name="label" translatable="yes">Break After</property> + <property name="use_underline">True</property> + <property name="stock_id">gtk-stop</property> + </object> + <packing> + <property name="expand">False</property> <property name="homogeneous">True</property> </packing> </child> <child> + <object class="GtkToolButton" id="tool_step"> + <property name="label" translatable="yes">Step</property> + <property name="use_underline">True</property> + <property name="stock_id">gtk-jump-to</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkSeparatorToolItem" id="tool_separator"/> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> <object class="GtkToolButton" id="tool_back"> <property name="label" translatable="yes">Back</property> <property name="use_underline">True</property> @@ -217,6 +255,160 @@ <property name="visible">True</property> <property name="orientation">vertical</property> <child> + <object class="GtkHBox" id="context_view"> + <child> + <object class="GtkTable" id="_table1"> + <property name="visible">True</property> + <property name="n_rows">2</property> + <property name="n_columns">2</property> + <child> + <object class="GtkLabel" id="_label1"> + <property name="visible">True</property> + <property name="xalign">1</property> + <property name="label" translatable="yes">Shaders: </property> + </object> + </child> + <child> + <object class="GtkLabel" id="_label2"> + <property name="visible">True</property> + <property name="xalign">1</property> + <property name="label" translatable="yes">Surfaces: </property> + </object> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkHButtonBox" id="_hbuttonbox1"> + <property name="visible">True</property> + <property name="spacing">2</property> + <property name="layout_style">start</property> + <child> + <object class="GtkToggleButton" id="_togglebutton1"> + <property name="label" translatable="yes">Fragment</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="related_action">ra_ctx_fragment</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkToggleButton" id="_togglebutton2"> + <property name="label" translatable="yes">Vertex</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="related_action">ra_ctx_vertex</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + </packing> + </child> + <child> + <object class="GtkHButtonBox" id="_hbuttonbox2"> + <property name="visible">True</property> + <property name="spacing">2</property> + <property name="layout_style">start</property> + <child> + <object class="GtkToggleButton" id="_togglebutton3"> + <property name="label" translatable="yes">Color 1</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="related_action">ra_ctx_color0</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkToggleButton" id="_togglebutton4"> + <property name="label" translatable="yes">Color 2</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="related_action">ra_ctx_color1</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkToggleButton" id="_togglebutton5"> + <property name="label" translatable="yes">Color 3</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="related_action">ra_ctx_color2</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkToggleButton" id="_togglebutton6"> + <property name="label" translatable="yes">ZS</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="related_action">ra_ctx_zs</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">3</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="padding">2</property> + <property name="position">0</property> + </packing> + </child> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="padding">4</property> + <property name="position">0</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <child> <object class="GtkScrolledWindow" id="textview_scrolled"> <property name="visible">True</property> <property name="can_focus">True</property> @@ -229,18 +421,15 @@ </child> </object> <packing> - <property name="position">0</property> + <property name="position">2</property> </packing> </child> <child> <object class="GtkDrawingArea" id="draw"/> <packing> - <property name="position">1</property> + <property name="position">3</property> </packing> </child> - <child> - <placeholder/> - </child> </object> <packing> <property name="resize">True</property> @@ -264,4 +453,52 @@ </object> </child> </object> + <object class="GtkRadioAction" id="ra_ctx_fragment"> + <property name="draw_as_radio">True</property> + <property name="active">True</property> + </object> + <object class="GtkRadioAction" id="ra_ctx_vertex"> + <property name="draw_as_radio">True</property> + <property name="group">ra_ctx_fragment</property> + </object> + <object class="GtkRadioAction" id="ra_ctx_geom"> + <property name="draw_as_radio">True</property> + <property name="group">ra_ctx_fragment</property> + </object> + <object class="GtkRadioAction" id="ra_ctx_color0"> + <property name="draw_as_radio">True</property> + <property name="group">ra_ctx_fragment</property> + </object> + <object class="GtkRadioAction" id="ra_ctx_color1"> + <property name="draw_as_radio">True</property> + <property name="group">ra_ctx_fragment</property> + </object> + <object class="GtkRadioAction" id="ra_ctx_color2"> + <property name="draw_as_radio">True</property> + <property name="group">ra_ctx_fragment</property> + </object> + <object class="GtkRadioAction" id="ra_ctx_color3"> + <property name="draw_as_radio">True</property> + <property name="group">ra_ctx_fragment</property> + </object> + <object class="GtkRadioAction" id="ra_ctx_color4"> + <property name="draw_as_radio">True</property> + <property name="group">ra_ctx_fragment</property> + </object> + <object class="GtkRadioAction" id="ra_ctx_color5"> + <property name="draw_as_radio">True</property> + <property name="group">ra_ctx_fragment</property> + </object> + <object class="GtkRadioAction" id="ra_ctx_color6"> + <property name="draw_as_radio">True</property> + <property name="group">ra_ctx_fragment</property> + </object> + <object class="GtkRadioAction" id="ra_ctx_color7"> + <property name="draw_as_radio">True</property> + <property name="group">ra_ctx_fragment</property> + </object> + <object class="GtkRadioAction" id="ra_ctx_zs"> + <property name="draw_as_radio">True</property> + <property name="group">ra_ctx_fragment</property> + </object> </interface> diff --git a/src/context.c b/src/context.c index 3515053..a90fc02 100644 --- a/src/context.c +++ b/src/context.c @@ -24,6 +24,120 @@ #include "program.h" +#include "pipe/p_defines.h" + + +/* + * Actions + */ + +struct context_action_info; + +static struct context_action_info * +context_start_info_action(rbug_context_t c, GtkTreeIter *iter, struct program *p); +static void +context_stop_info_action(struct context_action_info *info, struct program *p); + + +/* + * Private + */ + + +static void ra(GtkWidget *widget, struct program *p) +{ + gboolean active; + int i; + + for (i = 0; i < CTX_VIEW_NUM; i++) + if (p->context.ra[i] == G_OBJECT(widget)) + break; + + g_assert(i < CTX_VIEW_NUM); + + active = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(widget)); + + if (!active || (unsigned)i == p->context.view_id) + return; + + p->context.view_id = i; + + context_start_info_action(p->selected.id, &p->selected.iter, p); +} + +static void break_before(GtkWidget *widget, struct program *p) +{ + struct rbug_connection *con = p->rbug.con; + gboolean active; + (void)widget; + + g_assert(p->selected.type == TYPE_CONTEXT); + + active = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(widget)); + + if (active) + rbug_send_context_draw_block(con, p->selected.id, + RBUG_BLOCK_BEFORE, NULL); + else + rbug_send_context_draw_unblock(con, p->selected.id, + RBUG_BLOCK_BEFORE, NULL); +} + +static void break_after(GtkWidget *widget, struct program *p) +{ + struct rbug_connection *con = p->rbug.con; + gboolean active; + (void)widget; + + g_assert(p->selected.type == TYPE_CONTEXT); + + active = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(widget)); + + if (active) + rbug_send_context_draw_block(con, p->selected.id, + RBUG_BLOCK_AFTER, NULL); + else + rbug_send_context_draw_unblock(con, p->selected.id, + RBUG_BLOCK_AFTER, NULL); +} + +static void step(GtkWidget *widget, struct program *p) +{ + struct rbug_connection *con = p->rbug.con; + (void)widget; + + g_assert(p->selected.type == TYPE_CONTEXT); + + rbug_send_context_draw_step(con, p->selected.id, + RBUG_BLOCK_BEFORE | RBUG_BLOCK_AFTER, NULL); +} + +static gboolean blocked(struct rbug_event *e, struct rbug_header *h, struct program *p) +{ + struct rbug_proto_context_draw_blocked *b = (struct rbug_proto_context_draw_blocked *)h; + GtkTreeIter iter; + (void)e; + + /* auto flush on break */ + if (b->block & RBUG_BLOCK_AFTER) + rbug_send_context_flush(p->rbug.con, b->context, + PIPE_FLUSH_TEXTURE_CACHE | + PIPE_FLUSH_RENDER_CACHE, NULL); + + if (main_find_id(b->context, &iter, p)) + context_start_info_action(b->context, &iter, p); + + (void)context_stop_info_action; + + return TRUE; +} + + +/* + * Exported + */ + + void context_list(GtkTreeStore *store, GtkTreeIter *parent, struct program *p) { struct rbug_proto_context_list_reply *list; @@ -51,3 +165,199 @@ void context_list(GtkTreeStore *store, GtkTreeIter *parent, struct program *p) rbug_free_header(header); } + +void context_unselected(struct program *p) +{ + int i; + + gtk_widget_hide(p->main.context_view); + gtk_widget_hide(p->tool.break_before); + gtk_widget_hide(p->tool.break_after); + gtk_widget_hide(p->tool.step); + gtk_widget_hide(p->tool.separator); + + for (i = 0; i < CTX_VIEW_NUM; i++) + g_signal_handler_disconnect(p->context.ra[i], p->context.sid[i]); + g_signal_handler_disconnect(p->tool.step, p->context.sid[12]); + g_signal_handler_disconnect(p->tool.break_before, p->context.sid[13]); + g_signal_handler_disconnect(p->tool.break_after, p->context.sid[14]); +} + +void context_selected(struct program *p) +{ + g_assert(p->selected.type == TYPE_CONTEXT); + int i; + + for (i = 0; i < CTX_VIEW_NUM; i++) + p->context.sid[i] = g_signal_connect(p->context.ra[i], "toggled", G_CALLBACK(ra), p); + p->context.sid[12] = g_signal_connect(p->tool.step, "clicked", G_CALLBACK(step), p); + p->context.sid[13] = g_signal_connect(p->tool.break_before, "toggled", G_CALLBACK(break_before), p); + p->context.sid[14] = g_signal_connect(p->tool.break_after, "toggled", G_CALLBACK(break_after), p); + + gtk_widget_show(p->main.context_view); + gtk_widget_show(p->tool.break_before); + gtk_widget_show(p->tool.break_after); + gtk_widget_show(p->tool.step); + gtk_widget_show(p->tool.separator); + + context_start_info_action(p->selected.id, &p->selected.iter, p); +} + +void context_init(struct program *p) +{ + p->context.blocked_event.func = blocked; + + rbug_add_event(&p->context.blocked_event, RBUG_OP_CONTEXT_DRAW_BLOCKED, p); +} + + +/* + * Action fuctions + */ + + +struct context_action_info +{ + struct rbug_event e; + + rbug_context_t cid; + + GtkTreeIter iter; + + gboolean running; + gboolean pending; +}; + +static void context_action_info_clean(struct context_action_info *action, struct program *p) +{ + (void)p; + + if (!action) + return; + + g_free(action); +} + +static gboolean context_action_info_info(struct rbug_event *e, + struct rbug_header *header, + struct program *p) +{ + struct rbug_proto_context_info_reply *info; + struct context_action_info *action; + GtkTreeIter iter; + GdkPixbuf *buf = NULL; + gboolean ret; + + + info = (struct rbug_proto_context_info_reply *)header; + action = (struct context_action_info *)e; + + /* ack pending message */ + action->pending = FALSE; + + g_assert(header->opcode == RBUG_OP_CONTEXT_INFO_REPLY); + + if (info->blocker || info->blocked) + buf = icon_get("shader_off_normal", p); + else + buf = icon_get("shader_on_normal", p); + + gtk_tree_store_set(p->main.treestore, &action->iter, COLUMN_PIXBUF, buf, -1); + + /* if this context is not currently selected */ + if (action->cid != p->selected.id) + goto out; + + if (info->blocker & RBUG_BLOCK_BEFORE) + gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(p->tool.break_before), TRUE); + else + gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(p->tool.break_before), FALSE); + + if (info->blocker & RBUG_BLOCK_AFTER) + gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(p->tool.break_after), TRUE); + else + gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(p->tool.break_after), FALSE); + + ret = FALSE; + switch (p->context.view_id) { + case CTX_VIEW_FRAGMENT: + ret = main_find_id(info->fragment, &iter, p); + break; + case CTX_VIEW_VERTEX: + ret = main_find_id(info->vertex, &iter, p); + break; + case CTX_VIEW_COLOR0: + if (info->cbufs_len < 1) + break; + if (info->cbufs[0] == 0) + break; + ret = main_find_id(info->cbufs[0], &iter, p); + break; + case CTX_VIEW_COLOR1: + if (info->cbufs_len < 2) + break; + if (info->cbufs[1] == 0) + break; + ret = main_find_id(info->cbufs[1], &iter, p); + break; + case CTX_VIEW_COLOR2: + if (info->cbufs_len < 3) + break; + if (info->cbufs[2] == 0) + break; + ret = main_find_id(info->cbufs[2], &iter, p); + break; + case CTX_VIEW_ZS: + if (info->zsbuf == 0) + break; + ret = main_find_id(info->zsbuf, &iter, p); + break; + default: + break; + } + + if (ret) + main_set_viewed(&iter, TRUE, p); + else + main_set_viewed(NULL, FALSE, p); + +out: + context_action_info_clean(action, p); + return FALSE; +} + +static struct context_action_info * +context_start_info_action(rbug_context_t c, + GtkTreeIter *iter, + struct program *p) +{ + struct rbug_connection *con = p->rbug.con; + struct context_action_info *action; + uint32_t serial = 0; + + action = g_malloc(sizeof(*action)); + memset(action, 0, sizeof(*action)); + + rbug_send_context_info(con, c, &serial); + + action->e.func = context_action_info_info; + action->cid = c; + action->iter = *iter; + action->pending = TRUE; + action->running = TRUE; + + rbug_add_reply(&action->e, serial, p); + + return action; +} + +static void context_stop_info_action(struct context_action_info *action, struct program *p) +{ + if (!action) + return; + + action->running = FALSE; + + if (!action->pending) + context_action_info_clean(action, p); +} @@ -149,7 +149,7 @@ static gboolean expose(GtkWidget* widget, GdkEventExpose* e, gpointer data) if (!gdk_gl_drawable_gl_begin(drawable, context)) return FALSE; - if (p->selected.type == TYPE_TEXTURE) + if (p->viewed.type == TYPE_TEXTURE) texture_draw(p); else draw_tri(p); @@ -135,12 +135,16 @@ static void changed(GtkTreeSelection *s, gpointer data) shader_unselected(p); else if (old_type == TYPE_TEXTURE) texture_unselected(p); + else if (old_type == TYPE_CONTEXT) + context_unselected(p); } if (p->selected.id) { if (p->selected.type == TYPE_SHADER) shader_selected(p); else if (p->selected.type == TYPE_TEXTURE) texture_selected(p); + else if (p->selected.type == TYPE_CONTEXT) + context_selected(p); } } } @@ -235,7 +239,50 @@ static void icon_setup(struct program *p) icon_add("res/shader_off_replaced.png", "shader_off_replaced", p); } -void main_set_viewed(GtkTreeIter *iter, struct program *p) +struct find_struct +{ + GtkTreeIter *out; + guint64 id; + gboolean result; +}; + +static gboolean find_foreach(GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data) +{ + struct find_struct *find = (struct find_struct *)data; + guint64 id; + (void)path; + + gtk_tree_model_get(model, iter, + COLUMN_ID, &id, + -1); + + if (id == find->id) { + *find->out = *iter; + find->result = TRUE; + return TRUE; + } + + return FALSE; +} + +gboolean main_find_id(guint64 id, GtkTreeIter *out, struct program *p) +{ + GtkTreeModel *model = GTK_TREE_MODEL(p->main.treestore); + struct find_struct find; + + find.out = out; + find.id = id; + find.result = FALSE; + + gtk_tree_model_foreach(model, find_foreach, &find); + + return find.result; +} + +void main_set_viewed(GtkTreeIter *iter, gboolean force_update, struct program *p) { GtkTreeModel *model = GTK_TREE_MODEL(p->main.treestore); GtkTreeIter parent; @@ -286,12 +333,20 @@ void main_set_viewed(GtkTreeIter *iter, struct program *p) else if (old_type == TYPE_TEXTURE) texture_unviewed(p); } + if (p->viewed.id) { if (p->viewed.type == TYPE_SHADER) shader_viewed(p); - else if (p->selected.type == TYPE_TEXTURE) + else if (p->viewed.type == TYPE_TEXTURE) texture_viewed(p); } + } else { + if (force_update || p->viewed.id) { + if (p->viewed.type == TYPE_SHADER) + shader_refresh(p); + else if (p->viewed.type == TYPE_TEXTURE) + texture_refresh(p); + } } } @@ -303,6 +358,7 @@ void main_window_create(struct program *p) GObject *selection; GtkDrawingArea *draw; GtkTextView *textview; + GtkWidget *context_view; GtkWidget *textview_scrolled; GtkTreeView *treeview; GtkTreeStore *treestore; @@ -310,6 +366,11 @@ void main_window_create(struct program *p) GObject *tool_quit; GObject *tool_refresh; + GObject *tool_break_before; + GObject *tool_break_after; + GObject *tool_step; + GObject *tool_separator; + GObject *tool_back; GObject *tool_forward; GObject *tool_background; @@ -332,12 +393,18 @@ void main_window_create(struct program *p) treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview")); treestore = GTK_TREE_STORE(gtk_builder_get_object(builder, "treestore")); selection = G_OBJECT(gtk_tree_view_get_selection(treeview)); + context_view = GTK_WIDGET(gtk_builder_get_object(builder, "context_view")); textview_scrolled = GTK_WIDGET(gtk_builder_get_object(builder, "textview_scrolled")); tool_quit = gtk_builder_get_object(builder, "tool_quit"); tool_refresh = gtk_builder_get_object(builder, "tool_refresh"); + tool_break_before = gtk_builder_get_object(builder, "tool_break_before"); + tool_break_after = gtk_builder_get_object(builder, "tool_break_after"); + tool_step = gtk_builder_get_object(builder, "tool_step"); + tool_separator = gtk_builder_get_object(builder, "tool_separator"); + tool_back = gtk_builder_get_object(builder, "tool_back"); tool_forward = gtk_builder_get_object(builder, "tool_forward"); tool_background = gtk_builder_get_object(builder, "tool_background"); @@ -357,13 +424,32 @@ void main_window_create(struct program *p) g_signal_connect(tool_refresh, "clicked", G_CALLBACK(refresh), p); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), p); + p->context.ra[0] = gtk_builder_get_object(builder, "ra_ctx_fragment"); + p->context.ra[1] = gtk_builder_get_object(builder, "ra_ctx_vertex"); + p->context.ra[2] = gtk_builder_get_object(builder, "ra_ctx_geom"); + p->context.ra[3] = gtk_builder_get_object(builder, "ra_ctx_zs"); + p->context.ra[4] = gtk_builder_get_object(builder, "ra_ctx_color0"); + p->context.ra[5] = gtk_builder_get_object(builder, "ra_ctx_color1"); + p->context.ra[6] = gtk_builder_get_object(builder, "ra_ctx_color2"); + p->context.ra[7] = gtk_builder_get_object(builder, "ra_ctx_color3"); + p->context.ra[8] = gtk_builder_get_object(builder, "ra_ctx_color4"); + p->context.ra[9] = gtk_builder_get_object(builder, "ra_ctx_color5"); + p->context.ra[10] = gtk_builder_get_object(builder, "ra_ctx_color6"); + p->context.ra[11] = gtk_builder_get_object(builder, "ra_ctx_color7"); + p->main.draw = draw; p->main.window = window; p->main.textview = textview; p->main.treeview = treeview; p->main.treestore = treestore; + p->main.context_view = context_view; p->main.textview_scrolled = textview_scrolled; + p->tool.break_before = GTK_WIDGET(tool_break_before); + p->tool.break_after = GTK_WIDGET(tool_break_after); + p->tool.step = GTK_WIDGET(tool_step); + p->tool.separator = GTK_WIDGET(tool_separator); + p->tool.back = GTK_WIDGET(tool_back); p->tool.forward = GTK_WIDGET(tool_forward); p->tool.background = GTK_WIDGET(tool_background); @@ -395,6 +481,8 @@ void main_window_create(struct program *p) icon_setup(p); + context_init(p); + /* do a refresh */ refresh(GTK_WIDGET(tool_refresh), p); } diff --git a/src/program.h b/src/program.h index 36d6a41..51e40bf 100644 --- a/src/program.h +++ b/src/program.h @@ -54,6 +54,22 @@ enum types { 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 { @@ -74,6 +90,7 @@ struct program struct { GtkWidget *window; + GtkWidget *context_view; GtkTextView *textview; GtkWidget *textview_scrolled; GtkTreeView *treeview; @@ -98,6 +115,11 @@ struct program } viewed; struct { + GtkWidget *break_before; + GtkWidget *break_after; + GtkWidget *step; + GtkWidget *separator; + GtkWidget *back; GtkWidget *forward; GtkWidget *background; @@ -111,6 +133,17 @@ struct program } 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; @@ -155,7 +188,8 @@ gboolean ask_connect(struct program *p); /* src/main.c */ void main_window_create(struct program *p); void main_quit(struct program *p); -void main_set_viewed(GtkTreeIter *iter, 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); @@ -168,10 +202,14 @@ 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); @@ -187,6 +225,7 @@ 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, diff --git a/src/shader.c b/src/shader.c index 867e78d..a73aebd 100644 --- a/src/shader.c +++ b/src/shader.c @@ -161,6 +161,13 @@ out: g_free(text); } +void shader_refresh(struct program *p) +{ + g_assert(p->viewed.type == TYPE_SHADER); + + shader_start_info_action(p->viewed.parent, p->viewed.id, &p->viewed.iter, p); +} + void shader_viewed(struct program *p) { g_assert(p->viewed.type == TYPE_SHADER); @@ -196,12 +203,12 @@ void shader_unviewed(struct program *p) void shader_unselected(struct program *p) { - main_set_viewed(NULL, p); + main_set_viewed(NULL, FALSE, p); } void shader_selected(struct program *p) { - main_set_viewed(&p->selected.iter, p); + main_set_viewed(&p->selected.iter, FALSE, p); } void shader_list(GtkTreeStore *store, GtkTreeIter *parent, diff --git a/src/texture.c b/src/texture.c index dc19b79..f99d84a 100644 --- a/src/texture.c +++ b/src/texture.c @@ -205,12 +205,12 @@ void texture_viewed(struct program *p) void texture_unselected(struct program *p) { - main_set_viewed(NULL, p); + main_set_viewed(NULL, FALSE, p); } void texture_selected(struct program *p) { - main_set_viewed(&p->selected.iter, p); + main_set_viewed(&p->selected.iter, FALSE, p); } /* |