More uiArea work. Ready to write the actual drawing code now, I suppose.
This commit is contained in:
parent
33c1852e21
commit
e628ae45bb
|
@ -1,6 +1,10 @@
|
|||
// 4 september 2015
|
||||
#include "area.h"
|
||||
|
||||
struct uiDrawContext {
|
||||
cairo_t *cr;
|
||||
};
|
||||
|
||||
struct areaPrivate {
|
||||
uiArea *a;
|
||||
uiAreaHandler *ah;
|
||||
|
@ -121,8 +125,10 @@ static gboolean areaWidget_draw(GtkWidget *w, cairo_t *cr)
|
|||
struct areaPrivate *ap = a->priv;
|
||||
uiAreaDrawParams dp;
|
||||
double clipX0, clipY0, clipX1, clipY1;
|
||||
uiDrawContext ctxt;
|
||||
|
||||
// TODO dp.Context
|
||||
ctxt.cr = cr;
|
||||
dp.Context = &ctxt;
|
||||
|
||||
dp.ClientWidth = ap->clientWidth;
|
||||
dp.ClientHeight = ap->clientHeight;
|
||||
|
@ -133,6 +139,14 @@ static gboolean areaWidget_draw(GtkWidget *w, cairo_t *cr)
|
|||
dp.ClipWidth = clipX1 - clipX0;
|
||||
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.VScrollPos = gtk_adjustment_get_value(ap->va);
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ typedef struct uiArea uiArea;
|
|||
typedef struct uiAreaHandler uiAreaHandler;
|
||||
typedef struct uiAreaDrawParams uiAreaDrawParams;
|
||||
|
||||
typedef struct uiDrawContext uiDrawContext;
|
||||
|
||||
struct uiAreaHandler {
|
||||
void (*Draw)(uiAreaHandler *, uiArea *, uiAreaDrawParams *);
|
||||
uintmax_t (*HScrollMax)(uiAreaHandler *, uiArea *);
|
||||
|
@ -11,7 +13,7 @@ struct uiAreaHandler {
|
|||
};
|
||||
|
||||
struct uiAreaDrawParams {
|
||||
// TODO context
|
||||
uiDrawContext *Context;
|
||||
|
||||
intmax_t ClientWidth;
|
||||
intmax_t ClientHeight;
|
||||
|
@ -21,8 +23,8 @@ struct uiAreaDrawParams {
|
|||
intmax_t ClipWidth;
|
||||
intmax_t ClipHeight;
|
||||
|
||||
//TODO xxxx DPIX;
|
||||
//TODO xxxx DPIY;
|
||||
int DPIX;
|
||||
int DPIY;
|
||||
|
||||
intmax_t HScrollPos;
|
||||
intmax_t VScrollPos;
|
||||
|
|
Loading…
Reference in New Issue