[qwaq] Fix TableView's scrolling

This commit is contained in:
Bill Currie 2021-09-25 02:14:26 +09:00
parent 0a60f46a64
commit 0df16fb210
5 changed files with 130 additions and 1 deletions

View file

@ -6,9 +6,11 @@
#include "ruamoko/qwaq/debugger/debug.h"
@class DefView;
@class ListenerGroup;
@interface LocalsData : Object <TableViewDataSource>
{
ListenerGroup *onRowCountChanged;
qdb_target_t target;
qfot_type_encodings_t target_encodings;
unsigned current_fnum;

View file

@ -4,6 +4,7 @@
#include "ruamoko/qwaq/debugger/views/defview.h"
#include "ruamoko/qwaq/debugger/views/nameview.h"
#include "ruamoko/qwaq/debugger/localsdata.h"
#include "ruamoko/qwaq/ui/listener.h"
@implementation LocalsData
@ -18,6 +19,7 @@
qdb_get_data (target, encodings_def.offset, sizeof(target_encodings),
&target_encodings);
self.onRowCountChanged = [[ListenerGroup listener] retain];
return self;
}
@ -42,6 +44,7 @@ free_defs (LocalsData *self)
-(void)dealloc
{
[onRowCountChanged release];
if (defs) {
free_defs (self);
}
@ -56,7 +59,7 @@ free_defs (LocalsData *self)
if (current_fnum == fnum) {
return self;
}
current_fnum =fnum;
current_fnum = fnum;
if (defs) {
free_defs (self);
@ -82,6 +85,7 @@ free_defs (LocalsData *self)
}
prefixsum (def_rows, aux_func.num_locals + 1);
}
[onRowCountChanged respond:self];
return self;
}
@ -90,6 +94,7 @@ free_defs (LocalsData *self)
if (data && func.local_size && func.local_data) {
qdb_get_data (target, func.local_data, func.local_size, data);
}
int rowCount = def_rows[aux_func.num_locals];
if (aux_func) {
def_rows[0] = 0;
for (int i = 0; i < aux_func.num_locals; i++) {
@ -98,9 +103,17 @@ free_defs (LocalsData *self)
}
prefixsum (def_rows, aux_func.num_locals + 1);
}
if (rowCount != def_rows[aux_func.num_locals]) {
[onRowCountChanged respond:self];
}
return self;
}
-(ListenerGroup *)onRowCountChanged
{
return onRowCountChanged;
}
-(int)numberOfRows:(TableView *)tableview
{
if (aux_func) {

View file

@ -228,6 +228,11 @@ page (ScrollBar *self, Point pos, Point thumb)
-setRange:(unsigned)range
{
self.range = range;
if (index > range) {
index = range;
[onScrollBarModified respond:self];
position_tab (self);
}
return self;
}

View file

@ -7,8 +7,10 @@
@class TableView;
@class TableViewColumn;
@class Array;
@class ListenerGroup;
@protocol TableViewDataSource
-(ListenerGroup *)onRowCountChanged;
-(int)numberOfRows:(TableView *)tableview;
-(View *)tableView:(TableView *)tableView
forColumn:(TableViewColumn *)column

View file

@ -1,5 +1,6 @@
#include <Array.h>
#include "ruamoko/qwaq/ui/listener.h"
#include "ruamoko/qwaq/ui/scrollbar.h"
#include "ruamoko/qwaq/ui/tableview.h"
@implementation TableViewColumn
@ -97,9 +98,16 @@
-setDataSource:(id<TableViewDataSource>)dataSource
{
self.dataSource = [dataSource retain];
[[dataSource onRowCountChanged] addListener:self
:@selector(onRowCountChanged:)];
return self;
}
-(void)onRowCountChanged:(id)sender
{
[vScrollBar setRange:[sender numberOfRows:self]];
}
-resize:(Extent)delta
{
Extent size = self.size;
@ -143,4 +151,103 @@
}
}
static int
handleEvent (TableView *self, qwaq_event_t *event)
{
if (event.what & qe_mouse) {
if (event.what == qe_mouseclick) {
if (event.mouse.buttons & (1 << 3)) {
[self.vScrollBar page:1 dir:0];
return 1;
}
if (event.mouse.buttons & (1 << 4)) {
[self.vScrollBar page:1 dir:1];
return 1;
}
#if 0
if (event.mouse.buttons & (1 << 5)) {
[self scrollLeft: 1];
return 1;
}
if (event.mouse.buttons & (1 << 6)) {
[self scrollRight: 1];
return 1;
}
#endif
}
} else if (event.what == qe_keydown) {
#if 0
switch (event.key.code) {
case QFK_PAGEUP:
if (event.key.shift & qe_control) {
[self moveBOT];
} else {
[self pageUp];
}
return 1;
case QFK_PAGEDOWN:
if (event.key.shift & qe_control) {
[self moveEOT];
} else {
[self pageDown];
}
return 1;
case QFK_UP:
if (event.key.shift & qe_control) {
[self linesUp];
} else {
[self charUp];
}
return 1;
case QFK_DOWN:
if (event.key.shift & qe_control) {
[self linesDown];
} else {
[self charDown];
}
return 1;
case QFK_LEFT:
if (event.key.shift & qe_control) {
[self wordLeft];
} else {
[self charLeft];
}
return 1;
case QFK_RIGHT:
if (event.key.shift & qe_control) {
[self wordRight];
} else {
[self charRight];
}
return 1;
case QFK_HOME:
if (event.key.shift & qe_control) {
[self moveBOS];
} else {
[self moveBOL];
}
return 1;
case QFK_END:
if (event.key.shift & qe_control) {
[self moveEOS];
} else {
[self moveEOL];
}
return 1;
}
#endif
}
return 0;
}
-handleEvent:(qwaq_event_t *) event
{
[super handleEvent: event];
if (handleEvent (self, event)) {
event.what = qe_none;
}
return self;
}
@end