mirror of
https://github.com/weiju/amiga-stuff
synced 2025-11-23 19:01:45 +00:00
figured out the small details about the slider
fixed the VertPot setting, smoothened the drag update rate
This commit is contained in:
@ -25,6 +25,16 @@
|
|||||||
|
|
||||||
#define NUM_FILE_ENTRIES 10
|
#define NUM_FILE_ENTRIES 10
|
||||||
|
|
||||||
|
/*
|
||||||
|
this is the wait time between handling mouse drag
|
||||||
|
events of the vslider, 50ms will roughly result in
|
||||||
|
20 updates/redraws per second which is fairly smooth
|
||||||
|
*/
|
||||||
|
#define VSLIDER_UPDATE_MS 50
|
||||||
|
|
||||||
|
// *********************
|
||||||
|
// This is essentially the requester's state, should actually be a struct
|
||||||
|
|
||||||
static int filelist_width;
|
static int filelist_width;
|
||||||
static int filelist_height;
|
static int filelist_height;
|
||||||
static int filelist_bm_width;
|
static int filelist_bm_width;
|
||||||
@ -40,6 +50,8 @@ static int slider_increment;
|
|||||||
*/
|
*/
|
||||||
static struct FileListEntry *first_visible_entry;
|
static struct FileListEntry *first_visible_entry;
|
||||||
|
|
||||||
|
// *********************
|
||||||
|
|
||||||
enum { LABEL_DRAWER = 0, LABEL_FILE, LABEL_PARENT, LABEL_DRIVES, LABEL_OPEN, LABEL_CANCEL } Labels;
|
enum { LABEL_DRAWER = 0, LABEL_FILE, LABEL_PARENT, LABEL_DRIVES, LABEL_OPEN, LABEL_CANCEL } Labels;
|
||||||
|
|
||||||
#define REQ_HEIGHT 175
|
#define REQ_HEIGHT 175
|
||||||
@ -255,7 +267,7 @@ int vertpot2entry(int vertpot)
|
|||||||
else if ((num_current_files - index) < NUM_FILE_ENTRIES) {
|
else if ((num_current_files - index) < NUM_FILE_ENTRIES) {
|
||||||
final_index = num_current_files - NUM_FILE_ENTRIES;
|
final_index = num_current_files - NUM_FILE_ENTRIES;
|
||||||
}
|
}
|
||||||
printf("computed index: %d, final index: %d\n", index, final_index);
|
//printf("computed index: %d, final index: %d\n", index, final_index);
|
||||||
return final_index;
|
return final_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,7 +370,7 @@ static void handle_events()
|
|||||||
} else {
|
} else {
|
||||||
CurrentTime(&seconds, µs);
|
CurrentTime(&seconds, µs);
|
||||||
ULONG diff = (seconds - last_seconds) * 1000 + (micros - last_micros) / 1000;
|
ULONG diff = (seconds - last_seconds) * 1000 + (micros - last_micros) / 1000;
|
||||||
if (diff > 300) {
|
if (diff > VSLIDER_UPDATE_MS) {
|
||||||
// update the list, but ignore most of the move events,
|
// update the list, but ignore most of the move events,
|
||||||
// otherwise the we need to process too many events and
|
// otherwise the we need to process too many events and
|
||||||
// refresh too often
|
// refresh too often
|
||||||
@ -418,8 +430,8 @@ static void handle_events()
|
|||||||
case VSLIDER_ID:
|
case VSLIDER_ID:
|
||||||
// determine the portion to be displayed
|
// determine the portion to be displayed
|
||||||
idx = vertpot2entry(propinfo.VertPot);
|
idx = vertpot2entry(propinfo.VertPot);
|
||||||
printf("gadget up, vslider, vertpot: %d, incr: %d, idx: %d\n",
|
//printf("gadget up, vslider, vertpot: %d, incr: %d, idx: %d\n",
|
||||||
(int) propinfo.VertPot, slider_increment, idx);
|
// (int) propinfo.VertPot, slider_increment, idx);
|
||||||
movestart = FALSE;
|
movestart = FALSE;
|
||||||
update_list(idx);
|
update_list(idx);
|
||||||
break;
|
break;
|
||||||
@ -538,8 +550,14 @@ void open_file(struct Window *window)
|
|||||||
// the body size by solving the equation
|
// the body size by solving the equation
|
||||||
// MAXBODY / vertbody = num_current_files / NUM_FILE_ENTRIES
|
// MAXBODY / vertbody = num_current_files / NUM_FILE_ENTRIES
|
||||||
vertbody = (MAXBODY * NUM_FILE_ENTRIES) / num_current_files;
|
vertbody = (MAXBODY * NUM_FILE_ENTRIES) / num_current_files;
|
||||||
slider_increment = (MAXBODY / num_current_files);
|
|
||||||
vertpot = select_index * slider_increment;
|
// this is surprisingly different that I thought:
|
||||||
|
// we need to compute the increment over the drag space not over
|
||||||
|
// the vslider space, so we can ignore the VertBody setting (in short
|
||||||
|
// VertPot and VertBody are independent)
|
||||||
|
slider_increment = MAXBODY / (num_current_files - NUM_FILE_ENTRIES);
|
||||||
|
vertpot = first_visible_entry->index * slider_increment;
|
||||||
|
printf("vpot: %d, vbody: %d inc: %d\n", vertpot, vertbody, slider_increment);
|
||||||
}
|
}
|
||||||
NewModifyProp(&list_vslider, req_window, &requester, AUTOKNOB | FREEVERT,
|
NewModifyProp(&list_vslider, req_window, &requester, AUTOKNOB | FREEVERT,
|
||||||
0, vertpot, MAXBODY, vertbody, 1);
|
0, vertpot, MAXBODY, vertbody, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user