Added a test of mouse events in a scrolled uiArea. Removed some dead code from the GTK+ uiArea. Now to make the changes to the Windows and OS X backends!
This commit is contained in:
parent
6b2d9920c5
commit
2ce0c810f1
|
@ -12,6 +12,7 @@ CFILES += \
|
||||||
test/page6.c \
|
test/page6.c \
|
||||||
test/page7.c \
|
test/page7.c \
|
||||||
test/page7a.c \
|
test/page7a.c \
|
||||||
|
test/page7b.c \
|
||||||
test/spaced.c
|
test/spaced.c
|
||||||
|
|
||||||
HFILES += \
|
HFILES += \
|
||||||
|
|
|
@ -5,11 +5,20 @@ uiBox *makePage7(void)
|
||||||
{
|
{
|
||||||
uiBox *page7;
|
uiBox *page7;
|
||||||
uiGroup *group;
|
uiGroup *group;
|
||||||
|
uiBox *box2;
|
||||||
|
|
||||||
page7 = newHorizontalBox();
|
page7 = newHorizontalBox();
|
||||||
|
|
||||||
group = makePage7a();
|
group = makePage7a();
|
||||||
uiBoxAppend(page7, uiControl(group), 1);
|
uiBoxAppend(page7, uiControl(group), 1);
|
||||||
|
|
||||||
|
box2 = newVerticalBox();
|
||||||
|
uiBoxAppend(page7, uiControl(box2), 1);
|
||||||
|
|
||||||
|
group = makePage7b();
|
||||||
|
uiBoxAppend(box2, uiControl(group), 1);
|
||||||
|
|
||||||
|
uiBoxAppend(box2, uiControl(uiNewLabel("")), 1);
|
||||||
|
|
||||||
return page7;
|
return page7;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
// 13 october 2015
|
||||||
|
#include "test.h"
|
||||||
|
|
||||||
|
static uiArea *area;
|
||||||
|
static uiCheckbox *label;
|
||||||
|
|
||||||
|
struct handler {
|
||||||
|
uiAreaHandler ah;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct handler handler;
|
||||||
|
|
||||||
|
static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *p)
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handlerMouseEvent(uiAreaHandler *a, uiArea *area, uiAreaMouseEvent *e)
|
||||||
|
{
|
||||||
|
char pos[128];
|
||||||
|
|
||||||
|
snprintf(pos, 127, "X %g Y %g", e->X, e->Y);
|
||||||
|
uiCheckboxSetText(label, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handlerMouseCrossed(uiAreaHandler *ah, uiArea *a, int left)
|
||||||
|
{
|
||||||
|
uiCheckboxSetChecked(label, !left);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 *makePage7b(void)
|
||||||
|
{
|
||||||
|
uiGroup *group;
|
||||||
|
uiBox *box;
|
||||||
|
|
||||||
|
handler.ah.Draw = handlerDraw;
|
||||||
|
handler.ah.MouseEvent = handlerMouseEvent;
|
||||||
|
handler.ah.MouseCrossed = handlerMouseCrossed;
|
||||||
|
handler.ah.DragBroken = handlerDragBroken;
|
||||||
|
handler.ah.KeyEvent = handlerKeyEvent;
|
||||||
|
|
||||||
|
group = newGroup("Scrolling Mouse Test");
|
||||||
|
|
||||||
|
box = newVerticalBox();
|
||||||
|
uiGroupSetChild(group, uiControl(box));
|
||||||
|
|
||||||
|
area = uiNewScrollingArea((uiAreaHandler *) (&handler), 5000, 5000);
|
||||||
|
uiBoxAppend(box, uiControl(area), 1);
|
||||||
|
|
||||||
|
label = uiNewCheckbox("");
|
||||||
|
uiBoxAppend(box, uiControl(label), 0);
|
||||||
|
|
||||||
|
return group;
|
||||||
|
}
|
|
@ -60,5 +60,8 @@ extern uiBox *makePage7(void);
|
||||||
// page7a.c
|
// page7a.c
|
||||||
extern uiGroup *makePage7a(void);
|
extern uiGroup *makePage7a(void);
|
||||||
|
|
||||||
|
// page7b.c
|
||||||
|
extern uiGroup *makePage7b(void);
|
||||||
|
|
||||||
// page8.c
|
// page8.c
|
||||||
extern uiBox *makePage8(void);
|
extern uiBox *makePage8(void);
|
||||||
|
|
10
unix/area.c
10
unix/area.c
|
@ -64,16 +64,6 @@ static void areaWidget_init(areaWidget *aw)
|
||||||
GDK_ENTER_NOTIFY_MASK |
|
GDK_ENTER_NOTIFY_MASK |
|
||||||
GDK_LEAVE_NOTIFY_MASK);
|
GDK_LEAVE_NOTIFY_MASK);
|
||||||
|
|
||||||
// TODO are these still needed?
|
|
||||||
/*
|
|
||||||
// for scrolling
|
|
||||||
// TODO do we need GDK_TOUCH_MASK?
|
|
||||||
gtk_widget_add_events(GTK_WIDGET(aw),
|
|
||||||
GDK_SCROLL_MASK |
|
|
||||||
GDK_TOUCH_MASK |
|
|
||||||
GDK_SMOOTH_SCROLL_MASK);
|
|
||||||
*/
|
|
||||||
|
|
||||||
gtk_widget_set_can_focus(GTK_WIDGET(aw), TRUE);
|
gtk_widget_set_can_focus(GTK_WIDGET(aw), TRUE);
|
||||||
|
|
||||||
clickCounterReset(&(aw->cc));
|
clickCounterReset(&(aw->cc));
|
||||||
|
|
Loading…
Reference in New Issue