Switched coordinates to floating-point drawing space and implemented such on GTK+.

This commit is contained in:
Pietro Gagliardi 2015-10-14 08:49:06 -04:00
parent a504bcee40
commit 6849b01f73
2 changed files with 13 additions and 7 deletions

14
ui.h
View File

@ -275,10 +275,10 @@ _UI_EXTERN uiArea *uiNewArea(uiAreaHandler *ah);
struct uiAreaDrawParams {
uiDrawContext *Context;
// TODO this and the mouse event ones should probably be in points and not pixels
intmax_t ClientWidth;
intmax_t ClientHeight;
double ClientWidth;
double ClientHeight;
// TODO keep this?
intmax_t ClipX;
intmax_t ClipY;
intmax_t ClipWidth;
@ -439,11 +439,11 @@ enum uiModifiers {
};
struct uiAreaMouseEvent {
intmax_t X;
intmax_t Y;
double X;
double Y;
intmax_t ClientWidth;
intmax_t ClientHeight;
double ClientWidth;
double ClientHeight;
intmax_t HScrollPos;
intmax_t VScrollPos;

View File

@ -158,6 +158,9 @@ static gboolean areaWidget_draw(GtkWidget *w, cairo_t *cr)
dp.Context = newContext(cr);
// these are already in drawing space coordinates
// the size of drawing space has the same value as the widget allocation
// thanks to tristan in irc.gimp.net/#gtk+
dp.ClientWidth = ap->clientWidth;
dp.ClientHeight = ap->clientHeight;
@ -236,6 +239,9 @@ static void finishMouseEvent(struct areaPrivate *ap, uiAreaMouseEvent *me, guint
// don't check GDK_BUTTON4_MASK or GDK_BUTTON5_MASK because those are for the scrolling buttons mentioned above
// GDK expressly does not support any more buttons in the GdkModifierType; see https://git.gnome.org/browse/gtk+/tree/gdk/x11/gdkdevice-xi2.c#n763 (thanks mclasen in irc.gimp.net/#gtk+)
// these are already in drawing space coordinates
// the size of drawing space has the same value as the widget allocation
// thanks to tristan in irc.gimp.net/#gtk+
me->X = x;
me->Y = y;