Commit 426322f4 authored by Sven Neumann's avatar Sven Neumann
Browse files

More statusbar stuff.


--Sven
parent 1139d57c
Sun Jul 26 23:47:33 MEST 1998 Sven Neumann <sven@gimp.org>
* app/blend.c
* app/crop.c
* app/edit_selection.c
* app/rect_select.c: More statusbar stuff (should be finished now,
but who knows...)
Sat Jul 25 04:11:31 PDT 1998 Jay Cox <jaycox@earthlink.net>
* app/pixel_region.c: optimized pixel_region_[gs]et_row,
......
......@@ -49,6 +49,8 @@
#define M_PI 3.14159265358979323846
#endif /* M_PI */
#define STATUSBAR_SIZE 128
/* the Blend structures */
typedef enum
......@@ -91,6 +93,7 @@ struct _BlendTool
int endx; /* ending x coord */
int endy; /* ending y coord */
guint context_id; /* for the statusbar */
};
typedef struct _BlendOptions BlendOptions;
......@@ -575,6 +578,10 @@ blend_button_press (Tool *tool,
tool->gdisp_ptr = gdisp_ptr;
tool->state = ACTIVE;
/* initialize the statusbar display */
blend_tool->context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), "blend");
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), blend_tool->context_id, "Blend: 0, 0");
/* Start drawing the blend tool */
draw_core_start (blend_tool->core, gdisp->canvas->window, tool);
}
......@@ -584,16 +591,21 @@ blend_button_release (Tool *tool,
GdkEventButton *bevent,
gpointer gdisp_ptr)
{
GDisplay * gdisp;
GImage * gimage;
BlendTool * blend_tool;
Argument *return_vals;
int nreturn_vals;
gimage = ((GDisplay *) gdisp_ptr)->gimage;
gdisp = (GDisplay *) gdisp_ptr;
gimage = gdisp->gimage;
blend_tool = (BlendTool *) tool->private;
gdk_pointer_ungrab (bevent->time);
gdk_flush ();
gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), blend_tool->context_id);
draw_core_stop (blend_tool->core, tool);
tool->state = INACTIVE;
......@@ -637,6 +649,7 @@ blend_motion (Tool *tool,
{
GDisplay * gdisp;
BlendTool * blend_tool;
gchar vector[STATUSBAR_SIZE];
gdisp = (GDisplay *) gdisp_ptr;
blend_tool = (BlendTool *) tool->private;
......@@ -648,6 +661,12 @@ blend_motion (Tool *tool,
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
&blend_tool->endx, &blend_tool->endy, FALSE, 1);
gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), blend_tool->context_id);
g_snprintf (vector, STATUSBAR_SIZE, "Blend: %d, %d",
abs(blend_tool->endx - blend_tool->startx),
abs(blend_tool->endy - blend_tool->starty));
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), blend_tool->context_id, vector);
/* redraw the current tool */
draw_core_resume (blend_tool->core, tool);
}
......
......@@ -49,6 +49,8 @@
#define M_PI 3.14159265358979323846
#endif /* M_PI */
#define STATUSBAR_SIZE 128
/* the Blend structures */
typedef enum
......@@ -91,6 +93,7 @@ struct _BlendTool
int endx; /* ending x coord */
int endy; /* ending y coord */
guint context_id; /* for the statusbar */
};
typedef struct _BlendOptions BlendOptions;
......@@ -575,6 +578,10 @@ blend_button_press (Tool *tool,
tool->gdisp_ptr = gdisp_ptr;
tool->state = ACTIVE;
/* initialize the statusbar display */
blend_tool->context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), "blend");
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), blend_tool->context_id, "Blend: 0, 0");
/* Start drawing the blend tool */
draw_core_start (blend_tool->core, gdisp->canvas->window, tool);
}
......@@ -584,16 +591,21 @@ blend_button_release (Tool *tool,
GdkEventButton *bevent,
gpointer gdisp_ptr)
{
GDisplay * gdisp;
GImage * gimage;
BlendTool * blend_tool;
Argument *return_vals;
int nreturn_vals;
gimage = ((GDisplay *) gdisp_ptr)->gimage;
gdisp = (GDisplay *) gdisp_ptr;
gimage = gdisp->gimage;
blend_tool = (BlendTool *) tool->private;
gdk_pointer_ungrab (bevent->time);
gdk_flush ();
gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), blend_tool->context_id);
draw_core_stop (blend_tool->core, tool);
tool->state = INACTIVE;
......@@ -637,6 +649,7 @@ blend_motion (Tool *tool,
{
GDisplay * gdisp;
BlendTool * blend_tool;
gchar vector[STATUSBAR_SIZE];
gdisp = (GDisplay *) gdisp_ptr;
blend_tool = (BlendTool *) tool->private;
......@@ -648,6 +661,12 @@ blend_motion (Tool *tool,
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
&blend_tool->endx, &blend_tool->endy, FALSE, 1);
gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), blend_tool->context_id);
g_snprintf (vector, STATUSBAR_SIZE, "Blend: %d, %d",
abs(blend_tool->endx - blend_tool->startx),
abs(blend_tool->endy - blend_tool->starty));
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), blend_tool->context_id, vector);
/* redraw the current tool */
draw_core_resume (blend_tool->core, tool);
}
......
......@@ -29,6 +29,8 @@
#include "info_dialog.h"
#include "undo.h"
#define STATUSBAR_SIZE 128
typedef struct _crop Crop;
struct _crop
......@@ -50,6 +52,7 @@ struct _crop
int tx2, ty2; /* */
int function; /* moving or resizing */
guint context_id; /* for the statusbar */
};
/* possible crop functions */
......@@ -186,16 +189,14 @@ crop_button_release (Tool *tool,
gdk_pointer_ungrab (bevent->time);
gdk_flush ();
gtk_statusbar_pop (GTK_STATUSBAR(gdisp->statusbar), crop->context_id);
if (! (bevent->state & GDK_BUTTON3_MASK))
{
if (crop->function == CROPPING)
crop_image (gdisp->gimage, crop->tx1, crop->ty1, crop->tx2, crop->ty2);
else
{
/* if the crop information dialog doesn't yet exist, create the bugger */
if (! crop_info)
crop_info_create (tool);
crop_info_update (tool);
return;
}
......@@ -264,6 +265,7 @@ crop_motion (Tool *tool,
int x1, y1, x2, y2;
int curx, cury;
int inc_x, inc_y;
gchar size[STATUSBAR_SIZE];
crop = (Crop *) tool->private;
gdisp = (GDisplay *) gdisp_ptr;
......@@ -338,6 +340,16 @@ crop_motion (Tool *tool,
/* recalculate the coordinates for crop_draw based on the new values */
crop_recalc (tool, crop);
if (crop->function == CREATING ||
crop->function == RESIZING_LEFT || crop->function == RESIZING_RIGHT)
{
gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), crop->context_id);
g_snprintf (size, STATUSBAR_SIZE, "Crop: %d x %d",
(crop->tx2 - crop->tx1), (crop->ty2 - crop->ty1));
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), crop->context_id, size);
}
draw_core_resume (crop->core, tool);
}
......@@ -677,6 +689,14 @@ crop_start (Tool *tool,
gdisp = (GDisplay *) tool->gdisp_ptr;
crop_recalc (tool, crop);
/* if the crop information dialog doesn't yet exist, create the bugger */
if (! crop_info)
crop_info_create (tool);
/* initialize the statusbar display */
crop->context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), "crop");
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), crop->context_id, "Crop: 0 x 0");
draw_core_start (crop->core, gdisp->canvas->window, tool);
}
......@@ -712,7 +732,7 @@ static void
crop_info_update (Tool *tool)
{
Crop * crop;
crop = (Crop *) tool->private;
sprintf (orig_x_buf, "%d", crop->tx1);
......
......@@ -30,6 +30,7 @@
#define EDIT_SELECT_SCROLL_LOCK 0
#define ARROW_VELOCITY 25
#define STATUSBAR_SIZE 128
typedef struct _edit_selection EditSelection;
......@@ -97,7 +98,6 @@ init_edit_selection (Tool *tool,
{
GDisplay *gdisp;
Layer *layer;
gchar *offset;
int x, y;
gdisp = (GDisplay *) gdisp_ptr;
......@@ -148,11 +148,8 @@ init_edit_selection (Tool *tool,
selection_pause (gdisp->select);
/* initialize the statusbar display */
edit_select.context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar),
"edit_select");
offset = g_new (gchar, 11); /* strlen("Move: 0, 0") */
edit_select.context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), "edit_select");
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), edit_select.context_id, "Move: 0, 0");
g_free (offset);
/* Create and start the selection core */
edit_select.core = draw_core_new (edit_selection_draw);
......@@ -285,7 +282,7 @@ edit_selection_motion (Tool *tool,
gpointer gdisp_ptr)
{
GDisplay * gdisp;
gchar *offset;
gchar offset[STATUSBAR_SIZE];
if (tool->state != ACTIVE)
return;
......@@ -297,11 +294,9 @@ edit_selection_motion (Tool *tool,
edit_selection_snap (gdisp, mevent->x, mevent->y);
gtk_statusbar_pop (GTK_STATUSBAR(gdisp->statusbar), edit_select.context_id);
offset = g_new (gchar, 22); /* strlen("Move: x ") + 2*6 */
g_snprintf (offset, 22, "Move: %d, %d",
g_snprintf (offset, STATUSBAR_SIZE, "Move: %d, %d",
(edit_select.x - edit_select.origx), (edit_select.y - edit_select.origy));
gtk_statusbar_push (GTK_STATUSBAR(gdisp->statusbar), edit_select.context_id, offset);
g_free (offset);
draw_core_resume (edit_select.core, tool);
}
......
......@@ -30,6 +30,8 @@
#define FIXED_ENTRY_SIZE 50
#define FIXED_ENTRY_MAX_CHARS 10
#define STATUSBAR_SIZE 128
extern SelectionOptions *ellipse_options;
static SelectionOptions *rect_options = NULL;
......@@ -314,7 +316,7 @@ rect_select_button_press (Tool *tool,
{
GDisplay * gdisp;
RectSelect * rect_sel;
gchar *select_mode;
gchar select_mode[STATUSBAR_SIZE];
int x, y;
gdisp = (GDisplay *) gdisp_ptr;
......@@ -378,27 +380,26 @@ rect_select_button_press (Tool *tool,
rect_sel->op = REPLACE;
}
/* initialize the statusbar display */
rect_sel->context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), "selection");
select_mode = g_new (gchar, 21); /* strlen("Selection: INTERSECT") */
switch (rect_sel->op)
{
case ADD:
g_snprintf (select_mode, 21, "Selection: ADD");
g_snprintf (select_mode, STATUSBAR_SIZE, "Selection: ADD");
break;
case SUB:
g_snprintf (select_mode, 21, "Selection: SUBTRACT");
g_snprintf (select_mode, STATUSBAR_SIZE, "Selection: SUBTRACT");
break;
case INTERSECT:
g_snprintf (select_mode, 21, "Selection: INTERSECT");
g_snprintf (select_mode, STATUSBAR_SIZE, "Selection: INTERSECT");
break;
case REPLACE:
g_snprintf (select_mode, 21, "Selection: REPLACE");
g_snprintf (select_mode, STATUSBAR_SIZE, "Selection: REPLACE");
break;
default:
break;
}
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), rect_sel->context_id, select_mode);
g_free (select_mode);
draw_core_start (rect_sel->core, gdisp->canvas->window, tool);
}
......@@ -481,7 +482,7 @@ rect_select_motion (Tool *tool,
{
RectSelect * rect_sel;
GDisplay * gdisp;
gchar *size;
gchar size[STATUSBAR_SIZE];
int ox, oy;
int x, y;
int w, h, s;
......@@ -591,10 +592,8 @@ rect_select_motion (Tool *tool,
}
gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), rect_sel->context_id);
size = g_new (gchar, 25); /* strlen("Selection: x ") + 2*5 */
g_snprintf (size, 25, "Selection: %d x %d", abs(rect_sel->w), abs(rect_sel->h));
g_snprintf (size, STATUSBAR_SIZE, "Selection: %d x %d", abs(rect_sel->w), abs(rect_sel->h));
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), rect_sel->context_id, size);
g_free (size);
draw_core_resume (rect_sel->core, tool);
}
......
......@@ -49,6 +49,8 @@
#define M_PI 3.14159265358979323846
#endif /* M_PI */
#define STATUSBAR_SIZE 128
/* the Blend structures */
typedef enum
......@@ -91,6 +93,7 @@ struct _BlendTool
int endx; /* ending x coord */
int endy; /* ending y coord */
guint context_id; /* for the statusbar */
};
typedef struct _BlendOptions BlendOptions;
......@@ -575,6 +578,10 @@ blend_button_press (Tool *tool,
tool->gdisp_ptr = gdisp_ptr;
tool->state = ACTIVE;
/* initialize the statusbar display */
blend_tool->context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), "blend");
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), blend_tool->context_id, "Blend: 0, 0");
/* Start drawing the blend tool */
draw_core_start (blend_tool->core, gdisp->canvas->window, tool);
}
......@@ -584,16 +591,21 @@ blend_button_release (Tool *tool,
GdkEventButton *bevent,
gpointer gdisp_ptr)
{
GDisplay * gdisp;
GImage * gimage;
BlendTool * blend_tool;
Argument *return_vals;
int nreturn_vals;
gimage = ((GDisplay *) gdisp_ptr)->gimage;
gdisp = (GDisplay *) gdisp_ptr;
gimage = gdisp->gimage;
blend_tool = (BlendTool *) tool->private;
gdk_pointer_ungrab (bevent->time);
gdk_flush ();
gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), blend_tool->context_id);
draw_core_stop (blend_tool->core, tool);
tool->state = INACTIVE;
......@@ -637,6 +649,7 @@ blend_motion (Tool *tool,
{
GDisplay * gdisp;
BlendTool * blend_tool;
gchar vector[STATUSBAR_SIZE];
gdisp = (GDisplay *) gdisp_ptr;
blend_tool = (BlendTool *) tool->private;
......@@ -648,6 +661,12 @@ blend_motion (Tool *tool,
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
&blend_tool->endx, &blend_tool->endy, FALSE, 1);
gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), blend_tool->context_id);
g_snprintf (vector, STATUSBAR_SIZE, "Blend: %d, %d",
abs(blend_tool->endx - blend_tool->startx),
abs(blend_tool->endy - blend_tool->starty));
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), blend_tool->context_id, vector);
/* redraw the current tool */
draw_core_resume (blend_tool->core, tool);
}
......
......@@ -29,6 +29,8 @@
#include "info_dialog.h"
#include "undo.h"
#define STATUSBAR_SIZE 128
typedef struct _crop Crop;
struct _crop
......@@ -50,6 +52,7 @@ struct _crop
int tx2, ty2; /* */
int function; /* moving or resizing */
guint context_id; /* for the statusbar */
};
/* possible crop functions */
......@@ -186,16 +189,14 @@ crop_button_release (Tool *tool,
gdk_pointer_ungrab (bevent->time);
gdk_flush ();
gtk_statusbar_pop (GTK_STATUSBAR(gdisp->statusbar), crop->context_id);
if (! (bevent->state & GDK_BUTTON3_MASK))
{
if (crop->function == CROPPING)
crop_image (gdisp->gimage, crop->tx1, crop->ty1, crop->tx2, crop->ty2);
else
{
/* if the crop information dialog doesn't yet exist, create the bugger */
if (! crop_info)
crop_info_create (tool);
crop_info_update (tool);
return;
}
......@@ -264,6 +265,7 @@ crop_motion (Tool *tool,
int x1, y1, x2, y2;
int curx, cury;
int inc_x, inc_y;
gchar size[STATUSBAR_SIZE];
crop = (Crop *) tool->private;
gdisp = (GDisplay *) gdisp_ptr;
......@@ -338,6 +340,16 @@ crop_motion (Tool *tool,
/* recalculate the coordinates for crop_draw based on the new values */
crop_recalc (tool, crop);
if (crop->function == CREATING ||
crop->function == RESIZING_LEFT || crop->function == RESIZING_RIGHT)
{
gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), crop->context_id);
g_snprintf (size, STATUSBAR_SIZE, "Crop: %d x %d",
(crop->tx2 - crop->tx1), (crop->ty2 - crop->ty1));
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), crop->context_id, size);
}
draw_core_resume (crop->core, tool);
}
......@@ -677,6 +689,14 @@ crop_start (Tool *tool,
gdisp = (GDisplay *) tool->gdisp_ptr;
crop_recalc (tool, crop);
/* if the crop information dialog doesn't yet exist, create the bugger */
if (! crop_info)
crop_info_create (tool);
/* initialize the statusbar display */
crop->context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), "crop");
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), crop->context_id, "Crop: 0 x 0");
draw_core_start (crop->core, gdisp->canvas->window, tool);
}
......@@ -712,7 +732,7 @@ static void
crop_info_update (Tool *tool)
{
Crop * crop;
crop = (Crop *) tool->private;
sprintf (orig_x_buf, "%d", crop->tx1);
......
......@@ -30,6 +30,7 @@
#define EDIT_SELECT_SCROLL_LOCK 0
#define ARROW_VELOCITY 25
#define STATUSBAR_SIZE 128
typedef struct _edit_selection EditSelection;
......@@ -97,7 +98,6 @@ init_edit_selection (Tool *tool,
{
GDisplay *gdisp;
Layer *layer;
gchar *offset;
int x, y;
gdisp = (GDisplay *) gdisp_ptr;
......@@ -148,11 +148,8 @@ init_edit_selection (Tool *tool,
selection_pause (gdisp->select);
/* initialize the statusbar display */
edit_select.context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar),
"edit_select");
offset = g_new (gchar, 11); /* strlen("Move: 0, 0") */
edit_select.context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), "edit_select");
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), edit_select.context_id, "Move: 0, 0");
g_free (offset);
/* Create and start the selection core */
edit_select.core = draw_core_new (edit_selection_draw);
......@@ -285,7 +282,7 @@ edit_selection_motion (Tool *tool,
gpointer gdisp_ptr)
{
GDisplay * gdisp;
gchar *offset;
gchar offset[STATUSBAR_SIZE];
if (tool->state != ACTIVE)
return;
......@@ -297,11 +294,9 @@ edit_selection_motion (Tool *tool,
edit_selection_snap (gdisp, mevent->x, mevent->y);
gtk_statusbar_pop (GTK_STATUSBAR(gdisp->statusbar), edit_select.context_id);
offset = g_new (gchar, 22); /* strlen("Move: x ") + 2*6 */
g_snprintf (offset, 22, "Move: %d, %d",
g_snprintf (offset, STATUSBAR_SIZE, "Move: %d, %d",
(edit_select.x - edit_select.origx), (edit_select.y - edit_select.origy));
gtk_statusbar_push (GTK_STATUSBAR(gdisp->statusbar), edit_select.context_id, offset);
g_free (offset);
draw_core_resume (edit_select.core, tool);
}
......
......@@ -49,6 +49,8 @@
#define M_PI 3.14159265358979323846
#endif /* M_PI */
#define STATUSBAR_SIZE 128
/* the Blend structures */
typedef enum
......@@ -91,6 +93,7 @@ struct _BlendTool
int endx; /* ending x coord */
int endy; /* ending y coord */
guint context_id; /* for the statusbar */
};
typedef struct _BlendOptions BlendOptions;
......@@ -575,6 +578,10 @@ blend_button_press (Tool *tool,
tool->gdisp_ptr = gdisp_ptr;
tool->state = ACTIVE;
/* initialize the statusbar display */
blend_tool->context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), "blend");
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), blend_tool->context_id, "Blend: 0, 0");
/* Start drawing the blend tool */
draw_core_start (blend_tool->core, gdisp->canvas->window, tool);
}
......@@ -584,16 +591,21 @@ blend_button_release (Tool *tool,
GdkEventButton *bevent,
gpointer gdisp_ptr)
{
GDisplay * gdisp;
GImage * gimage;
BlendTool * blend_tool;
Argument *return_vals;
int nreturn_vals;
gimage = ((GDisplay *) gdisp_ptr)->gimage;
gdisp = (GDisplay *) gdisp_ptr;
gimage = gdisp->gimage;
blend_tool = (BlendTool *) tool->private;
gdk_pointer_ungrab (bevent->time);
gdk_flush ();
gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), blend_tool->context_id);
draw_core_stop (blend_tool->core, tool);
tool->state = INACTIVE;
......@@ -637,6 +649,7 @@ blend_motion (Tool *tool,
{
GDisplay * gdisp;
BlendTool * blend_tool;
gchar vector[STATUSBAR_SIZE];
gdisp = (GDisplay *) gdisp_ptr;
blend_tool = (BlendTool *) tool->private;
......@@ -648,6 +661,12 @@ blend_motion (Tool *tool,
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
&blend_tool->endx, &blend_tool->endy, FALSE, 1);
gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), blend_tool->context_id);
g_snprintf (vector, STATUSBAR_SIZE, "Blend: %d, %d",
abs(blend_tool->endx - blend_tool->startx),
abs(blend_tool->endy - blend_tool->starty));
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), blend_tool->context_id, vector);
/* redraw the current tool */
draw_core_resume (blend_tool->core, tool);
}
......
......@@ -29,6 +29,8 @@
#include "info_dialog.h"
#include "undo.h"
#define STATUSBAR_SIZE 128