Added a test of scrolled drawing. More TODOs.
This commit is contained in:
parent
13fa2e213d
commit
0f80d15fc4
5
TODO.md
5
TODO.md
|
@ -1,3 +1,8 @@
|
|||
- add uiPi for portability
|
||||
|
||||
- make it so that the windows cntrols only register a resize if their new minimum size is larger than their current size to easen the effect of flicker
|
||||
- it won't remove that outright, but it'll help
|
||||
|
||||
- http://blogs.msdn.com/b/oldnewthing/archive/2004/01/12/57833.aspx provide a DEF file on Windows
|
||||
|
||||
- all ports: update state when adding a control to a parent
|
||||
|
|
|
@ -13,6 +13,7 @@ CFILES += \
|
|||
test/page7.c \
|
||||
test/page7a.c \
|
||||
test/page7b.c \
|
||||
test/page7c.c \
|
||||
test/spaced.c
|
||||
|
||||
HFILES += \
|
||||
|
|
|
@ -18,7 +18,8 @@ uiBox *makePage7(void)
|
|||
group = makePage7b();
|
||||
uiBoxAppend(box2, uiControl(group), 1);
|
||||
|
||||
uiBoxAppend(box2, uiControl(uiNewLabel("")), 1);
|
||||
group = makePage7c();
|
||||
uiBoxAppend(box2, uiControl(group), 1);
|
||||
|
||||
return page7;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
// 13 october 2015
|
||||
#include "test.h"
|
||||
|
||||
static uiArea *area;
|
||||
|
||||
struct handler {
|
||||
uiAreaHandler ah;
|
||||
};
|
||||
|
||||
static struct handler handler;
|
||||
|
||||
#define areaSize 250
|
||||
#define borderThickness 1
|
||||
#define padding 30
|
||||
#define circleRadius ((areaSize - padding) / 2)
|
||||
|
||||
static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *dp)
|
||||
{
|
||||
uiDrawPath *path;
|
||||
uiDrawBrush brush;
|
||||
uiDrawStrokeParams sp;
|
||||
uiDrawBrushGradientStop stops[2];
|
||||
|
||||
memset(&brush, 0, sizeof (uiDrawBrush));
|
||||
memset(&sp, 0, sizeof (uiDrawStrokeParams));
|
||||
|
||||
path = uiDrawNewPath(uiDrawFillModeWinding);
|
||||
uiDrawPathAddRectangle(path,
|
||||
0, 0,
|
||||
areaSize, areaSize);
|
||||
uiDrawPathEnd(path);
|
||||
brush.Type = uiDrawBrushTypeSolid;
|
||||
brush.R = 1;
|
||||
brush.G = 0;
|
||||
brush.B = 0;
|
||||
brush.A = 1;
|
||||
sp.Cap = uiDrawLineCapFlat;
|
||||
sp.Join = uiDrawLineJoinMiter;
|
||||
sp.Thickness = 1;
|
||||
sp.MiterLimit = uiDrawDefaultMiterLimit;
|
||||
uiDrawStroke(dp->Context, path, &brush, &sp);
|
||||
uiDrawFreePath(path);
|
||||
|
||||
path = uiDrawNewPath(uiDrawFillModeWinding);
|
||||
uiDrawPathNewFigureWithArc(path,
|
||||
areaSize / 2, areaSize / 2,
|
||||
circleRadius,
|
||||
0, 2 * M_PI,
|
||||
0);
|
||||
uiDrawPathEnd(path);
|
||||
stops[0].Pos =0.0;
|
||||
stops[0].R = 0.0;
|
||||
stops[0].G = 1.0;
|
||||
stops[0].B = 1.0;
|
||||
stops[0].A = 1.0;
|
||||
stops[1].Pos = 1.0;
|
||||
stops[1].R = 0.0;
|
||||
stops[1].G = 0.0;
|
||||
stops[1].B = 1.0;
|
||||
stops[1].A = 1.0;
|
||||
brush.Type = uiDrawBrushTypeLinearGradient;
|
||||
brush.X0 = areaSize / 2;
|
||||
brush.Y0 = padding;
|
||||
brush.X1 = areaSize / 2;
|
||||
brush.Y1 = areaSize - padding;
|
||||
brush.Stops = stops;
|
||||
brush.NumStops = 2;
|
||||
uiDrawFill(dp->Context, path, &brush);
|
||||
uiDrawFreePath(path);
|
||||
}
|
||||
|
||||
static void handlerMouseEvent(uiAreaHandler *a, uiArea *area, uiAreaMouseEvent *e)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
static void handlerMouseCrossed(uiAreaHandler *ah, uiArea *a, int left)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
static void handlerDragBroken(uiAreaHandler *ah, uiArea *a)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
static int handlerKeyEvent(uiAreaHandler *ah, uiArea *a, uiAreaKeyEvent *e)
|
||||
{
|
||||
if (e->Key == 'h' && !e->Up) {
|
||||
// TODO hide the widget momentarily on the h key
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uiGroup *makePage7c(void)
|
||||
{
|
||||
uiGroup *group;
|
||||
|
||||
handler.ah.Draw = handlerDraw;
|
||||
handler.ah.MouseEvent = handlerMouseEvent;
|
||||
handler.ah.MouseCrossed = handlerMouseCrossed;
|
||||
handler.ah.DragBroken = handlerDragBroken;
|
||||
handler.ah.KeyEvent = handlerKeyEvent;
|
||||
|
||||
group = newGroup("Scrolling Drawing Test");
|
||||
|
||||
area = uiNewScrollingArea((uiAreaHandler *) (&handler),
|
||||
areaSize, areaSize);
|
||||
uiGroupSetChild(group, uiControl(area));
|
||||
|
||||
return group;
|
||||
}
|
|
@ -63,5 +63,8 @@ extern uiGroup *makePage7a(void);
|
|||
// page7b.c
|
||||
extern uiGroup *makePage7b(void);
|
||||
|
||||
// page7c.c
|
||||
extern uiGroup *makePage7c(void);
|
||||
|
||||
// page8.c
|
||||
extern uiBox *makePage8(void);
|
||||
|
|
Loading…
Reference in New Issue