1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-11-25 12:42:49 +02:00

Added tooltips to all icons acting as buttons.

git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5767 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
werner 2010-01-01 14:59:17 +00:00
parent 40028ed18f
commit bdd6e95521
5 changed files with 70 additions and 36 deletions

2
TODO
View File

@ -27,7 +27,7 @@ Style and usability:
- when changing the part, we should automatically switch to a configuration - when changing the part, we should automatically switch to a configuration
that generates any of its (non-global) elements that generates any of its (non-global) elements
- add zoom controls to top toolbar - add zoom controls to top toolbar
- add tooltips - add tooltips (in progress)
Bugs: Bugs:
- default silk width has no business being hard-coded in obj.c - default silk width has no business being hard-coded in obj.c

36
gui.c
View File

@ -1,8 +1,8 @@
/* /*
* gui.c - Editor GUI core * gui.c - Editor GUI core
* *
* Written 2009 by Werner Almesberger * Written 2009, 2010 by Werner Almesberger
* Copyright 2009 by Werner Almesberger * Copyright 2009, 2010 by Werner Almesberger
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -163,19 +163,27 @@ static void make_tool_bar(GtkWidget *hbox, GdkDrawable *drawable)
//gtk_box_pack_end(GTK_BOX(hbox), bar, FALSE, FALSE, 0); //gtk_box_pack_end(GTK_BOX(hbox), bar, FALSE, FALSE, 0);
gtk_toolbar_set_style(GTK_TOOLBAR(bar), GTK_TOOLBAR_ICONS); gtk_toolbar_set_style(GTK_TOOLBAR(bar), GTK_TOOLBAR_ICONS);
ev_all = tool_button(bar, drawable, NULL, toggle_all, NULL); ev_all = tool_button(bar, drawable, NULL, NULL, toggle_all, NULL);
ev_stuff = tool_button(bar, drawable, NULL, toggle_stuff, NULL); ev_stuff = tool_button(bar, drawable, NULL, NULL, toggle_stuff, NULL);
ev_meas = tool_button(bar, drawable, NULL, toggle_meas, NULL); ev_meas = tool_button(bar, drawable, NULL, NULL, toggle_meas, NULL);
ev_bright = tool_button(bar, drawable, NULL, toggle_bright, NULL); ev_bright = tool_button(bar, drawable, NULL, NULL, toggle_bright, NULL);
stuff_image[0] = gtk_widget_ref(make_image(drawable, xpm_stuff_off)); stuff_image[0] = gtk_widget_ref(make_image(drawable, xpm_stuff_off,
stuff_image[1] = gtk_widget_ref(make_image(drawable, xpm_stuff)); "Show vectors and frame references (disabled)"));
meas_image[0] = gtk_widget_ref(make_image(drawable, xpm_meas_off)); stuff_image[1] = gtk_widget_ref(make_image(drawable, xpm_stuff,
meas_image[1] = gtk_widget_ref(make_image(drawable, xpm_meas)); "Show vectors and frame references (enabled)"));
all_image[0] = gtk_widget_ref(make_image(drawable, xpm_all_off)); meas_image[0] = gtk_widget_ref(make_image(drawable, xpm_meas_off,
all_image[1] = gtk_widget_ref(make_image(drawable, xpm_all)); "Show measurements (disabled)"));
bright_image[0] = gtk_widget_ref(make_image(drawable, xpm_bright_off)); meas_image[1] = gtk_widget_ref(make_image(drawable, xpm_meas,
bright_image[1] = gtk_widget_ref(make_image(drawable, xpm_bright)); "Show measurements (enabled)"));
all_image[0] = gtk_widget_ref(make_image(drawable, xpm_all_off,
"Show all frames (currently showing only the active frame)"));
all_image[1] = gtk_widget_ref(make_image(drawable, xpm_all,
"Show all frames (enabled)"));
bright_image[0] = gtk_widget_ref(make_image(drawable, xpm_bright_off,
"Highlight elements (disabled)"));
bright_image[1] = gtk_widget_ref(make_image(drawable, xpm_bright,
"Highlight elements (enabled)"));
set_image(ev_stuff, stuff_image[show_stuff]); set_image(ev_stuff, stuff_image[show_stuff]);
set_image(ev_meas, meas_image[show_meas]); set_image(ev_meas, meas_image[show_meas]);

View File

@ -1,8 +1,8 @@
/* /*
* gui_tool.c - GUI, tool bar * gui_tool.c - GUI, tool bar
* *
* Written 2009 by Werner Almesberger * Written 2009, 2010 by Werner Almesberger
* Copyright 2009 by Werner Almesberger * Copyright 2009, 2010 by Werner Almesberger
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -1030,7 +1030,7 @@ GtkWidget *get_icon_by_inst(const struct inst *inst)
default: default:
abort(); abort();
} }
return make_transparent_image(DA, image); return make_transparent_image(DA, image, NULL);
} }
@ -1097,41 +1097,57 @@ GtkWidget *gui_setup_tools(GdkDrawable *drawable)
GTK_ORIENTATION_VERTICAL); GTK_ORIENTATION_VERTICAL);
ev_point = tool_button(bar, drawable, xpm_point, ev_point = tool_button(bar, drawable, xpm_point,
"Select and move items",
tool_button_press_event, NULL); tool_button_press_event, NULL);
ev_delete = tool_button(bar, drawable, NULL, ev_delete = tool_button(bar, drawable, NULL, NULL,
tool_button_press_event, &delete_ops); tool_button_press_event, &delete_ops);
tool_separator(bar); tool_separator(bar);
tool_button(bar, drawable, xpm_vec, tool_button(bar, drawable, xpm_vec,
"Add a vector",
tool_button_press_event, &vec_ops); tool_button_press_event, &vec_ops);
ev_frame = tool_button(bar, drawable, NULL, ev_frame = tool_button(bar, drawable, NULL, NULL,
tool_button_press_event, &frame_ops); tool_button_press_event, &frame_ops);
tool_button(bar, drawable, xpm_pad, tool_button(bar, drawable, xpm_pad,
"Add a rectangular pad",
tool_button_press_event, &pad_ops); tool_button_press_event, &pad_ops);
tool_button(bar, drawable, xpm_rpad, tool_button(bar, drawable, xpm_rpad,
"Add a rounded pad",
tool_button_press_event, &rpad_ops); tool_button_press_event, &rpad_ops);
tool_button(bar, drawable, xpm_line, tool_button(bar, drawable, xpm_line,
"Add a silk screen line",
tool_button_press_event, &line_ops); tool_button_press_event, &line_ops);
tool_button(bar, drawable, xpm_rect, tool_button(bar, drawable, xpm_rect,
"Add a silk screen rectangle",
tool_button_press_event, &rect_ops); tool_button_press_event, &rect_ops);
tool_button(bar, drawable, xpm_circ, tool_button(bar, drawable, xpm_circ,
"Add a silk screen circle or arc",
tool_button_press_event, &circ_ops); tool_button_press_event, &circ_ops);
tool_separator(bar); tool_separator(bar);
tool_button(bar, drawable, xpm_meas, tool_button(bar, drawable, xpm_meas,
"Add a measurement",
tool_button_press_event, &tool_meas_ops); tool_button_press_event, &tool_meas_ops);
tool_button(bar, drawable, xpm_meas_x, tool_button(bar, drawable, xpm_meas_x,
"Add a horizontal measurement",
tool_button_press_event, &tool_meas_ops_x); tool_button_press_event, &tool_meas_ops_x);
tool_button(bar, drawable, xpm_meas_y, tool_button(bar, drawable, xpm_meas_y,
"Add a vertical measurement",
tool_button_press_event, &tool_meas_ops_y); tool_button_press_event, &tool_meas_ops_y);
frame_image = gtk_widget_ref(make_image(drawable, xpm_frame)); frame_image = gtk_widget_ref(make_image(drawable, xpm_frame,
"Step 1: select the current frame for insertion"));
frame_image_locked = frame_image_locked =
gtk_widget_ref(make_image(drawable, xpm_frame_locked)); gtk_widget_ref(make_image(drawable, xpm_frame_locked,
"Step 2: select the frame into which to insert"));
frame_image_ready = frame_image_ready =
gtk_widget_ref(make_image(drawable, xpm_frame_ready)); gtk_widget_ref(make_image(drawable, xpm_frame_ready,
"Final step: add the frame reference to an anchor point "
"(vector or origin)"));
set_frame_image(frame_image); set_frame_image(frame_image);
delete_image[0] = gtk_widget_ref(make_image(drawable, xpm_delete_off)); delete_image[0] = gtk_widget_ref(make_image(drawable, xpm_delete_off,
delete_image[1] = gtk_widget_ref(make_image(drawable, xpm_delete)); NULL));
delete_image[1] = gtk_widget_ref(make_image(drawable, xpm_delete,
"Delete the selected item"));
set_image(ev_delete, delete_image[0]); set_image(ev_delete, delete_image[0]);
tool_reset(); tool_reset();

View File

@ -1,8 +1,8 @@
/* /*
* gui_util.c - GUI helper functions * gui_util.c - GUI helper functions
* *
* Written 2009 by Werner Almesberger * Written 2009, 2010 by Werner Almesberger
* Copyright 2009 by Werner Almesberger * Copyright 2009, 2010 by Werner Almesberger
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -172,7 +172,7 @@ void label_in_box_bg(GtkWidget *label, const char *color)
/* ----- generate a tool button with an XPM image -------------------------- */ /* ----- generate a tool button with an XPM image -------------------------- */
GtkWidget *make_image(GdkDrawable *drawable, char **xpm) GtkWidget *make_image(GdkDrawable *drawable, char **xpm, const char *tooltip)
{ {
GdkPixmap *pixmap; GdkPixmap *pixmap;
GtkWidget *image; GtkWidget *image;
@ -181,11 +181,14 @@ GtkWidget *make_image(GdkDrawable *drawable, char **xpm)
pixmap = gdk_pixmap_create_from_xpm_d(drawable, NULL, &white, xpm); pixmap = gdk_pixmap_create_from_xpm_d(drawable, NULL, &white, xpm);
image = gtk_image_new_from_pixmap(pixmap, NULL); image = gtk_image_new_from_pixmap(pixmap, NULL);
gtk_misc_set_padding(GTK_MISC(image), 1, 1); gtk_misc_set_padding(GTK_MISC(image), 1, 1);
if (tooltip)
gtk_widget_set_tooltip_markup(image, tooltip);
return image; return image;
} }
GtkWidget *make_transparent_image(GdkDrawable *drawable, char **xpm) GtkWidget *make_transparent_image(GdkDrawable *drawable, char **xpm,
const char *tooltip)
{ {
GdkPixmap *pixmap; GdkPixmap *pixmap;
GdkBitmap *mask; GdkBitmap *mask;
@ -194,6 +197,8 @@ GtkWidget *make_transparent_image(GdkDrawable *drawable, char **xpm)
pixmap = gdk_pixmap_create_from_xpm_d(drawable, &mask, NULL, xpm); pixmap = gdk_pixmap_create_from_xpm_d(drawable, &mask, NULL, xpm);
image = gtk_image_new_from_pixmap(pixmap, mask); image = gtk_image_new_from_pixmap(pixmap, mask);
gtk_misc_set_padding(GTK_MISC(image), 1, 1); gtk_misc_set_padding(GTK_MISC(image), 1, 1);
if (tooltip)
gtk_widget_set_tooltip_markup(image, tooltip);
return image; return image;
} }
@ -218,7 +223,8 @@ void set_image(GtkWidget *widget, GtkWidget *image)
} }
GtkWidget *tool_button(GtkWidget *bar, GdkDrawable *drawable, char **xpm, GtkWidget *tool_button(GtkWidget *bar, GdkDrawable *drawable,
char **xpm, const char *tooltip,
gboolean (*cb)(GtkWidget *widget, GdkEventButton *event, gpointer data), gboolean (*cb)(GtkWidget *widget, GdkEventButton *event, gpointer data),
gpointer data) gpointer data)
{ {
@ -233,7 +239,7 @@ GtkWidget *tool_button(GtkWidget *bar, GdkDrawable *drawable, char **xpm,
evbox = gtk_event_box_new(); evbox = gtk_event_box_new();
if (xpm) { if (xpm) {
image = make_image(drawable, xpm); image = make_image(drawable, xpm, tooltip);
gtk_container_add(GTK_CONTAINER(evbox), image); gtk_container_add(GTK_CONTAINER(evbox), image);
} }
g_signal_connect(G_OBJECT(evbox), "button_press_event", g_signal_connect(G_OBJECT(evbox), "button_press_event",

View File

@ -1,8 +1,8 @@
/* /*
* gui_util.h - GUI helper functions * gui_util.h - GUI helper functions
* *
* Written 2009 by Werner Almesberger * Written 2009, 2010 by Werner Almesberger
* Copyright 2009 by Werner Almesberger * Copyright 2009, 2010 by Werner Almesberger
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -59,10 +59,14 @@ void label_in_box_bg(GtkWidget *box, const char *color);
void vacate_widget(GtkWidget *widget); void vacate_widget(GtkWidget *widget);
GtkWidget *make_image(GdkDrawable *drawable, char **xpm); /* tooltips are optional (use NULL for none) */
GtkWidget *make_transparent_image(GdkDrawable *drawable, char **xpm);
GtkWidget *make_image(GdkDrawable *drawable, char **xpm, const char *tooltip);
GtkWidget *make_transparent_image(GdkDrawable *drawable, char **xpm,
const char *tooltip);
void set_image(GtkWidget *widget, GtkWidget *image); void set_image(GtkWidget *widget, GtkWidget *image);
GtkWidget *tool_button(GtkWidget *bar, GdkDrawable *drawable, char **xpm, GtkWidget *tool_button(GtkWidget *bar, GdkDrawable *drawable,
char **xpm, const char *tooltip,
gboolean (*cb)(GtkWidget *widget, GdkEventButton *event, gpointer data), gboolean (*cb)(GtkWidget *widget, GdkEventButton *event, gpointer data),
gpointer data); gpointer data);