2 #include <gdk/gdkkeysyms.h>
6 #include "../src/mark.h"
8 #include "../src/opticalflow.h"
17 #include "brightcontrast.h"
28 extern const guint8 img_size_1[];
29 extern const guint8 img_size_3[];
30 extern const guint8 img_size_5[];
31 extern const guint8 img_size_9[];
32 extern const guint8 img_size_11[];
33 extern const guint8 img_size_19[];
34 extern const guint8 img_fill[];
35 extern const guint8 img_move[];
36 extern const guint8 img_pick[];
38 struct paint_buttons {
40 GtkToggleButton *button;
49 { img_size_1, NULL, FALSE, 1, 1, 0, 0, 0, "Set pen size to 1" },
50 { img_size_3, NULL, TRUE, 2, 1, 0, 0, 0, "Set pen size to 3" },
51 { img_size_5, NULL, FALSE, 3, 1, 0, 0, 0, "Set pen size to 5" },
52 { img_size_9, NULL, FALSE, 5, 1, 0, 0, 0, "Set pen size to 9" },
53 { img_size_11, NULL, FALSE, 6, 1, 0, 0, 0, "Set pen size to 11" },
54 { img_size_19, NULL, FALSE, 10, 1, 0, 0, 0, "Set pen size to 19" },
55 { img_fill, NULL, FALSE, 0, 0, 0, 1, 0, "FILL marked area" },
56 { img_move, NULL, FALSE, 0, 0, 1, 0, 0, "Move marked pixles" },
57 { img_pick, NULL, FALSE, 0, 0, 0, 0, 1, "Pick color from marked area" },
58 { NULL, NULL, FALSE, 0, 0, 0, 0, 0, NULL },
61 void paint_button_toggled(GtkToggleButton *togglebutton, gpointer index)
65 if (paint_buttons[(long)index].toggle_state == gtk_toggle_button_get_active(togglebutton)) {
69 /* picker just toggles */
70 if (paint_buttons[(long)index].pick) {
72 if (paint_buttons[i].toggle_state == FALSE) {
73 paint_buttons[i].toggle_state = TRUE;
74 gtk_toggle_button_set_active(paint_buttons[i].button, TRUE);
81 for (i = 0; paint_buttons[i].button; i++) {
82 if ((long)index == i) {
83 paint_buttons[i].toggle_state = TRUE;
84 gtk_toggle_button_set_active(paint_buttons[i].button, TRUE);
85 brush_size = paint_buttons[i].size;
86 draw_mode = paint_buttons[i].draw;
87 move_mode = paint_buttons[i].move;
88 fill_mode = paint_buttons[i].fill;
91 paint_buttons[i].toggle_state = FALSE;
92 gtk_toggle_button_set_active(paint_buttons[i].button, FALSE);
98 void release_pick_mode(void)
103 for (i = 0; paint_buttons[i].button; i++) {
104 if (paint_buttons[i].pick) {
105 paint_buttons[i].toggle_state = FALSE;
106 gtk_toggle_button_set_active(paint_buttons[i].button, FALSE);
111 void zoomin_button_clicked(GtkButton *button, gpointer index)
116 void zoomout_button_clicked(GtkButton *button, gpointer index)
118 zoom_out_event(NULL);
121 void highlight_button_toggled(GtkButton *button, gpointer index)
123 highlight = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
124 set_menu_toggel_by_label(TOGGLE_LABEL_HIGHLIGHT, highlight);
125 draw_image(0, 0, -1, -1);
128 void preview_button_toggled(GtkButton *button, gpointer index)
130 preview = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
131 set_menu_toggel_by_label(TOGGLE_LABEL_PREVIEW, preview);
132 draw_image(0, 0, -1, -1);
135 void palette_button_clicked(GtkButton *button, gpointer index)
140 void bc_button_clicked(GtkButton *button, gpointer index)
145 void colorize_button_clicked(GtkButton *button, gpointer index)
147 colorize_event(NULL);
150 void view_colorized_button_toggled(GtkButton *button, gpointer index)
152 if (timeline_frames > 1)
153 rendered = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
156 gtk_toggle_button_set_active(show_colorized_button, rendered);
157 set_menu_toggel_by_label(TOGGLE_LABEL_RENDERED, rendered);
158 timeline_select_and_save(timeline_selected, timeline_selected);
162 void view_flow_button_toggled(GtkButton *button, gpointer index)
164 if (flow_enable && timeline_frames > 1)
165 flowview = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
168 gtk_toggle_button_set_active(show_flow_button, flowview);
169 set_menu_toggel_by_label(TOGGLE_LABEL_FLOWVIEW, flowview);
170 timeline_select_and_save(timeline_selected, timeline_selected);
174 extern const guint8 img_zoomin[];
175 extern const guint8 img_zoomout[];
176 extern const guint8 img_pal[];
177 extern const guint8 img_bc[];
178 extern const guint8 img_highlight[];
179 extern const guint8 img_preview[];
180 extern const guint8 img_eye[];
181 extern const guint8 img_col[];
182 extern const guint8 img_flow[];
184 struct tool_buttons {
185 enum toggle_label label;
189 void (*handler)(GtkButton *togglebutton, gpointer priv);
190 GtkToggleButton **button;
193 { TOGGLE_LABEL_NONE, NULL, img_zoomin, 0, zoomin_button_clicked, NULL, "Zoom in" },
194 { TOGGLE_LABEL_NONE, NULL, img_zoomout, 0, zoomout_button_clicked, NULL, "Zoom out" },
195 { TOGGLE_LABEL_NONE, NULL, img_pal, 0, palette_button_clicked, NULL, "Palette dialog" },
196 { TOGGLE_LABEL_NONE, NULL, img_bc, 0, bc_button_clicked, NULL, "Brightness+Contrast dialog" },
197 { TOGGLE_LABEL_HIGHLIGHT, NULL, img_highlight, 1, highlight_button_toggled, &show_highlighted_button, "Highlight selected mark color" },
198 { TOGGLE_LABEL_PREVIEW, NULL, img_preview, 1, preview_button_toggled, &show_preview_button, "Show preview of selected mark color" },
199 { TOGGLE_LABEL_RENDERED, NULL, img_eye, 1, view_colorized_button_toggled, &show_colorized_button, "Show result of a rendered sequence" },
201 { TOGGLE_LABEL_FLOWVIEW, NULL, img_flow, 1, view_flow_button_toggled, &show_flow_button, "Show optical flow" },
203 { TOGGLE_LABEL_NONE, NULL, img_col, 0, colorize_button_clicked, NULL, "Colorize current image" },
204 { TOGGLE_LABEL_NONE, NULL, NULL, 0, NULL, NULL, NULL },
207 void create_toolbar(GtkWidget *tool_bar)
212 GtkToggleButton *button;
213 GtkTooltips *tooltips;
214 GtkWidget *separator;
216 for (i = 0; paint_buttons[i].data; i++) {
217 pixbuf = gdk_pixbuf_new_from_inline(-1, paint_buttons[i].data, FALSE, NULL);
218 image = gtk_image_new_from_pixbuf(pixbuf);
219 gtk_widget_show(GTK_WIDGET(image));
220 paint_buttons[i].button = button = (GtkToggleButton *) gtk_toggle_button_new();
221 if (paint_buttons[i].toggle_state) {
222 gtk_toggle_button_set_active(button, TRUE);
223 brush_size = paint_buttons[i].size;
225 g_signal_connect(button, "toggled", G_CALLBACK(paint_button_toggled), (void *)((long)i));
226 tooltips = gtk_tooltips_new();
227 gtk_tooltips_set_tip(tooltips, GTK_WIDGET(button), paint_buttons[i].tooltip, NULL);
228 gtk_container_add (GTK_CONTAINER (button), image);
229 gtk_widget_show(GTK_WIDGET(button));
230 gtk_box_pack_start(GTK_BOX(tool_bar), GTK_WIDGET(button), FALSE, FALSE, 2);
233 for (i = 0; tool_buttons[i].data; i++) {
234 if (i == 0 || i == 2) {
235 /* add vertical seperation to hbox */
236 separator = gtk_vseparator_new();
237 gtk_widget_show(separator);
238 gtk_box_pack_start(GTK_BOX(tool_bar), separator, FALSE, FALSE, 3);
240 pixbuf = gdk_pixbuf_new_from_inline(-1, tool_buttons[i].data, FALSE, NULL);
241 image = gtk_image_new_from_pixbuf(pixbuf);
242 gtk_widget_show(GTK_WIDGET(image));
243 if (tool_buttons[i].toggle) {
244 button = (GtkToggleButton *) gtk_toggle_button_new();
245 g_signal_connect(button, "toggled", G_CALLBACK(tool_buttons[i].handler), NULL);
247 button = (GtkToggleButton *) gtk_button_new();
248 g_signal_connect(button, "clicked", G_CALLBACK(tool_buttons[i].handler), NULL);
250 tool_buttons[i].widget = (GtkWidget *)button;
251 tooltips = gtk_tooltips_new();
252 gtk_tooltips_set_tip(tooltips, GTK_WIDGET(button), tool_buttons[i].tooltip, NULL);
253 if (tool_buttons[i].button)
254 *(tool_buttons[i].button) = button;
255 gtk_container_add (GTK_CONTAINER (button), image);
256 gtk_widget_show(GTK_WIDGET(button));
257 gtk_box_pack_start(GTK_BOX(tool_bar), GTK_WIDGET(button), FALSE, FALSE, 2);
261 void set_button_toggel_by_label(enum toggle_label label, gboolean active)
265 for (i = 0; tool_buttons[i].data; i++) {
266 if (tool_buttons[i].label == label)
267 gtk_toggle_button_set_active((GtkToggleButton *)tool_buttons[i].widget, active);