#endif
#include "main.h"
#include "menu.h"
+#include "toolbar.h"
#include "image.h"
#include "palette.h"
#include "timeline.h"
}
/*
- * tool bar
- */
-
-extern const guint8 img_size_1[];
-extern const guint8 img_size_3[];
-extern const guint8 img_size_5[];
-extern const guint8 img_size_9[];
-extern const guint8 img_size_11[];
-extern const guint8 img_size_19[];
-extern const guint8 img_fill[];
-extern const guint8 img_move[];
-
-struct paint_buttons {
- const guint8 *data;
- GtkToggleButton *button;
- int toggle_state;
- int size;
- int move;
- int fill;
- const char *tooltip;
-} paint_buttons[] = {
- { img_size_1, NULL, FALSE, 1, 0, 0, "Set pen size to 1" },
- { img_size_3, NULL, TRUE, 2, 0, 0, "Set pen size to 3" },
- { img_size_5, NULL, FALSE, 3, 0, 0, "Set pen size to 5" },
- { img_size_9, NULL, FALSE, 5, 0, 0, "Set pen size to 9" },
- { img_size_11, NULL, FALSE, 6, 0, 0, "Set pen size to 11" },
- { img_size_19, NULL, FALSE, 10, 0, 0, "Set pen size to 19" },
- { img_fill, NULL, FALSE, 0, 0, 1, "FILL marked area" },
- { img_move, NULL, FALSE, 0, 1, 0, "Move marked pixles" },
- { NULL, NULL, 0, 0, 0, 0, NULL },
-};
-
-void paint_button_toggled(GtkToggleButton *togglebutton, gpointer index)
-{
- int i;
-
- if (paint_buttons[(long)index].toggle_state == gtk_toggle_button_get_active(togglebutton)) {
- return;
- }
-
- for (i = 0; paint_buttons[i].button; i++) {
- if ((long)index == i) {
- paint_buttons[i].toggle_state = TRUE;
- gtk_toggle_button_set_active(paint_buttons[i].button, TRUE);
- brush_size = paint_buttons[i].size;
- move_mode = paint_buttons[i].move;
- fill_mode = paint_buttons[i].fill;
- } else {
- paint_buttons[i].toggle_state = FALSE;
- gtk_toggle_button_set_active(paint_buttons[i].button, FALSE);
- }
- }
-
-}
-
-void zoomin_button_clicked(GtkButton *button, gpointer index)
-{
- zoom_in_event(NULL);
-}
-
-void zoomout_button_clicked(GtkButton *button, gpointer index)
-{
- zoom_out_event(NULL);
-}
-
-void highlight_button_toggled(GtkButton *button, gpointer index)
-{
- highlight = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
- set_menu_toggel_by_label(TOGGLE_LABEL_HIGHLIGHT, highlight);
- draw_image(0, 0, -1, -1);
-}
-
-void preview_button_toggled(GtkButton *button, gpointer index)
-{
- preview = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
- set_menu_toggel_by_label(TOGGLE_LABEL_PREVIEW, preview);
- draw_image(0, 0, -1, -1);
-}
-
-void palette_button_clicked(GtkButton *button, gpointer index)
-{
- palette_event(NULL);
-}
-
-void bc_button_clicked(GtkButton *button, gpointer index)
-{
- bc_event(NULL);
-}
-
-void colorize_button_clicked(GtkButton *button, gpointer index)
-{
- colorize_event(NULL);
-}
-
-void view_colorized_button_toggled(GtkButton *button, gpointer index)
-{
- if (timeline_frames > 1)
- rendered = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
- else
- rendered = 0;
- gtk_toggle_button_set_active(show_colorized_button, rendered);
- set_menu_toggel_by_label(TOGGLE_LABEL_RENDERED, rendered);
- timeline_select_and_save(timeline_selected, timeline_selected);
-}
-
-#ifdef WITH_OPENCV
-void view_flow_button_toggled(GtkButton *button, gpointer index)
-{
- if (flow_enable && timeline_frames > 1)
- flowview = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
- else
- flowview = 0;
- gtk_toggle_button_set_active(show_flow_button, flowview);
- set_menu_toggel_by_label(TOGGLE_LABEL_FLOWVIEW, flowview);
- timeline_select_and_save(timeline_selected, timeline_selected);
-}
-#endif
-
-extern const guint8 img_zoomin[];
-extern const guint8 img_zoomout[];
-extern const guint8 img_pal[];
-extern const guint8 img_bc[];
-extern const guint8 img_highlight[];
-extern const guint8 img_preview[];
-extern const guint8 img_eye[];
-extern const guint8 img_col[];
-extern const guint8 img_flow[];
-
-struct tool_buttons {
- enum toggle_label label;
- GtkWidget *widget;
- const guint8 *data;
- int toggle;
- void (*handler)(GtkButton *togglebutton, gpointer priv);
- GtkToggleButton **button;
- const char *tooltip;
-} tool_buttons[] = {
- { TOGGLE_LABEL_NONE, NULL, img_zoomin, 0, zoomin_button_clicked, NULL, "Zoom in" },
- { TOGGLE_LABEL_NONE, NULL, img_zoomout, 0, zoomout_button_clicked, NULL, "Zoom out" },
- { TOGGLE_LABEL_NONE, NULL, img_pal, 0, palette_button_clicked, NULL, "Palette dialog" },
- { TOGGLE_LABEL_NONE, NULL, img_bc, 0, bc_button_clicked, NULL, "Brightness+Contrast dialog" },
- { TOGGLE_LABEL_HIGHLIGHT, NULL, img_highlight, 1, highlight_button_toggled, &show_highlighted_button, "Highlight selected mark color" },
- { TOGGLE_LABEL_PREVIEW, NULL, img_preview, 1, preview_button_toggled, &show_preview_button, "Show preview of selected mark color" },
- { TOGGLE_LABEL_RENDERED, NULL, img_eye, 1, view_colorized_button_toggled, &show_colorized_button, "Show result of a rendered sequence" },
-#ifdef WITH_OPENCV
- { TOGGLE_LABEL_FLOWVIEW, NULL, img_flow, 1, view_flow_button_toggled, &show_flow_button, "Show optical flow" },
-#endif
- { TOGGLE_LABEL_NONE, NULL, img_col, 0, colorize_button_clicked, NULL, "Colorize current image" },
- { TOGGLE_LABEL_NONE, NULL, NULL, 0, NULL, NULL, NULL },
-};
-
-void set_button_toggel_by_label(enum toggle_label label, gboolean active)
-{
- int i;
-
- for (i = 0; tool_buttons[i].data; i++) {
- if (tool_buttons[i].label == label)
- gtk_toggle_button_set_active((GtkToggleButton *)tool_buttons[i].widget, active);
- }
-}
-
-/*
* creation of main window
*/
int main(int argc, char *argv[])
{
- GtkWidget *vbox, *tool_box;
+ GtkWidget *vbox, *tool_bar;
GtkWidget *paned;
GtkWidget *pal_scroll;
GtkWidget *menu_bar;
- GtkWidget *separator;
GtkTreeSelection *selection;
GtkTreeViewColumn *palette_column;
GtkCellRenderer *palette_renderer;
- GtkToggleButton *button;
- GtkWidget *image;
- GdkPixbuf *pixbuf;
- GtkTooltips *tooltips;
-
- int i;
gtk_init(&argc, &argv);
gtk_widget_show(menu_bar);
create_menus(menu_bar);
- /* add tool_box to vbox (bottom part of palette box) */
- tool_box = gtk_hbox_new(FALSE, 0);
- gtk_box_pack_start(GTK_BOX(vbox), tool_box, FALSE, FALSE, 2);
- gtk_widget_show(tool_box);
-
- for (i = 0; paint_buttons[i].data; i++) {
- pixbuf = gdk_pixbuf_new_from_inline(-1, paint_buttons[i].data, FALSE, NULL);
- image = gtk_image_new_from_pixbuf(pixbuf);
- gtk_widget_show(GTK_WIDGET(image));
- paint_buttons[i].button = button = (GtkToggleButton *) gtk_toggle_button_new();
- if (paint_buttons[i].toggle_state) {
- gtk_toggle_button_set_active(button, TRUE);
- brush_size = paint_buttons[i].size;
- }
- g_signal_connect(button, "toggled", G_CALLBACK(paint_button_toggled), (void *)((long)i));
- tooltips = gtk_tooltips_new();
- gtk_tooltips_set_tip(tooltips, GTK_WIDGET(button), paint_buttons[i].tooltip, NULL);
- gtk_container_add (GTK_CONTAINER (button), image);
- gtk_widget_show(GTK_WIDGET(button));
- gtk_box_pack_start(GTK_BOX(tool_box), GTK_WIDGET(button), FALSE, FALSE, 2);
- }
-
- for (i = 0; tool_buttons[i].data; i++) {
- if (i == 0 || i == 2) {
- /* add vertical seperation to hbox */
- separator = gtk_vseparator_new();
- gtk_widget_show(separator);
- gtk_box_pack_start(GTK_BOX(tool_box), separator, FALSE, FALSE, 3);
- }
- pixbuf = gdk_pixbuf_new_from_inline(-1, tool_buttons[i].data, FALSE, NULL);
- image = gtk_image_new_from_pixbuf(pixbuf);
- gtk_widget_show(GTK_WIDGET(image));
- if (tool_buttons[i].toggle) {
- button = (GtkToggleButton *) gtk_toggle_button_new();
- g_signal_connect(button, "toggled", G_CALLBACK(tool_buttons[i].handler), NULL);
- } else {
- button = (GtkToggleButton *) gtk_button_new();
- g_signal_connect(button, "clicked", G_CALLBACK(tool_buttons[i].handler), NULL);
- }
- tool_buttons[i].widget = (GtkWidget *)button;
- tooltips = gtk_tooltips_new();
- gtk_tooltips_set_tip(tooltips, GTK_WIDGET(button), tool_buttons[i].tooltip, NULL);
- if (tool_buttons[i].button)
- *(tool_buttons[i].button) = button;
- gtk_container_add (GTK_CONTAINER (button), image);
- gtk_widget_show(GTK_WIDGET(button));
- gtk_box_pack_start(GTK_BOX(tool_box), GTK_WIDGET(button), FALSE, FALSE, 2);
- }
+ /* add tool_bar to vbox (bottom part of palette box) */
+ tool_bar = gtk_hbox_new(FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), tool_bar, FALSE, FALSE, 2);
+ gtk_widget_show(tool_bar);
+ create_toolbar(tool_bar);
/* add paned view to vbox (middle part of vbox) */
paned = gtk_hpaned_new ();
--- /dev/null
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include "../src/mark.h"
+#ifdef WITH_OPENCV
+#include "../src/opticalflow.h"
+#endif
+#include "main.h"
+#include "menu.h"
+#include "toolbar.h"
+#include "image.h"
+#include "palette.h"
+#include "timeline.h"
+#include "colorize.h"
+#include "brightcontrast.h"
+#include "level.h"
+#include "fill.h"
+#ifdef WITH_OPENCV
+#include "flow.h"
+#endif
+
+/*
+ * tool bar
+ */
+
+extern const guint8 img_size_1[];
+extern const guint8 img_size_3[];
+extern const guint8 img_size_5[];
+extern const guint8 img_size_9[];
+extern const guint8 img_size_11[];
+extern const guint8 img_size_19[];
+extern const guint8 img_fill[];
+extern const guint8 img_move[];
+
+struct paint_buttons {
+ const guint8 *data;
+ GtkToggleButton *button;
+ int toggle_state;
+ int size;
+ int move;
+ int fill;
+ const char *tooltip;
+} paint_buttons[] = {
+ { img_size_1, NULL, FALSE, 1, 0, 0, "Set pen size to 1" },
+ { img_size_3, NULL, TRUE, 2, 0, 0, "Set pen size to 3" },
+ { img_size_5, NULL, FALSE, 3, 0, 0, "Set pen size to 5" },
+ { img_size_9, NULL, FALSE, 5, 0, 0, "Set pen size to 9" },
+ { img_size_11, NULL, FALSE, 6, 0, 0, "Set pen size to 11" },
+ { img_size_19, NULL, FALSE, 10, 0, 0, "Set pen size to 19" },
+ { img_fill, NULL, FALSE, 0, 0, 1, "FILL marked area" },
+ { img_move, NULL, FALSE, 0, 1, 0, "Move marked pixles" },
+ { NULL, NULL, 0, 0, 0, 0, NULL },
+};
+
+void paint_button_toggled(GtkToggleButton *togglebutton, gpointer index)
+{
+ int i;
+
+ if (paint_buttons[(long)index].toggle_state == gtk_toggle_button_get_active(togglebutton)) {
+ return;
+ }
+
+ for (i = 0; paint_buttons[i].button; i++) {
+ if ((long)index == i) {
+ paint_buttons[i].toggle_state = TRUE;
+ gtk_toggle_button_set_active(paint_buttons[i].button, TRUE);
+ brush_size = paint_buttons[i].size;
+ move_mode = paint_buttons[i].move;
+ fill_mode = paint_buttons[i].fill;
+ } else {
+ paint_buttons[i].toggle_state = FALSE;
+ gtk_toggle_button_set_active(paint_buttons[i].button, FALSE);
+ }
+ }
+
+}
+
+void zoomin_button_clicked(GtkButton *button, gpointer index)
+{
+ zoom_in_event(NULL);
+}
+
+void zoomout_button_clicked(GtkButton *button, gpointer index)
+{
+ zoom_out_event(NULL);
+}
+
+void highlight_button_toggled(GtkButton *button, gpointer index)
+{
+ highlight = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
+ set_menu_toggel_by_label(TOGGLE_LABEL_HIGHLIGHT, highlight);
+ draw_image(0, 0, -1, -1);
+}
+
+void preview_button_toggled(GtkButton *button, gpointer index)
+{
+ preview = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
+ set_menu_toggel_by_label(TOGGLE_LABEL_PREVIEW, preview);
+ draw_image(0, 0, -1, -1);
+}
+
+void palette_button_clicked(GtkButton *button, gpointer index)
+{
+ palette_event(NULL);
+}
+
+void bc_button_clicked(GtkButton *button, gpointer index)
+{
+ bc_event(NULL);
+}
+
+void colorize_button_clicked(GtkButton *button, gpointer index)
+{
+ colorize_event(NULL);
+}
+
+void view_colorized_button_toggled(GtkButton *button, gpointer index)
+{
+ if (timeline_frames > 1)
+ rendered = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
+ else
+ rendered = 0;
+ gtk_toggle_button_set_active(show_colorized_button, rendered);
+ set_menu_toggel_by_label(TOGGLE_LABEL_RENDERED, rendered);
+ timeline_select_and_save(timeline_selected, timeline_selected);
+}
+
+#ifdef WITH_OPENCV
+void view_flow_button_toggled(GtkButton *button, gpointer index)
+{
+ if (flow_enable && timeline_frames > 1)
+ flowview = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
+ else
+ flowview = 0;
+ gtk_toggle_button_set_active(show_flow_button, flowview);
+ set_menu_toggel_by_label(TOGGLE_LABEL_FLOWVIEW, flowview);
+ timeline_select_and_save(timeline_selected, timeline_selected);
+}
+#endif
+
+extern const guint8 img_zoomin[];
+extern const guint8 img_zoomout[];
+extern const guint8 img_pal[];
+extern const guint8 img_bc[];
+extern const guint8 img_highlight[];
+extern const guint8 img_preview[];
+extern const guint8 img_eye[];
+extern const guint8 img_col[];
+extern const guint8 img_flow[];
+
+struct tool_buttons {
+ enum toggle_label label;
+ GtkWidget *widget;
+ const guint8 *data;
+ int toggle;
+ void (*handler)(GtkButton *togglebutton, gpointer priv);
+ GtkToggleButton **button;
+ const char *tooltip;
+} tool_buttons[] = {
+ { TOGGLE_LABEL_NONE, NULL, img_zoomin, 0, zoomin_button_clicked, NULL, "Zoom in" },
+ { TOGGLE_LABEL_NONE, NULL, img_zoomout, 0, zoomout_button_clicked, NULL, "Zoom out" },
+ { TOGGLE_LABEL_NONE, NULL, img_pal, 0, palette_button_clicked, NULL, "Palette dialog" },
+ { TOGGLE_LABEL_NONE, NULL, img_bc, 0, bc_button_clicked, NULL, "Brightness+Contrast dialog" },
+ { TOGGLE_LABEL_HIGHLIGHT, NULL, img_highlight, 1, highlight_button_toggled, &show_highlighted_button, "Highlight selected mark color" },
+ { TOGGLE_LABEL_PREVIEW, NULL, img_preview, 1, preview_button_toggled, &show_preview_button, "Show preview of selected mark color" },
+ { TOGGLE_LABEL_RENDERED, NULL, img_eye, 1, view_colorized_button_toggled, &show_colorized_button, "Show result of a rendered sequence" },
+#ifdef WITH_OPENCV
+ { TOGGLE_LABEL_FLOWVIEW, NULL, img_flow, 1, view_flow_button_toggled, &show_flow_button, "Show optical flow" },
+#endif
+ { TOGGLE_LABEL_NONE, NULL, img_col, 0, colorize_button_clicked, NULL, "Colorize current image" },
+ { TOGGLE_LABEL_NONE, NULL, NULL, 0, NULL, NULL, NULL },
+};
+
+void create_toolbar(GtkWidget *tool_bar)
+{
+ int i;
+ GdkPixbuf *pixbuf;
+ GtkWidget *image;
+ GtkToggleButton *button;
+ GtkTooltips *tooltips;
+ GtkWidget *separator;
+
+ for (i = 0; paint_buttons[i].data; i++) {
+ pixbuf = gdk_pixbuf_new_from_inline(-1, paint_buttons[i].data, FALSE, NULL);
+ image = gtk_image_new_from_pixbuf(pixbuf);
+ gtk_widget_show(GTK_WIDGET(image));
+ paint_buttons[i].button = button = (GtkToggleButton *) gtk_toggle_button_new();
+ if (paint_buttons[i].toggle_state) {
+ gtk_toggle_button_set_active(button, TRUE);
+ brush_size = paint_buttons[i].size;
+ }
+ g_signal_connect(button, "toggled", G_CALLBACK(paint_button_toggled), (void *)((long)i));
+ tooltips = gtk_tooltips_new();
+ gtk_tooltips_set_tip(tooltips, GTK_WIDGET(button), paint_buttons[i].tooltip, NULL);
+ gtk_container_add (GTK_CONTAINER (button), image);
+ gtk_widget_show(GTK_WIDGET(button));
+ gtk_box_pack_start(GTK_BOX(tool_bar), GTK_WIDGET(button), FALSE, FALSE, 2);
+ }
+
+ for (i = 0; tool_buttons[i].data; i++) {
+ if (i == 0 || i == 2) {
+ /* add vertical seperation to hbox */
+ separator = gtk_vseparator_new();
+ gtk_widget_show(separator);
+ gtk_box_pack_start(GTK_BOX(tool_bar), separator, FALSE, FALSE, 3);
+ }
+ pixbuf = gdk_pixbuf_new_from_inline(-1, tool_buttons[i].data, FALSE, NULL);
+ image = gtk_image_new_from_pixbuf(pixbuf);
+ gtk_widget_show(GTK_WIDGET(image));
+ if (tool_buttons[i].toggle) {
+ button = (GtkToggleButton *) gtk_toggle_button_new();
+ g_signal_connect(button, "toggled", G_CALLBACK(tool_buttons[i].handler), NULL);
+ } else {
+ button = (GtkToggleButton *) gtk_button_new();
+ g_signal_connect(button, "clicked", G_CALLBACK(tool_buttons[i].handler), NULL);
+ }
+ tool_buttons[i].widget = (GtkWidget *)button;
+ tooltips = gtk_tooltips_new();
+ gtk_tooltips_set_tip(tooltips, GTK_WIDGET(button), tool_buttons[i].tooltip, NULL);
+ if (tool_buttons[i].button)
+ *(tool_buttons[i].button) = button;
+ gtk_container_add (GTK_CONTAINER (button), image);
+ gtk_widget_show(GTK_WIDGET(button));
+ gtk_box_pack_start(GTK_BOX(tool_bar), GTK_WIDGET(button), FALSE, FALSE, 2);
+ }
+}
+
+void set_button_toggel_by_label(enum toggle_label label, gboolean active)
+{
+ int i;
+
+ for (i = 0; tool_buttons[i].data; i++) {
+ if (tool_buttons[i].label == label)
+ gtk_toggle_button_set_active((GtkToggleButton *)tool_buttons[i].widget, active);
+ }
+}
+