app/gtkhwrapbox.[ch] sync from gle

* app/gtkhwrapbox.[ch]
* app/gtkwrapbox.[ch]: sync from gle

* app/inteface.c: set allow_shrink on the toolbox window, use
gtk_hwrap_box_new

* app/blend.c: use shift to constrain to 45 deg: XachCode (tm)

-Yosh
This commit is contained in:
Manish Singh 1999-09-02 18:56:39 +00:00
parent 42b6faccc0
commit 52b5222052
16 changed files with 174 additions and 35 deletions

View file

@ -1,3 +1,13 @@
Thu Sep 2 11:51:02 PDT 1999 Manish Singh <yosh@gimp.org>
* app/gtkhwrapbox.[ch]
* app/gtkwrapbox.[ch]: sync from gle
* app/inteface.c: set allow_shrink on the toolbox window, use
gtk_hwrap_box_new
* app/blend.c: use shift to constrain to 45 deg: XachCode (tm)
Thu Sep 2 19:25:03 MEST 1999 Sven Neumann <sven@gimp.org> Thu Sep 2 19:25:03 MEST 1999 Sven Neumann <sven@gimp.org>
* app/app_procs.c: call device_status_free before freeing brushes * app/app_procs.c: call device_status_free before freeing brushes

View file

@ -630,6 +630,33 @@ blend_motion (Tool *tool,
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
&blend_tool->endx, &blend_tool->endy, FALSE, 1); &blend_tool->endx, &blend_tool->endy, FALSE, 1);
/* Restrict to multiples of 45 degrees if shift is pressed */
if (mevent->state & GDK_SHIFT_MASK) {
int dx, dy, d;
int abs_dx, abs_dy;
dx = blend_tool->endx - blend_tool->startx;
dy = blend_tool->endy - blend_tool->starty;
abs_dx = abs(dx);
abs_dy = abs(dy);
d = (abs_dx + abs_dy) >> 1;
if ((abs_dx >> 1) < abs_dy && (abs_dy >> 1) < abs_dx)
{
blend_tool->endx = blend_tool->startx + ((dx < 0) ? -d : d);
blend_tool->endy = blend_tool->starty + ((dy < 0) ? -d : d);
}
else
{
if (abs_dx > abs_dy)
blend_tool->endy = blend_tool->starty;
else
blend_tool->endx = blend_tool->startx;
}
}
/* restrict to horizontal/vertical blend, if modifiers are pressed */ /* restrict to horizontal/vertical blend, if modifiers are pressed */
if (mevent->state & GDK_MOD1_MASK) if (mevent->state & GDK_MOD1_MASK)
{ {

View file

@ -630,6 +630,33 @@ blend_motion (Tool *tool,
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
&blend_tool->endx, &blend_tool->endy, FALSE, 1); &blend_tool->endx, &blend_tool->endy, FALSE, 1);
/* Restrict to multiples of 45 degrees if shift is pressed */
if (mevent->state & GDK_SHIFT_MASK) {
int dx, dy, d;
int abs_dx, abs_dy;
dx = blend_tool->endx - blend_tool->startx;
dy = blend_tool->endy - blend_tool->starty;
abs_dx = abs(dx);
abs_dy = abs(dy);
d = (abs_dx + abs_dy) >> 1;
if ((abs_dx >> 1) < abs_dy && (abs_dy >> 1) < abs_dx)
{
blend_tool->endx = blend_tool->startx + ((dx < 0) ? -d : d);
blend_tool->endy = blend_tool->starty + ((dy < 0) ? -d : d);
}
else
{
if (abs_dx > abs_dy)
blend_tool->endy = blend_tool->starty;
else
blend_tool->endx = blend_tool->startx;
}
}
/* restrict to horizontal/vertical blend, if modifiers are pressed */ /* restrict to horizontal/vertical blend, if modifiers are pressed */
if (mevent->state & GDK_MOD1_MASK) if (mevent->state & GDK_MOD1_MASK)
{ {

View file

@ -349,7 +349,7 @@ create_tools (GtkWidget *parent)
gint i, j; gint i, j;
/*create_logo (parent);*/ /*create_logo (parent);*/
wbox = GTK_WIDGET (gtk_type_new (gtk_hwrap_box_get_type ())); wbox = gtk_hwrap_box_new (FALSE);
gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (wbox), .36); gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (wbox), .36);
gtk_box_pack_start (GTK_BOX (parent), wbox, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (parent), wbox, TRUE, TRUE, 0);
@ -526,6 +526,7 @@ create_toolbox ()
gtk_window_set_wmclass (GTK_WINDOW (window), "toolbox", "Gimp"); gtk_window_set_wmclass (GTK_WINDOW (window), "toolbox", "Gimp");
gtk_window_set_title (GTK_WINDOW (window), _("The GIMP")); gtk_window_set_title (GTK_WINDOW (window), _("The GIMP"));
gtk_window_set_policy (GTK_WINDOW (window), TRUE, TRUE, FALSE);
session_set_window_geometry (window, &toolbox_session_info, TRUE); session_set_window_geometry (window, &toolbox_session_info, TRUE);
gtk_signal_connect (GTK_OBJECT (window), "delete_event", gtk_signal_connect (GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC (toolbox_delete), GTK_SIGNAL_FUNC (toolbox_delete),

View file

@ -349,7 +349,7 @@ create_tools (GtkWidget *parent)
gint i, j; gint i, j;
/*create_logo (parent);*/ /*create_logo (parent);*/
wbox = GTK_WIDGET (gtk_type_new (gtk_hwrap_box_get_type ())); wbox = gtk_hwrap_box_new (FALSE);
gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (wbox), .36); gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (wbox), .36);
gtk_box_pack_start (GTK_BOX (parent), wbox, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (parent), wbox, TRUE, TRUE, 0);
@ -526,6 +526,7 @@ create_toolbox ()
gtk_window_set_wmclass (GTK_WINDOW (window), "toolbox", "Gimp"); gtk_window_set_wmclass (GTK_WINDOW (window), "toolbox", "Gimp");
gtk_window_set_title (GTK_WINDOW (window), _("The GIMP")); gtk_window_set_title (GTK_WINDOW (window), _("The GIMP"));
gtk_window_set_policy (GTK_WINDOW (window), TRUE, TRUE, FALSE);
session_set_window_geometry (window, &toolbox_session_info, TRUE); session_set_window_geometry (window, &toolbox_session_info, TRUE);
gtk_signal_connect (GTK_OBJECT (window), "delete_event", gtk_signal_connect (GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC (toolbox_delete), GTK_SIGNAL_FUNC (toolbox_delete),

View file

@ -88,6 +88,18 @@ gtk_hwrap_box_init (GtkHWrapBox *hwbox)
hwbox->max_child_height = 0; hwbox->max_child_height = 0;
} }
GtkWidget *
gtk_hwrap_box_new (gboolean homogeneous)
{
GtkHWrapBox *hwbox;
hwbox = GTK_HWRAP_BOX (gtk_widget_new (gtk_hwrap_box_get_type (), NULL));
GTK_WRAP_BOX (hwbox)->homogeneous = homogeneous ? TRUE : FALSE;
return GTK_WIDGET (hwbox);
}
static inline void static inline void
get_child_requisition (GtkWrapBox *wbox, get_child_requisition (GtkWrapBox *wbox,
GtkWidget *child, GtkWidget *child,
@ -252,10 +264,10 @@ gtk_hwrap_box_size_request (GtkWidget *widget,
} }
/*<h2v-off>*/ /*<h2v-off>*/
g_print ("ratio for width %d height %d = %f\n", /* g_print ("ratio for width %d height %d = %f\n",
(gint) layout_width, (gint) layout_width,
(gint) layout_height, (gint) layout_height,
ratio); ratio); */
/*<h2v-on>*/ /*<h2v-on>*/
} }
while (row_inc); while (row_inc);
@ -263,9 +275,9 @@ gtk_hwrap_box_size_request (GtkWidget *widget,
/*<h2v-off>*/ /*<h2v-off>*/
requisition->width += GTK_CONTAINER (wbox)->border_width * 2; requisition->width += GTK_CONTAINER (wbox)->border_width * 2;
requisition->height += GTK_CONTAINER (wbox)->border_width * 2; requisition->height += GTK_CONTAINER (wbox)->border_width * 2;
g_print ("choosen: width %d, height %d\n", /* g_print ("choosen: width %d, height %d\n",
requisition->width, requisition->width,
requisition->height); requisition->height); */
/*<h2v-on>*/ /*<h2v-on>*/
} }
@ -449,11 +461,11 @@ layout_row (GtkWrapBox *wbox,
} }
else else
{ {
g_print ("child_allocation.x %d += %d * %f ", /* g_print ("child_allocation.x %d += %d * %f ",
child_allocation.x, n_children, extra); child_allocation.x, n_children, extra); */
child_allocation.x += n_children * extra; child_allocation.x += n_children * extra;
g_print ("= %d\n", /* g_print ("= %d\n",
child_allocation.x); child_allocation.x); */
child_allocation.width = MIN (child_requisition.width, child_allocation.width = MIN (child_requisition.width,
area->width - child_allocation.x + area->x); area->width - child_allocation.x + area->x);
} }
@ -619,9 +631,9 @@ gtk_hwrap_box_size_allocate (GtkWidget *widget,
area.height = MAX (1, (gint) allocation->height - border * 2); area.height = MAX (1, (gint) allocation->height - border * 2);
/*<h2v-off>*/ /*<h2v-off>*/
g_print ("got: width %d, height %d\n", /* g_print ("got: width %d, height %d\n",
allocation->width, allocation->width,
allocation->height); allocation->height); */
/*<h2v-on>*/ /*<h2v-on>*/
layout_rows (wbox, &area); layout_rows (wbox, &area);

View file

@ -61,7 +61,7 @@ struct _GtkHWrapBoxClass
/* --- prototypes --- */ /* --- prototypes --- */
GtkType gtk_hwrap_box_get_type (void); GtkType gtk_hwrap_box_get_type (void);
GtkWidget* gtk_hwrap_box_new (gboolean homogeneous);
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -19,9 +19,10 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#include "gtkwrapbox.h"
#include <math.h> #include <math.h>
#include "gtkwrapbox.h"
/* --- arguments --- */ /* --- arguments --- */
enum { enum {

View file

@ -123,7 +123,3 @@ void gtk_wrap_box_set_child_packing (GtkWrapBox *wbox,
#endif /* __GTK_WRAP_BOX_H__ */ #endif /* __GTK_WRAP_BOX_H__ */

View file

@ -349,7 +349,7 @@ create_tools (GtkWidget *parent)
gint i, j; gint i, j;
/*create_logo (parent);*/ /*create_logo (parent);*/
wbox = GTK_WIDGET (gtk_type_new (gtk_hwrap_box_get_type ())); wbox = gtk_hwrap_box_new (FALSE);
gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (wbox), .36); gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (wbox), .36);
gtk_box_pack_start (GTK_BOX (parent), wbox, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (parent), wbox, TRUE, TRUE, 0);
@ -526,6 +526,7 @@ create_toolbox ()
gtk_window_set_wmclass (GTK_WINDOW (window), "toolbox", "Gimp"); gtk_window_set_wmclass (GTK_WINDOW (window), "toolbox", "Gimp");
gtk_window_set_title (GTK_WINDOW (window), _("The GIMP")); gtk_window_set_title (GTK_WINDOW (window), _("The GIMP"));
gtk_window_set_policy (GTK_WINDOW (window), TRUE, TRUE, FALSE);
session_set_window_geometry (window, &toolbox_session_info, TRUE); session_set_window_geometry (window, &toolbox_session_info, TRUE);
gtk_signal_connect (GTK_OBJECT (window), "delete_event", gtk_signal_connect (GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC (toolbox_delete), GTK_SIGNAL_FUNC (toolbox_delete),

View file

@ -630,6 +630,33 @@ blend_motion (Tool *tool,
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
&blend_tool->endx, &blend_tool->endy, FALSE, 1); &blend_tool->endx, &blend_tool->endy, FALSE, 1);
/* Restrict to multiples of 45 degrees if shift is pressed */
if (mevent->state & GDK_SHIFT_MASK) {
int dx, dy, d;
int abs_dx, abs_dy;
dx = blend_tool->endx - blend_tool->startx;
dy = blend_tool->endy - blend_tool->starty;
abs_dx = abs(dx);
abs_dy = abs(dy);
d = (abs_dx + abs_dy) >> 1;
if ((abs_dx >> 1) < abs_dy && (abs_dy >> 1) < abs_dx)
{
blend_tool->endx = blend_tool->startx + ((dx < 0) ? -d : d);
blend_tool->endy = blend_tool->starty + ((dy < 0) ? -d : d);
}
else
{
if (abs_dx > abs_dy)
blend_tool->endy = blend_tool->starty;
else
blend_tool->endx = blend_tool->startx;
}
}
/* restrict to horizontal/vertical blend, if modifiers are pressed */ /* restrict to horizontal/vertical blend, if modifiers are pressed */
if (mevent->state & GDK_MOD1_MASK) if (mevent->state & GDK_MOD1_MASK)
{ {

View file

@ -630,6 +630,33 @@ blend_motion (Tool *tool,
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
&blend_tool->endx, &blend_tool->endy, FALSE, 1); &blend_tool->endx, &blend_tool->endy, FALSE, 1);
/* Restrict to multiples of 45 degrees if shift is pressed */
if (mevent->state & GDK_SHIFT_MASK) {
int dx, dy, d;
int abs_dx, abs_dy;
dx = blend_tool->endx - blend_tool->startx;
dy = blend_tool->endy - blend_tool->starty;
abs_dx = abs(dx);
abs_dy = abs(dy);
d = (abs_dx + abs_dy) >> 1;
if ((abs_dx >> 1) < abs_dy && (abs_dy >> 1) < abs_dx)
{
blend_tool->endx = blend_tool->startx + ((dx < 0) ? -d : d);
blend_tool->endy = blend_tool->starty + ((dy < 0) ? -d : d);
}
else
{
if (abs_dx > abs_dy)
blend_tool->endy = blend_tool->starty;
else
blend_tool->endx = blend_tool->startx;
}
}
/* restrict to horizontal/vertical blend, if modifiers are pressed */ /* restrict to horizontal/vertical blend, if modifiers are pressed */
if (mevent->state & GDK_MOD1_MASK) if (mevent->state & GDK_MOD1_MASK)
{ {

View file

@ -88,6 +88,18 @@ gtk_hwrap_box_init (GtkHWrapBox *hwbox)
hwbox->max_child_height = 0; hwbox->max_child_height = 0;
} }
GtkWidget *
gtk_hwrap_box_new (gboolean homogeneous)
{
GtkHWrapBox *hwbox;
hwbox = GTK_HWRAP_BOX (gtk_widget_new (gtk_hwrap_box_get_type (), NULL));
GTK_WRAP_BOX (hwbox)->homogeneous = homogeneous ? TRUE : FALSE;
return GTK_WIDGET (hwbox);
}
static inline void static inline void
get_child_requisition (GtkWrapBox *wbox, get_child_requisition (GtkWrapBox *wbox,
GtkWidget *child, GtkWidget *child,
@ -252,10 +264,10 @@ gtk_hwrap_box_size_request (GtkWidget *widget,
} }
/*<h2v-off>*/ /*<h2v-off>*/
g_print ("ratio for width %d height %d = %f\n", /* g_print ("ratio for width %d height %d = %f\n",
(gint) layout_width, (gint) layout_width,
(gint) layout_height, (gint) layout_height,
ratio); ratio); */
/*<h2v-on>*/ /*<h2v-on>*/
} }
while (row_inc); while (row_inc);
@ -263,9 +275,9 @@ gtk_hwrap_box_size_request (GtkWidget *widget,
/*<h2v-off>*/ /*<h2v-off>*/
requisition->width += GTK_CONTAINER (wbox)->border_width * 2; requisition->width += GTK_CONTAINER (wbox)->border_width * 2;
requisition->height += GTK_CONTAINER (wbox)->border_width * 2; requisition->height += GTK_CONTAINER (wbox)->border_width * 2;
g_print ("choosen: width %d, height %d\n", /* g_print ("choosen: width %d, height %d\n",
requisition->width, requisition->width,
requisition->height); requisition->height); */
/*<h2v-on>*/ /*<h2v-on>*/
} }
@ -449,11 +461,11 @@ layout_row (GtkWrapBox *wbox,
} }
else else
{ {
g_print ("child_allocation.x %d += %d * %f ", /* g_print ("child_allocation.x %d += %d * %f ",
child_allocation.x, n_children, extra); child_allocation.x, n_children, extra); */
child_allocation.x += n_children * extra; child_allocation.x += n_children * extra;
g_print ("= %d\n", /* g_print ("= %d\n",
child_allocation.x); child_allocation.x); */
child_allocation.width = MIN (child_requisition.width, child_allocation.width = MIN (child_requisition.width,
area->width - child_allocation.x + area->x); area->width - child_allocation.x + area->x);
} }
@ -619,9 +631,9 @@ gtk_hwrap_box_size_allocate (GtkWidget *widget,
area.height = MAX (1, (gint) allocation->height - border * 2); area.height = MAX (1, (gint) allocation->height - border * 2);
/*<h2v-off>*/ /*<h2v-off>*/
g_print ("got: width %d, height %d\n", /* g_print ("got: width %d, height %d\n",
allocation->width, allocation->width,
allocation->height); allocation->height); */
/*<h2v-on>*/ /*<h2v-on>*/
layout_rows (wbox, &area); layout_rows (wbox, &area);

View file

@ -61,7 +61,7 @@ struct _GtkHWrapBoxClass
/* --- prototypes --- */ /* --- prototypes --- */
GtkType gtk_hwrap_box_get_type (void); GtkType gtk_hwrap_box_get_type (void);
GtkWidget* gtk_hwrap_box_new (gboolean homogeneous);
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -19,9 +19,10 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#include "gtkwrapbox.h"
#include <math.h> #include <math.h>
#include "gtkwrapbox.h"
/* --- arguments --- */ /* --- arguments --- */
enum { enum {

View file

@ -123,7 +123,3 @@ void gtk_wrap_box_set_child_packing (GtkWrapBox *wbox,
#endif /* __GTK_WRAP_BOX_H__ */ #endif /* __GTK_WRAP_BOX_H__ */