applied patch from Joao S. O. Bueno Calligaris which adds a preview for

2007-02-07  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpgradienteditor.[ch]: applied patch from Joao
	S. O. Bueno Calligaris which adds a preview for the color the
	cursor is currently hovering and reduces excess precision when
	displaying color components and gradient positions (bug #400907).


svn path=/trunk/; revision=21858
This commit is contained in:
Michael Natterer 2007-02-07 13:50:08 +00:00 committed by Michael Natterer
parent 6e134e6d1c
commit d6ee118027
3 changed files with 44 additions and 15 deletions

View file

@ -1,3 +1,10 @@
2007-02-07 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpgradienteditor.[ch]: applied patch from Joao
S. O. Bueno Calligaris which adds a preview for the color the
cursor is currently hovering and reduces excess precision when
displaying color components and gradient positions (bug #400907).
2007-02-07 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell-scale.c: don't compare floating

View file

@ -79,9 +79,10 @@
#define GRAD_SCROLLBAR_STEP_SIZE 0.05
#define GRAD_SCROLLBAR_PAGE_SIZE 0.75
#define GRAD_VIEW_WIDTH 128
#define GRAD_VIEW_HEIGHT 96
#define GRAD_CONTROL_HEIGHT 10
#define GRAD_VIEW_WIDTH 128
#define GRAD_VIEW_HEIGHT 96
#define GRAD_CONTROL_HEIGHT 14
#define GRAD_CURRENT_COLOR_WIDTH 64
#define GRAD_MOVE_TIME 150 /* ms between mouse click and detection of movement in gradient control */
@ -294,6 +295,9 @@ gimp_gradient_editor_init (GimpGradientEditor *editor)
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *button;
GimpRGB transp;
gimp_rgba_set (&transp, 0.0, 0.0, 0.0, 0.0);
/* Frame for gradient view and gradient control */
frame = gtk_frame_new (NULL);
@ -383,13 +387,29 @@ gimp_gradient_editor_init (GimpGradientEditor *editor)
gtk_box_pack_start (GTK_BOX (editor), editor->scrollbar, FALSE, FALSE, 0);
gtk_widget_show (editor->scrollbar);
/* Instant update toggle */
/* Box for current color and instant update toggle */
editor->instant_update = TRUE;
hbox = gtk_hbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (editor), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
/* Frame showing current active color */
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
editor->current_color = gimp_color_area_new (&transp,
GIMP_COLOR_AREA_SMALL_CHECKS,
GDK_BUTTON1_MASK |
GDK_BUTTON2_MASK);
gtk_container_add (GTK_CONTAINER (frame), editor->current_color);
gtk_widget_set_size_request (editor->current_color,
GRAD_CURRENT_COLOR_WIDTH, -1);
gtk_widget_show (editor->current_color);
/* Instant update toggle */
button = gtk_check_button_new_with_label (_("Instant update"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
editor->instant_update);
@ -767,7 +787,7 @@ gradient_editor_scrollbar_update (GtkAdjustment *adjustment,
str1 = g_strdup_printf (_("Zoom factor: %d:1"),
editor->zoom_factor);
str2 = g_strdup_printf (_("Displaying [%0.6f, %0.6f]"),
str2 = g_strdup_printf (_("Displaying [%0.4f, %0.4f]"),
adjustment->value,
adjustment->value + adjustment->page_size);
@ -815,7 +835,6 @@ gradient_editor_set_hint (GimpGradientEditor *editor,
gtk_label_set_text (GTK_LABEL (editor->hint_label2), str2);
gtk_label_set_text (GTK_LABEL (editor->hint_label3), str3);
gtk_label_set_text (GTK_LABEL (editor->hint_label4), str4);
}
@ -978,16 +997,18 @@ view_set_hint (GimpGradientEditor *editor,
data_editor->context, NULL,
xpos, FALSE, &rgb);
gimp_color_area_set_color (GIMP_COLOR_AREA (editor->current_color), &rgb);
gimp_rgb_to_hsv (&rgb, &hsv);
str1 = g_strdup_printf (_("Position: %0.6f"), xpos);
str1 = g_strdup_printf (_("Position: %0.4f"), xpos);
str2 = g_strdup_printf (_("RGB (%0.3f, %0.3f, %0.3f)"),
rgb.r, rgb.g, rgb.b);
str3 = g_strdup_printf (_("HSV (%0.3f, %0.3f, %0.3f)"),
hsv.h * 360.0, hsv.s, hsv.v);
str4 = g_strdup_printf (_("Luminance: %0.3f Opacity: %0.3f"),
GIMP_RGB_LUMINANCE (rgb.r, rgb.g, rgb.b), rgb.a);
str3 = g_strdup_printf (_("HSV (%0.1f, %0.1f, %0.1f)"),
hsv.h * 360.0, hsv.s * 100.0, hsv.v * 100.0);
str4 = g_strdup_printf (_("Luminance: %0.1f Opacity: %0.1f"),
GIMP_RGB_LUMINANCE (rgb.r, rgb.g, rgb.b) * 100.0,
rgb.a * 100.0);
gradient_editor_set_hint (editor, str1, str2, str3, str4);
@ -1555,7 +1576,7 @@ control_motion (GimpGradientEditor *editor,
editor->control_sel_r,
seg, pos);
str = g_strdup_printf (_("Handle position: %0.6f"), seg->left);
str = g_strdup_printf (_("Handle position: %0.4f"), seg->left);
break;
case GRAD_DRAG_MIDDLE:
@ -1563,7 +1584,7 @@ control_motion (GimpGradientEditor *editor,
gimp_gradient_segment_set_middle_pos (gradient, seg, pos);
str = g_strdup_printf (_("Handle position: %0.6f"), seg->middle);
str = g_strdup_printf (_("Handle position: %0.4f"), seg->middle);
break;
case GRAD_DRAG_ALL:
@ -1580,7 +1601,7 @@ control_motion (GimpGradientEditor *editor,
editor->control_last_gx += delta;
str = g_strdup_printf (_("Distance: %0.6f"),
str = g_strdup_printf (_("Distance: %0.4f"),
editor->control_last_gx -
editor->control_orig_pos);
break;

View file

@ -52,6 +52,7 @@ struct _GimpGradientEditor
{
GimpDataEditor parent_instance;
GtkWidget *current_color;
GtkWidget *hint_label1;
GtkWidget *hint_label2;
GtkWidget *hint_label3;