aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2011-11-09 21:39:56 +0100
committerThomas White <taw@bitwiz.org.uk>2011-11-09 21:39:56 +0100
commit204b75d648a24d9a03f53b60c6c77a128eedee37 (patch)
tree64bd80426f6283899f8fd83e26dc3f975b8fe9b5
parent6ee425b365d2486304f05ff87da3f1846eb26408 (diff)
Respect margins when importing an image
-rw-r--r--src/mainwindow.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 1c5f467..a4fae6b 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -915,11 +915,36 @@ static gboolean dnd_motion(GtkWidget *widget, GdkDragContext *drag_context,
if ( p->have_drag_data && p->import_acceptable ) {
+ struct style *sty;
+ double eright, ebottom;
+
gdk_drag_status(drag_context, GDK_ACTION_LINK, time);
p->start_corner_x = x - p->import_width/2.0;
p->start_corner_y = y - p->import_height/2.0;
p->drag_corner_x = x + p->import_width/2.0;
p->drag_corner_y = y + p->import_height/2.0;
+
+ sty = p->ss->styles[0];
+
+ eright = p->slide_width - sty->margin_right;
+ ebottom = p->slide_height - sty->margin_bottom;
+ if ( p->start_corner_x < sty->margin_left ) {
+ p->start_corner_x = sty->margin_left;
+ p->drag_corner_x = sty->margin_left + p->import_width;
+ }
+ if ( p->start_corner_y < sty->margin_top ) {
+ p->start_corner_y = sty->margin_top;
+ p->drag_corner_y = sty->margin_top + p->import_height;
+ }
+ if ( p->drag_corner_x > eright ) {
+ p->drag_corner_x = eright;
+ p->start_corner_x = eright - p->import_width;
+ }
+ if ( p->drag_corner_y > ebottom ) {
+ p->drag_corner_y = ebottom;
+ p->start_corner_y = ebottom - p->import_height;
+ }
+
redraw_overlay(p);
}