Commit bfe203c2 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

removed all drawing functions. The file was still too large.

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

	* app/display/gimpdisplayshell.[ch]: removed all drawing functions.
	The file was still too large.

	* app/display/Makefile.am
	* app/display/gimpdisplayshell-draw.[ch]: new files containing
	the drawing functions.

	* app/display/gimpdisplayshell-callbacks.c
	* app/display/gimpdisplayshell-handlers.c
	* app/tools/gimpmovetool.c: changed #includes accordingly.

	* app/display/gimpdisplay-handlers.c
	(gimp_display_size_changed_handler): added some #if 0'ed code I'm
	not sure about. Actually, some of the handlers in this file could
	need the same code, so it could be abstracted as
	gimp_display_stop_draw() or something. Please have a look.
parent f05b2aac
2004-02-07 Michael Natterer <mitch@gimp.org>
* app/display/gimpdisplayshell.[ch]: removed all drawing functions.
The file was still too large.
* app/display/Makefile.am
* app/display/gimpdisplayshell-draw.[ch]: new files containing
the drawing functions.
* app/display/gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell-handlers.c
* app/tools/gimpmovetool.c: changed #includes accordingly.
* app/display/gimpdisplay-handlers.c
(gimp_display_size_changed_handler): added some #if 0'ed code I'm
not sure about. Actually, some of the handlers in this file could
need the same code, so it could be abstracted as
gimp_display_stop_draw() or something. Please have a look.
2004-02-06 Sven Neumann <sven@gimp.org>
 
* libgimpwidgets/gimpcolorselect.c: let the color selector widget
expand. Removes the ugly empty spaces and improves the color
selection experience ;)
2004-02-05 Michael Natterer <mitch@gimp.org>
 
