Commit 57071f9e authored by Robert Sprowson's avatar Robert Sprowson
Browse files

ScrollList gadget redraw fixes

When _set_colour() is called, remember to redraw the gadget if the colours changed.
When _set_font() is called, remember to redraw the gadget and try to preserve the scroll bar positions.
Save a couple of SWIs if we know the scroll bars must jump in 2 other places.
Remove ScrollLisS, its (never called) function did nothing but return.
Removed duplicate redraw_box, same as redraw_all_box and marked as const.

Reported by Fred Graute, reference
  https://www.riscosopen.org/forum/forums/4/topics/3628
the memory leak aspects of the report have been transferred to ticket #414 for later consideration.
Tested with !ExifEdit and some special versions from Fred with the redraw workarounds removed.

Version 0.39. Tagged as 'Gadgets-0_39'
parent f4fe9155
......@@ -19,7 +19,7 @@ COMPONENT = Gadgets
TARGET ?= TextGadget
OBJS = glib glib3 main MemMan riscos_uti Scrollbar\
ScrollList Sizes TextArea TextMan Font riscos_gra\
ScrollLisS TAsel_ven Utils
TAsel_ven Utils
CMHGDEPENDS = main
ROMCDEFINES = -DROM
CINCLUDES = -IC:tboxlibint,tbox:,C:
......
/* (0.38)
/* (0.39)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.38
#define Module_MajorVersion_CMHG 0.39
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 18 Aug 2015
#define Module_Date_CMHG 12 Oct 2015
#define Module_MajorVersion "0.38"
#define Module_Version 38
#define Module_MajorVersion "0.39"
#define Module_Version 39
#define Module_MinorVersion ""
#define Module_Date "18 Aug 2015"
#define Module_Date "12 Oct 2015"
#define Module_ApplicationDate "18-Aug-15"
#define Module_ApplicationDate "12-Oct-15"
#define Module_ComponentName "Gadgets"
#define Module_ComponentPath "castle/RiscOS/Sources/Toolbox/Gadgets"
#define Module_FullVersion "0.38"
#define Module_HelpVersion "0.38 (18 Aug 2015)"
#define Module_LibraryVersionInfo "0:38"
#define Module_FullVersion "0.39"
#define Module_HelpVersion "0.39 (12 Oct 2015)"
#define Module_LibraryVersionInfo "0:39"
......@@ -72,11 +72,14 @@ static unsigned int vscroll_width = SCROLLBAR_SIZE;
static PrivateScrollList **scrolllist_list = NULL;
// Cannot be a const, 'cos of the stupid blimmin' tbox header files
static wimp_Bbox redraw_box = {0, -0xffff, 0xffff, 0};
static const wimp_Bbox redraw_all_box = {0, -0xffff, 0xffff, 0};
static _kernel_oserror *_make_visible(const PrivateScrollList *sdata,
int visible);
static _kernel_oserror *_scrolllist_redraw(const PrivateScrollList *sdata,
WindowRedraw *block, wimp_Bbox *box,
unsigned int sprite_width,
unsigned int item_height, int base_line);
static const WindowTemplate window_template =
{
......@@ -140,8 +143,6 @@ static /* const */ ObjectTemplateHeader scroll_list_window =
sizeof(WindowTemplate) // body_size
};
static wimp_Bbox redraw_all_box = {0, -0xffff, 0xffff, 0};
_kernel_oserror *scrolllist_init(void)
{
scroll_list_window.body = (void*) &window_template;
......@@ -548,6 +549,8 @@ _kernel_oserror *scrolllist_remove(PrivateScrollList *handle)
static _kernel_oserror *_set_colour(PrivateScrollList *handle,
unsigned int flags, unsigned int foreground, unsigned int background)
{
BOOL changed;
if (flags | ScrollList_DesktopColours == flags)
{
// Need to translate desktop colours to real colours
......@@ -560,9 +563,18 @@ static _kernel_oserror *_set_colour(PrivateScrollList *handle,
foreground = palette.colours[foreground] & ~0xff;
background = palette.colours[background] & ~0xff;
}
changed = (handle->foreground != foreground) ||
(handle->background != background);
handle->foreground = foreground;
handle->background = background;
if (changed)
{
// Redraw, given colour change
_swix(Toolbox_ObjectMiscOp, _INR(0,3),
0, handle->object_id, Window_ForceRedraw, &redraw_all_box);
}
return NULL;
}
......@@ -666,9 +678,12 @@ static _kernel_oserror *_add_item(PrivateScrollList *sdata,
sdata->no_entries++;
// Remember existing window details
window_get_wimp_handle(0, sdata->object_id, &state.open.window_handle);
wimp_get_window_state(&state);
if (!(flags & ScrollList_AddItem_MakeVisible))
{
// Remember existing window details
window_get_wimp_handle(0, sdata->object_id, &state.open.window_handle);
wimp_get_window_state(&state);
}
// Update window extent (this scrolls to the top of the display too)
_show(sdata);
......@@ -695,10 +710,9 @@ static _kernel_oserror *_add_item(PrivateScrollList *sdata,
}
}
// scrolllist_update(sdata, sdata->box.xmin, sdata->box.ymin,
// sdata->box.xmax - vscroll_width, sdata->box.ymax);
// Redraw, given addition
_swix(Toolbox_ObjectMiscOp, _INR(0,3),
0, sdata->object_id, Window_ForceRedraw, &redraw_box);
0, sdata->object_id, Window_ForceRedraw, &redraw_all_box);
return NULL;
}
......@@ -763,10 +777,12 @@ static _kernel_oserror *_delete_items(PrivateScrollList *sdata,
sdata->no_entries -= end - start + 1;
// Remember existing window details
window_get_wimp_handle(0, sdata->object_id, &state.open.window_handle);
wimp_get_window_state(&state);
if (flags & ScrollList_DeleteItems_DoNotJumpToTop)
{
// Remember existing window details
window_get_wimp_handle(0, sdata->object_id, &state.open.window_handle);
wimp_get_window_state(&state);
}
// Update window extent (this scrolls to the top of the display too)
_show(sdata);
......@@ -785,10 +801,9 @@ static _kernel_oserror *_delete_items(PrivateScrollList *sdata,
}
}
// scrolllist_update(sdata, sdata->box.xmin, sdata->box.ymin,
// sdata->box.xmax - vscroll_width, sdata->box.ymax);
// Redraw, given deletion
_swix(Toolbox_ObjectMiscOp, _INR(0,3),
0, sdata->object_id, Window_ForceRedraw, &redraw_box);
0, sdata->object_id, Window_ForceRedraw, &redraw_all_box);
if (flags & ScrollList_SelectionChangingMethod_SendEvent)
return _send_selection_event(sdata, 0, -1);
......@@ -911,6 +926,7 @@ static _kernel_oserror *_set_font(PrivateScrollList *sdata,
unsigned int width, unsigned int height)
{
_kernel_oserror *e;
wimp_GetWindowState state;
if (sdata->font_handle != 0)
{
......@@ -941,8 +957,30 @@ static _kernel_oserror *_set_font(PrivateScrollList *sdata,
}
}
scrolllist_update(sdata, sdata->box.xmin, sdata->box.ymin,
sdata->box.xmax - vscroll_width, sdata->box.ymax);
// Remember existing window details
window_get_wimp_handle(0, sdata->object_id, &state.open.window_handle);
wimp_get_window_state(&state);
// Update window extent (this scrolls to the top of the display too)
_show(sdata);
if (1)
{
int x = state.open.scx, y = state.open.scy;
// Restore scroll position
if (!wimp_get_window_state(&state))
{
state.open.scx = x;
state.open.scy = y;
wimp_open_window((wimp_OpenWindow *) &state);
}
}
// Redraw, given font change
_swix(Toolbox_ObjectMiscOp, _INR(0,3),
0, sdata->object_id, Window_ForceRedraw, &redraw_all_box);
return NULL;
}
......@@ -1137,8 +1175,6 @@ _kernel_oserror *scrolllist_method(PrivateScrollList *sdata,
case ScrollList_SetColour:
// R4 = foreground col, R5 = background col
e = _set_colour(sdata, regs->r[0], regs->r[4], regs->r[5]);
scrolllist_update(sdata, sdata->box.xmin, sdata->box.ymin,
sdata->box.xmax - vscroll_width, sdata->box.ymax);
break;
case ScrollList_GetColour:
......@@ -1255,7 +1291,7 @@ _kernel_oserror *scrolllist_plot(ScrollList *sdata)
return NULL;
}
_kernel_oserror *_scrolllist_redraw(const PrivateScrollList *sdata,
static _kernel_oserror *_scrolllist_redraw(const PrivateScrollList *sdata,
WindowRedraw *block, wimp_Bbox *box,
unsigned int sprite_width,
unsigned int item_height, int base_line)
......
......@@ -50,17 +50,6 @@ typedef struct {
unsigned int visible;
} PrivateScrollList;
/* Used in ScrollLisS.s */
_kernel_oserror *_scrolllist_redraw(const PrivateScrollList *sdata,
WindowRedraw *block, wimp_Bbox *box,
unsigned int max_sprite_width,
unsigned int max_height,
int base_line);
/* Implemented in ScrollLisS.s */
_kernel_oserror *scrolllist_update(PrivateScrollList *sdata,
int xmin, int ymin, int xmax, int ymax);
/* Others */
int scrolllist_active(void);
_kernel_oserror *scrolllist_init(void);
......
; Copyright 1997 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; ScrollList assember functions
; History: PW: 09-Aug-96: Created
AREA |C$$code|, CODE, READONLY
GET hdr:ListOpts
GET hdr:Macros
GET Hdr:System
GET Hdr:APCS.<APCS>
; APCS compliant
; SVC mode compatible (link register stacked)
; Updates a scrolling list gadget
; Prototype: _kernel_oserror *scrolllist_update(PrivateScrollList *sdata,
; int xmin, int ymin, int xmax, int ymax);
; On entry: r0 = sdata
; r1 = xmin
; r2 = ymin
; r3 = xmax
; [ip, #0] = ymax
scrolllist_update
EXPORT scrolllist_update
[ {TRUE}
Return ,LinkNotStacked
|
mov ip, sp
stmfd sp!, {r4, lr}
ldr r4, [ip]
sub sp, sp, #40
stmia sp, {r1-r4} ; Store redraw coords
sub sp, sp, #4
ldr r1, [r0, #12] ; Load window handle
str r1, [sp] ; Store window handle
mov r4, r0 ; r4 == sdata
mov r1, sp
swi XWimp_UpdateWindow
Return "r4",,VS
redraw_loop
teq r0, #0
addeq sp, sp, #44
Return "r4",,EQ
mov r0, r4
bl _scrolllist_redraw
mov r1, sp
swi XWimp_GetRectangle
b redraw_loop
]
END
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment