More uiArea work. Ready to write the actual drawing code now, I suppose.

This commit is contained in:
Pietro Gagliardi 2015-09-06 16:55:43 -04:00
parent 33c1852e21
commit e628ae45bb
2 changed files with 20 additions and 4 deletions

View File

@ -1,6 +1,10 @@
// 4 september 2015 // 4 september 2015
#include "area.h" #include "area.h"
struct uiDrawContext {
cairo_t *cr;
};
struct areaPrivate { struct areaPrivate {
uiArea *a; uiArea *a;
uiAreaHandler *ah; uiAreaHandler *ah;
@ -121,8 +125,10 @@ static gboolean areaWidget_draw(GtkWidget *w, cairo_t *cr)
struct areaPrivate *ap = a->priv; struct areaPrivate *ap = a->priv;
uiAreaDrawParams dp; uiAreaDrawParams dp;
double clipX0, clipY0, clipX1, clipY1; double clipX0, clipY0, clipX1, clipY1;
uiDrawContext ctxt;
// TODO dp.Context ctxt.cr = cr;
dp.Context = &ctxt;
dp.ClientWidth = ap->clientWidth; dp.ClientWidth = ap->clientWidth;
dp.ClientHeight = ap->clientHeight; dp.ClientHeight = ap->clientHeight;
@ -133,6 +139,14 @@ static gboolean areaWidget_draw(GtkWidget *w, cairo_t *cr)
dp.ClipWidth = clipX1 - clipX0; dp.ClipWidth = clipX1 - clipX0;
dp.ClipHeight = clipY1 - clipY0; dp.ClipHeight = clipY1 - clipY0;
// on GTK+ you're not supposed to care about high-DPI scaling
// instead, pango handles scaled text rendering for us
// this doesn't handle non-text cases, but neither do other GTK+ programs, so :/
// wayland and mir GDK are hardcoded to 96dpi; X11 uses this as a fallback
// thanks to hergertme in irc.gimp.net/#gtk+ for clarifying things
dp.DPIX = 96;
dp.DPIY = 96;
dp.HScrollPos = gtk_adjustment_get_value(ap->ha); dp.HScrollPos = gtk_adjustment_get_value(ap->ha);
dp.VScrollPos = gtk_adjustment_get_value(ap->va); dp.VScrollPos = gtk_adjustment_get_value(ap->va);

View File

@ -4,6 +4,8 @@ typedef struct uiArea uiArea;
typedef struct uiAreaHandler uiAreaHandler; typedef struct uiAreaHandler uiAreaHandler;
typedef struct uiAreaDrawParams uiAreaDrawParams; typedef struct uiAreaDrawParams uiAreaDrawParams;
typedef struct uiDrawContext uiDrawContext;
struct uiAreaHandler { struct uiAreaHandler {
void (*Draw)(uiAreaHandler *, uiArea *, uiAreaDrawParams *); void (*Draw)(uiAreaHandler *, uiArea *, uiAreaDrawParams *);
uintmax_t (*HScrollMax)(uiAreaHandler *, uiArea *); uintmax_t (*HScrollMax)(uiAreaHandler *, uiArea *);
@ -11,7 +13,7 @@ struct uiAreaHandler {
}; };
struct uiAreaDrawParams { struct uiAreaDrawParams {
// TODO context uiDrawContext *Context;
intmax_t ClientWidth; intmax_t ClientWidth;
intmax_t ClientHeight; intmax_t ClientHeight;
@ -21,8 +23,8 @@ struct uiAreaDrawParams {
intmax_t ClipWidth; intmax_t ClipWidth;
intmax_t ClipHeight; intmax_t ClipHeight;
//TODO xxxx DPIX; int DPIX;
//TODO xxxx DPIY; int DPIY;
intmax_t HScrollPos; intmax_t HScrollPos;
intmax_t VScrollPos; intmax_t VScrollPos;