* app/display/gimpdisplayshell.c (gimp_display_shell_mask_bounds):
......@@ -38,6 +38,8 @@ libappdisplay_a_sources = \
gimpdisplayshell-cursor.h \
gimpdisplayshell-dnd.c \
gimpdisplayshell-dnd.h \
gimpdisplayshell-draw.c \
gimpdisplayshell-draw.h \
gimpdisplayshell-handlers.c \
gimpdisplayshell-handlers.h \
gimpdisplayshell-filter.c \
......
......@@ -173,6 +173,22 @@ static void
gimp_display_size_changed_handler (GimpImage *gimage,
GimpDisplay *gdisp)
{
#if 0
/* stop rendering and free all update area lists because
* their coordinates have been invalidated by the resize
*/
if (gdisp->idle_render.idle_id)
{
g_source_remove (gdisp->idle_render.idle_id);
gdisp->idle_render.idle_id = 0;
}
gimp_display_area_list_free (gdisp->update_areas);
gimp_display_area_list_free (gdisp->idle_render.update_areas);
gdisp->update_areas = NULL;
gdisp->idle_render.update_areas = NULL;
#endif
gimp_display_add_update_area (gdisp,
0, 0,
gdisp->gimage->width,
......
......@@ -57,6 +57,7 @@
#include "gimpdisplayshell-appearance.h"
#include "gimpdisplayshell-callbacks.h"
#include "gimpdisplayshell-cursor.h"
#include "gimpdisplayshell-draw.h"
#include "gimpdisplayshell-layer-select.h"
#include "gimpdisplayshell-render.h"
#include "gimpdisplayshell-scale.h"
......
This diff is collapsed.
......@@ -16,224 +16,24 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_DISPLAY_SHELL_H__
#define __GIMP_DISPLAY_SHELL_H__
#include <gtk/gtkwindow.h>
/* FIXME: remove all gui/ stuff */
#include "gui/gui-types.h"
/* finding the effective screen resolution (double) */
#define SCREEN_XRES(s) (s->dot_for_dot ? \
s->gdisp->gimage->xresolution : s->monitor_xres)
#define SCREEN_YRES(s) (s->dot_for_dot ? \
s->gdisp->gimage->yresolution : s->monitor_yres)
/* calculate scale factors (double) */
#define SCALEFACTOR_X(s) (s->scale * SCREEN_XRES(s) / \
s->gdisp->gimage->xresolution)
#define SCALEFACTOR_Y(s) (s->scale * SCREEN_YRES(s) / \
s->gdisp->gimage->yresolution)
/* scale values */
#define SCALEX(s,x) ((gint) (x * SCALEFACTOR_X(s)))
#define SCALEY(s,y) ((gint) (y * SCALEFACTOR_Y(s)))
/* unscale values */
#define UNSCALEX(s,x) ((gint) (x / SCALEFACTOR_X(s)))
#define UNSCALEY(s,y) ((gint) (y / SCALEFACTOR_Y(s)))
/* (and float-returning versions) */
#define FUNSCALEX(s,x) (x / SCALEFACTOR_X(s))
#define FUNSCALEY(s,y) (y / SCALEFACTOR_Y(s))
#define GIMP_TYPE_DISPLAY_SHELL (gimp_display_shell_get_type ())
#define GIMP_DISPLAY_SHELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DISPLAY_SHELL, GimpDisplayShell))
#define GIMP_DISPLAY_SHELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DISPLAY_SHELL, GimpDisplayShellClass))
#define GIMP_IS_DISPLAY_SHELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_DISPLAY_SHELL))
#define GIMP_IS_DISPLAY_SHELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DISPLAY_SHELL))
#define GIMP_DISPLAY_SHELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_DISPLAY_SHELL, GimpDisplayShellClass))
typedef struct _GimpDisplayShellClass GimpDisplayShellClass;
struct _GimpDisplayShell
{
GtkWindow parent_instance;
GimpDisplay *gdisp;
GimpItemFactory *menubar_factory;
GimpItemFactory *popup_factory;
GimpItemFactory *qmask_factory;
gdouble monitor_xres;
gdouble monitor_yres;
gdouble scale; /* scale factor from original raw image */
gdouble other_scale; /* scale factor entered in Zoom->Other */
gboolean dot_for_dot; /* is monitor resolution being ignored? */
gint offset_x; /* offset of display image into raw image */
gint offset_y;
gint disp_width; /* width of drawing area */
gint disp_height; /* height of drawing area */
gint disp_xoffset;
gint disp_yoffset;
gboolean proximity; /* is a device in proximity */
gboolean snap_to_guides; /* should the guides be snapped to? */
gboolean snap_to_grid; /* should the grid be snapped to? */
Selection *select; /* Selection object */
GtkAdjustment *hsbdata; /* adjustments */
GtkAdjustment *vsbdata;
GtkWidget *canvas; /* GimpCanvas widget */
GtkWidget *hsb; /* scroll bars */
GtkWidget *vsb;
GtkWidget *qmask; /* qmask button */
GtkWidget *hrule; /* rulers */
GtkWidget *vrule;
GtkWidget *origin; /* origin button */
GtkWidget *statusbar; /* statusbar */
guchar *render_buf; /* buffer for rendering the image */
guint title_idle_id; /* title update idle ID */
gint icon_size; /* size of the icon pixmap */
guint icon_idle_id; /* ID of the idle-function */
GdkCursorType current_cursor; /* Currently installed main cursor */
GimpToolCursorType tool_cursor; /* Current Tool cursor */
GimpCursorModifier cursor_modifier; /* Cursor modifier (plus, minus, ...) */
GdkCursorType override_cursor; /* Overriding cursor */
gboolean using_override_cursor; /* is the cursor overridden? */
gboolean draw_cursor; /* should we draw software cursor ? */
gboolean have_cursor; /* is cursor currently drawn ? */
gint cursor_x; /* software cursor X value */
gint cursor_y; /* software cursor Y value */
GtkWidget *padding_button; /* GimpColorPanel in the NE corner */
GtkWidget *nav_ebox; /* GtkEventBox on the SE corner */
GtkWidget *warning_dialog; /* close warning dialog */
InfoDialog *info_dialog; /* image information dialog */
GtkWidget *scale_dialog; /* scale (zoom) dialog */
GtkWidget *nav_popup; /* navigation popup */
GtkWidget *grid_dialog; /* grid configuration dialog */
GimpColorDisplayStack *filter_stack; /* color display conversion stuff */
guint filter_idle_id;
GtkWidget *filters_dialog;/* color display filter dialog */
GdkWindowState window_state; /* for fullscreen display */
gint paused_count;
GQuark vectors_freeze_handler;
GQuark vectors_thaw_handler;
GQuark vectors_visible_handler;
GimpDisplayOptions *options;
GimpDisplayOptions *fullscreen_options;
/* the state of gimp_display_shell_tool_events() */
gboolean space_pressed;
gboolean space_release_pending;
gboolean scrolling;
gint scroll_start_x;
gint scroll_start_y;
gboolean button_press_before_focus;
};
struct _GimpDisplayShellClass
{
GtkWindowClass parent_class;
void (* scaled) (GimpDisplayShell *shell);
void (* scrolled) (GimpDisplayShell *shell);
void (* reconnect) (GimpDisplayShell *shell);
};
GType gimp_display_shell_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_display_shell_new (GimpDisplay *gdisp,
gdouble scale,
GimpMenuFactory *menu_factory,
GimpItemFactory *popup_factory);
void gimp_display_shell_close (GimpDisplayShell *shell,
gboolean kill_it);
void gimp_display_shell_reconnect (GimpDisplayShell *shell);
void gimp_display_shell_scaled (GimpDisplayShell *shell);
void gimp_display_shell_scrolled (GimpDisplayShell *shell);
void gimp_display_shell_snap_coords (GimpDisplayShell *shell,
GimpCoords *coords,
GimpCoords *snapped_coords,
gint snap_offset_x,
gint snap_offset_y,
gint snap_width,
gint snap_height);
gboolean gimp_display_shell_mask_bounds (GimpDisplayShell *shell,
gint *x1,
gint *y1,
gint *x2,
gint *y2);
void gimp_display_shell_expose_area (GimpDisplayShell *shell,
gint x,
gint y,
gint w,
gint h);
void gimp_display_shell_expose_guide (GimpDisplayShell *shell,
GimpGuide *guide);
void gimp_display_shell_expose_full (GimpDisplayShell *shell);
void gimp_display_shell_flush (GimpDisplayShell *shell,
gboolean now);
void gimp_display_shell_pause (GimpDisplayShell *shell);
void gimp_display_shell_resume (GimpDisplayShell *shell);
void gimp_display_shell_draw_area (GimpDisplayShell *shell,
gint x,
gint y,
gint w,
gint h);
void gimp_display_shell_draw_cursor (GimpDisplayShell *shell);
void gimp_display_shell_draw_guide (GimpDisplayShell *shell,
GimpGuide *guide,
gboolean active);
void gimp_display_shell_draw_guides (GimpDisplayShell *shell);
void gimp_display_shell_draw_grid (GimpDisplayShell *shell);
void gimp_display_shell_draw_vector (GimpDisplayShell *shell,
GimpVectors *vectors);
void gimp_display_shell_draw_vectors (GimpDisplayShell *shell);
void gimp_display_shell_update_icon (GimpDisplayShell *shell);
void gimp_display_shell_shrink_wrap (GimpDisplayShell *shell);
void gimp_display_shell_selection_visibility (GimpDisplayShell *shell,
GimpSelectionControl control);
#endif /* __GIMP_DISPLAY_SHELL_H__ */
#ifndef __GIMP_DISPLAY_SHELL_DRAW_H__
#define __GIMP_DISPLAY_SHELL_DRAW_H__
void gimp_display_shell_draw_guide (GimpDisplayShell *shell,
GimpGuide *guide,
gboolean active);
void gimp_display_shell_draw_guides (GimpDisplayShell *shell);
void gimp_display_shell_draw_grid (GimpDisplayShell *shell);
void gimp_display_shell_draw_vector (GimpDisplayShell *shell,
GimpVectors *vectors);
void gimp_display_shell_draw_vectors (GimpDisplayShell *shell);
void gimp_display_shell_draw_cursor (GimpDisplayShell *shell);
void gimp_display_shell_draw_area (GimpDisplayShell *shell,
gint x,
gint y,
gint w,
gint h);
#endif /* __GIMP_DISPLAY_SHELL_DRAW_H__ */
......@@ -38,6 +38,7 @@
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-appearance.h"
#include "gimpdisplayshell-callbacks.h"
#include "gimpdisplayshell-draw.h"
#include "gimpdisplayshell-handlers.h"
#include "gimpdisplayshell-scale.h"
#include "gimpdisplayshell-title.h"
......
......@@ -72,6 +72,7 @@
#include "gimpdisplayshell-callbacks.h"
#include "gimpdisplayshell-cursor.h"
#include "gimpdisplayshell-dnd.h"
#include "gimpdisplayshell-draw.h"
#include "gimpdisplayshell-filter.h"
#include "gimpdisplayshell-handlers.h"
#include "gimpdisplayshell-render.h"
......@@ -107,8 +108,6 @@ static gboolean gimp_display_shell_delete_event (GtkWidget *widget
static void gimp_display_shell_real_scaled (GimpDisplayShell *shell);
static GdkGC * gimp_display_shell_grid_gc_new (GtkWidget *widget,
GimpGrid *grid);
static void gimp_display_shell_close_warning_dialog (GimpDisplayShell *shell,
GimpImage *gimage);
static void gimp_display_shell_close_warning_callback (GtkWidget *widget,
......@@ -558,7 +557,7 @@ gimp_display_shell_new (GimpDisplay *gdisp,
{
new_scale = shell->scale * MIN (((gdouble) s_height) / n_height,
((gdouble) s_width) / n_width);
new_scale = gimp_display_shell_scale_zoom_step (GIMP_ZOOM_OUT,
new_scale);
......@@ -1259,326 +1258,6 @@ gimp_display_shell_update_icon (GimpDisplayShell *shell)
g_object_unref (pixbuf);
}
void
gimp_display_shell_draw_guide (GimpDisplayShell *shell,
GimpGuide *guide,
gboolean active)
{
gint x1, x2;
gint y1, y2;
gint x, y;
gint w, h;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (guide != NULL);
if (guide->position < 0)
return;
gimp_display_shell_transform_xy (shell, 0, 0, &x1, &y1, FALSE);
gimp_display_shell_transform_xy (shell,
shell->gdisp->gimage->width,
shell->gdisp->gimage->height,
&x2, &y2, FALSE);
gdk_drawable_get_size (shell->canvas->window, &w, &h);
if (x1 < 0) x1 = 0;
if (y1 < 0) y1 = 0;
if (x2 > w) x2 = w;
if (y2 > h) y2 = h;
switch (guide->orientation)
{
case GIMP_ORIENTATION_HORIZONTAL:
gimp_display_shell_transform_xy (shell,
0, guide->position, &x, &y, FALSE);
y1 = y2 = y;
break;
case GIMP_ORIENTATION_VERTICAL:
gimp_display_shell_transform_xy (shell,
guide->position, 0, &x, &y, FALSE);
x1 = x2 = x;
break;
case GIMP_ORIENTATION_UNKNOWN:
return;
}
gimp_canvas_draw_line (GIMP_CANVAS (shell->canvas),
(active ?
GIMP_CANVAS_STYLE_GUIDE_ACTIVE :
GIMP_CANVAS_STYLE_GUIDE_NORMAL), x1, y1, x2, y2);
}
void
gimp_display_shell_draw_guides (GimpDisplayShell *shell)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (gimp_display_shell_get_show_guides (shell))
{
GList *list;
for (list = shell->gdisp->gimage->guides; list; list = list->next)
{
gimp_display_shell_draw_guide (shell,
(GimpGuide *) list->data,
FALSE);
}
}
}
void
gimp_display_shell_draw_grid (GimpDisplayShell *shell)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (gimp_display_shell_get_show_grid (shell))
{
GimpGrid *grid;
GimpCanvas *canvas;
GdkGC *gc;
gint x1, x2;
gint y1, y2;
gint x, y;
gint x_real, y_real;
gint width, height;
const gint length = 2;
grid = GIMP_GRID (shell->gdisp->gimage->grid);
if (grid == NULL)
return;
gimp_display_shell_transform_xy (shell, 0, 0, &x1, &y1, FALSE);
gimp_display_shell_transform_xy (shell,
shell->gdisp->gimage->width,
shell->gdisp->gimage->height,
&x2, &y2, FALSE);
width = shell->gdisp->gimage->width;
height = shell->gdisp->gimage->height;
canvas = GIMP_CANVAS (shell->canvas);
gc = gimp_display_shell_grid_gc_new (shell->canvas, grid);
gimp_canvas_set_custom_gc (canvas, gc);
g_object_unref (gc);
switch (grid->style)
{
case GIMP_GRID_DOTS:
for (x = grid->xoffset; x <= width; x += grid->xspacing)
{
for (y = grid->yoffset; y <= height; y += grid->yspacing)
{
gimp_display_shell_transform_xy (shell,
x, y, &x_real, &y_real,
FALSE);
if (x_real >= x1 && x_real < x2 &&
y_real >= y1 && y_real < y2)
{
gimp_canvas_draw_point (GIMP_CANVAS (shell->canvas),
GIMP_CANVAS_STYLE_CUSTOM,
x_real, y_real);
}
}
}
break;
case GIMP_GRID_INTERSECTIONS:
for (x = grid->xoffset; x <= width; x += grid->xspacing)
{
for (y = grid->yoffset; y <= height; y += grid->yspacing)
{
gimp_display_shell_transform_xy (shell,
x, y, &x_real, &y_real,
FALSE);
if (x_real >= x1 && x_real < x2)
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_CUSTOM,
x_real,
CLAMP (y_real - length, y1, y2 - 1),
x_real,
CLAMP (y_real + length, y1, y2 - 1));
if (y_real >= y1 && y_real < y2)
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_CUSTOM,
CLAMP (x_real - length, x1, x2 - 1),
y_real,
CLAMP (x_real + length, x1, x2 - 1),
y_real);
}
}
break;
case GIMP_GRID_ON_OFF_DASH:
case GIMP_GRID_DOUBLE_DASH:
case GIMP_GRID_SOLID:
for (x = grid->xoffset; x < width; x += grid->xspacing)
{
gimp_display_shell_transform_xy (shell,
x, 0, &x_real, &y_real,
FALSE);
if (x_real > x1)
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_CUSTOM,
x_real, y1, x_real, y2 - 1);
}
for (y = grid->yoffset; y < height; y += grid->yspacing)
{
gimp_display_shell_transform_xy (shell,
0, y, &x_real, &y_real,
FALSE);
if (y_real > y1)
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_CUSTOM,
x1, y_real, x2 - 1, y_real);
}
break;
}
gimp_canvas_set_custom_gc (canvas, NULL);
}
}
void
gimp_display_shell_draw_vector (GimpDisplayShell *shell,
GimpVectors *vectors)
{
GimpStroke *stroke = NULL;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (GIMP_IS_VECTORS (vectors));
while ((stroke = gimp_vectors_stroke_get_next (vectors, stroke)))
{
GArray *coords;
gboolean closed;
coords = gimp_stroke_interpolate (stroke, 1.0, &closed);
if (coords && coords->len)
{
GimpCoords *coord;
GdkPoint *gdk_coords;
gint i;
gdouble sx, sy;
gdk_coords = g_new (GdkPoint, coords->len);
for (i = 0; i < coords->len; i++)
{
coord = &g_array_index (coords, GimpCoords, i);
gimp_display_shell_transform_xy_f (shell,
coord->x, coord->y,
&sx, &sy,
FALSE);
gdk_coords[i].x = ROUND (sx);
gdk_coords[i].y = ROUND (sy);
}
gimp_canvas_draw_lines (GIMP_CANVAS (shell->canvas),
GIMP_CANVAS_STYLE_XOR,
gdk_coords, coords->len);
g_free (gdk_coords);
}
if (coords)
g_array_free (coords, TRUE);
}
}
void
gimp_display_shell_draw_vectors (GimpDisplayShell *shell)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (TRUE /* gimp_display_shell_get_show_vectors (shell) */)
{
GList *list;
for (list = GIMP_LIST (shell->gdisp->gimage->vectors)->list;
list;