mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +01:00
programmatic scroller changes send notifications
fixed bug with tableview resize made tableview column resizing
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
Changes since wmaker 0.64.0:
|
||||||
|
............................
|
||||||
|
|
||||||
|
- made programmatic scroller changes send notifications
|
||||||
|
|
||||||
changes since wmaker 0.63.1:
|
changes since wmaker 0.63.1:
|
||||||
............................
|
............................
|
||||||
- added WMRunModalLoop() and WMBreakModalLoop()
|
- added WMRunModalLoop() and WMBreakModalLoop()
|
||||||
|
|||||||
@@ -120,7 +120,6 @@ main(int argc, char **argv)
|
|||||||
WMSetTableColumnDelegate(col, colDeleg);
|
WMSetTableColumnDelegate(col, colDeleg);
|
||||||
WMSetTableColumnId(col, (void*)2);
|
WMSetTableColumnId(col, (void*)2);
|
||||||
|
|
||||||
|
|
||||||
colDeleg = WTCreateBooleanSwitchDelegate(table);
|
colDeleg = WTCreateBooleanSwitchDelegate(table);
|
||||||
|
|
||||||
col = WMCreateTableColumn("Bool");
|
col = WMCreateTableColumn("Bool");
|
||||||
|
|||||||
@@ -189,50 +189,80 @@ static void scrollObserver(void *self, WMNotification *notif)
|
|||||||
WMTableView *table = (WMTableView*)self;
|
WMTableView *table = (WMTableView*)self;
|
||||||
WMRect rect;
|
WMRect rect;
|
||||||
int i, x;
|
int i, x;
|
||||||
|
|
||||||
rect = WMGetScrollViewVisibleRect(table->scrollView);
|
rect = WMGetScrollViewVisibleRect(table->scrollView);
|
||||||
|
|
||||||
x = 0;
|
x = 0;
|
||||||
for (i = 0; i < WMGetArrayItemCount(table->columns); i++) {
|
for (i = 0; i < WMGetArrayItemCount(table->columns); i++) {
|
||||||
WMTableColumn *column;
|
WMTableColumn *column;
|
||||||
|
WMView *splitter;
|
||||||
|
|
||||||
column = WMGetFromArray(table->columns, i);
|
column = WMGetFromArray(table->columns, i);
|
||||||
|
|
||||||
WMMoveWidget(column->titleW, x - rect.pos.x, 0);
|
WMMoveWidget(column->titleW, x - rect.pos.x, 0);
|
||||||
|
|
||||||
if (i > 0) {
|
|
||||||
WMView *splitter;
|
|
||||||
|
|
||||||
splitter = WMGetFromArray(table->splitters, i-1);
|
|
||||||
W_MoveView(splitter, x - rect.pos.x - 1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
x += W_VIEW_WIDTH(WMWidgetView(column->titleW)) + 1;
|
x += W_VIEW_WIDTH(WMWidgetView(column->titleW)) + 1;
|
||||||
|
|
||||||
|
splitter = WMGetFromArray(table->splitters, i);
|
||||||
|
W_MoveView(splitter, x - rect.pos.x - 1, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void splitterHandler(XEvent *event, void *data)
|
static void splitterHandler(XEvent *event, void *data)
|
||||||
{
|
{
|
||||||
WMTableView *table = (WMTableView*)data;
|
WMTableColumn *column = (WMTableColumn*)data;
|
||||||
|
WMTableView *table = column->table;
|
||||||
int done = 0;
|
int done = 0;
|
||||||
|
int cx, ox, offsX;
|
||||||
|
WMPoint pos;
|
||||||
|
WMScreen *scr = WMWidgetScreen(table);
|
||||||
|
GC gc = scr->ixorGC;
|
||||||
|
Display *dpy = WMScreenDisplay(scr);
|
||||||
|
int h = WMWidgetHeight(table) - 22;
|
||||||
|
Window w = WMViewXID(table->view);
|
||||||
|
|
||||||
|
pos = WMGetViewPosition(WMWidgetView(column->titleW));
|
||||||
|
|
||||||
|
offsX = pos.x + column->width;
|
||||||
|
|
||||||
|
ox = cx = offsX;
|
||||||
|
|
||||||
|
XDrawLine(dpy, w, gc, cx+20, 0, cx+20, h);
|
||||||
|
|
||||||
while (!done) {
|
while (!done) {
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
WMMaskEvent(event->xany.display, ButtonMotionMask|ButtonReleaseMask,
|
WMMaskEvent(dpy, ButtonMotionMask|ButtonReleaseMask, &ev);
|
||||||
&ev);
|
|
||||||
|
switch (ev.type) {
|
||||||
switch (event->type) {
|
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
printf("%i\n", event->xmotion.x);
|
ox = cx;
|
||||||
break;
|
if (column->width + ev.xmotion.x < column->minWidth)
|
||||||
|
cx = pos.x + column->minWidth;
|
||||||
|
else
|
||||||
|
cx = offsX + ev.xmotion.x;
|
||||||
|
|
||||||
|
if (column->maxWidth > 0) {
|
||||||
|
if (column->width + ev.xmotion.x > column->maxWidth)
|
||||||
|
cx = pos.x + column->maxWidth;
|
||||||
|
else
|
||||||
|
cx = offsX + ev.xmotion.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
XDrawLine(dpy, w, gc, ox+20, 0, ox+20, h);
|
||||||
|
XDrawLine(dpy, w, gc, cx+20, 0, cx+20, h);
|
||||||
|
break;
|
||||||
|
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
|
column->width = cx - pos.x;
|
||||||
|
rearrangeHeader(table);
|
||||||
done = 1;
|
done = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XDrawLine(dpy, w, gc, cx+20, 0, cx+20, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -294,8 +324,6 @@ WMTableView *WMCreateTableView(WMWidget *parent)
|
|||||||
W_ResizeView(table->tableView, 100, 1000);
|
W_ResizeView(table->tableView, 100, 1000);
|
||||||
W_MapView(table->tableView);
|
W_MapView(table->tableView);
|
||||||
|
|
||||||
WMSetScrollViewContentView(table->scrollView, table->tableView);
|
|
||||||
|
|
||||||
table->tableView->flags.dontCompressExpose = 1;
|
table->tableView->flags.dontCompressExpose = 1;
|
||||||
|
|
||||||
table->gridColor = WMCreateNamedColor(scr, "#cccccc", False);
|
table->gridColor = WMCreateNamedColor(scr, "#cccccc", False);
|
||||||
@@ -337,6 +365,8 @@ WMTableView *WMCreateTableView(WMWidget *parent)
|
|||||||
WMCreateEventHandler(table->tableView, ExposureMask|ButtonPressMask|
|
WMCreateEventHandler(table->tableView, ExposureMask|ButtonPressMask|
|
||||||
ButtonReleaseMask|ButtonMotionMask,
|
ButtonReleaseMask|ButtonMotionMask,
|
||||||
handleTableEvents, table);
|
handleTableEvents, table);
|
||||||
|
|
||||||
|
WMSetScrollViewContentView(table->scrollView, table->tableView);
|
||||||
|
|
||||||
return table;
|
return table;
|
||||||
|
|
||||||
@@ -377,9 +407,9 @@ void WMAddTableViewColumn(WMTableView *table, WMTableColumn *column)
|
|||||||
WMMapWidget(column->titleW);
|
WMMapWidget(column->titleW);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WMGetArrayItemCount(table->columns) > 1) {
|
{
|
||||||
WMView *splitter = W_CreateView(WMWidgetView(table->header));
|
WMView *splitter = W_CreateView(WMWidgetView(table->header));
|
||||||
|
|
||||||
W_SetViewBackgroundColor(splitter, WMWhiteColor(scr));
|
W_SetViewBackgroundColor(splitter, WMWhiteColor(scr));
|
||||||
|
|
||||||
if (W_VIEW_REALIZED(table->view))
|
if (W_VIEW_REALIZED(table->view))
|
||||||
@@ -387,10 +417,10 @@ void WMAddTableViewColumn(WMTableView *table, WMTableColumn *column)
|
|||||||
|
|
||||||
W_ResizeView(splitter, 2, table->headerHeight-1);
|
W_ResizeView(splitter, 2, table->headerHeight-1);
|
||||||
W_MapView(splitter);
|
W_MapView(splitter);
|
||||||
|
|
||||||
W_SetViewCursor(splitter, table->splitterCursor);
|
W_SetViewCursor(splitter, table->splitterCursor);
|
||||||
WMCreateEventHandler(splitter, ButtonPressMask,
|
WMCreateEventHandler(splitter, ButtonPressMask|ButtonReleaseMask,
|
||||||
splitterHandler, table);
|
splitterHandler, column);
|
||||||
|
|
||||||
WMAddToArray(table->splitters, splitter);
|
WMAddToArray(table->splitters, splitter);
|
||||||
}
|
}
|
||||||
@@ -924,22 +954,21 @@ static void rearrangeHeader(WMTableView *table)
|
|||||||
{
|
{
|
||||||
int width;
|
int width;
|
||||||
int count;
|
int count;
|
||||||
int i;
|
int i;
|
||||||
|
WMRect rect = WMGetScrollViewVisibleRect(table->scrollView);
|
||||||
|
|
||||||
width = 0;
|
width = 0;
|
||||||
|
|
||||||
count = WMGetArrayItemCount(table->columns);
|
count = WMGetArrayItemCount(table->columns);
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
WMTableColumn *column = WMGetFromArray(table->columns, i);
|
WMTableColumn *column = WMGetFromArray(table->columns, i);
|
||||||
|
WMView *splitter = WMGetFromArray(table->splitters, i);
|
||||||
|
|
||||||
WMMoveWidget(column->titleW, width, 0);
|
WMMoveWidget(column->titleW, width, 0);
|
||||||
WMResizeWidget(column->titleW, column->width-1, table->headerHeight);
|
WMResizeWidget(column->titleW, column->width-1, table->headerHeight);
|
||||||
|
|
||||||
if (i > 0) {
|
|
||||||
WMView *splitter = WMGetFromArray(table->splitters, i-1);
|
|
||||||
|
|
||||||
W_MoveView(splitter, width-1, 0);
|
|
||||||
}
|
|
||||||
width += column->width;
|
width += column->width;
|
||||||
|
W_MoveView(splitter, width-1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
wassertr(table->delegate && table->delegate->numberOfRows);
|
wassertr(table->delegate && table->delegate->numberOfRows);
|
||||||
@@ -948,6 +977,6 @@ static void rearrangeHeader(WMTableView *table)
|
|||||||
|
|
||||||
W_ResizeView(table->tableView, width+1,
|
W_ResizeView(table->tableView, width+1,
|
||||||
table->rows * table->rowHeight + 1);
|
table->rows * table->rowHeight + 1);
|
||||||
|
|
||||||
table->tableWidth = width + 1;
|
table->tableWidth = width + 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,6 +194,8 @@ WMSetScrollerParameters(WMScroller *sPtr, float floatValue,
|
|||||||
|
|
||||||
if (sPtr->view->flags.realized)
|
if (sPtr->view->flags.realized)
|
||||||
paintScroller(sPtr);
|
paintScroller(sPtr);
|
||||||
|
|
||||||
|
WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -120,6 +120,8 @@ applyScrollerValues(WMScrollView *sPtr)
|
|||||||
y = 0;
|
y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
x = WMAX(0, x);
|
x = WMAX(0, x);
|
||||||
y = WMAX(0, y);
|
y = WMAX(0, y);
|
||||||
|
|
||||||
@@ -551,9 +553,17 @@ updateScrollerProportion(ScrollView *sPtr)
|
|||||||
float prop, value;
|
float prop, value;
|
||||||
|
|
||||||
if (sPtr->flags.hasHScroller) {
|
if (sPtr->flags.hasHScroller) {
|
||||||
prop = (float)sPtr->viewport->size.width/sPtr->contentView->size.width;
|
float oldV, oldP;
|
||||||
value = WMGetScrollerValue(sPtr->hScroller);
|
|
||||||
|
|
||||||
|
oldV = WMGetScrollerValue(sPtr->hScroller);
|
||||||
|
oldP = WMGetScrollerKnobProportion(sPtr->hScroller);
|
||||||
|
|
||||||
|
prop = (float)sPtr->viewport->size.width/sPtr->contentView->size.width;
|
||||||
|
|
||||||
|
if (oldP == 1.0)
|
||||||
|
value = 0;
|
||||||
|
else
|
||||||
|
value = (prop * oldV) / oldP;
|
||||||
WMSetScrollerParameters(sPtr->hScroller, value, prop);
|
WMSetScrollerParameters(sPtr->hScroller, value, prop);
|
||||||
}
|
}
|
||||||
if (sPtr->flags.hasVScroller) {
|
if (sPtr->flags.hasVScroller) {
|
||||||
@@ -563,6 +573,7 @@ updateScrollerProportion(ScrollView *sPtr)
|
|||||||
|
|
||||||
WMSetScrollerParameters(sPtr->vScroller, value, prop);
|
WMSetScrollerParameters(sPtr->vScroller, value, prop);
|
||||||
}
|
}
|
||||||
|
applyScrollerValues(sPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user