Commit 3ed6d938 authored by Ben Avison's avatar Ben Avison
Browse files

Menu bugfixes and sprite variation support.

Detail:
  * Adjust clicking on menu items was leading to Message_MenusDeleted being
    broadcast, resulting in incorrect behaviour in many applications.
  * Sprite-only menu items (eg !Draw's line pattern submenu) now highlight
    correctly when tiled menus are configured.
  * Added Wimp_Extend 13, which works out the appropriate resolution suffix
    for a given sprite pathname - required since Sprites11 support needs
    an iterative approach. This supercedes Wimp_ReadSysInfo 2.
  * *IconSprites now tries prefixing the last element of its path argument
    with "<Wimp$IconTheme>".
Admin:
  Tested on Tungsten.

Version 4.85. Tagged as 'Wimp-4_85'
parent 67775716
...@@ -11,13 +11,13 @@ ...@@ -11,13 +11,13 @@
GBLS Module_HelpVersion GBLS Module_HelpVersion
GBLS Module_ComponentName GBLS Module_ComponentName
GBLS Module_ComponentPath GBLS Module_ComponentPath
Module_MajorVersion SETS "4.84" Module_MajorVersion SETS "4.85"
Module_Version SETA 484 Module_Version SETA 485
Module_MinorVersion SETS "" Module_MinorVersion SETS ""
Module_Date SETS "20 Dec 2002" Module_Date SETS "17 Jan 2003"
Module_ApplicationDate SETS "20-Dec-02" Module_ApplicationDate SETS "17-Jan-03"
Module_ComponentName SETS "Wimp" Module_ComponentName SETS "Wimp"
Module_ComponentPath SETS "RiscOS/Sources/Desktop/Wimp" Module_ComponentPath SETS "RiscOS/Sources/Desktop/Wimp"
Module_FullVersion SETS "4.84" Module_FullVersion SETS "4.85"
Module_HelpVersion SETS "4.84 (20 Dec 2002)" Module_HelpVersion SETS "4.85 (17 Jan 2003)"
END END
/* (4.84) /* (4.85)
* *
* This file is automatically maintained by srccommit, do not edit manually. * This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.68. * Last processed by srccommit version: 1.68.
* *
*/ */
#define Module_MajorVersion_CMHG 4.84 #define Module_MajorVersion_CMHG 4.85
#define Module_MinorVersion_CMHG #define Module_MinorVersion_CMHG
#define Module_Date_CMHG 20 Dec 2002 #define Module_Date_CMHG 17 Jan 2003
#define Module_MajorVersion "4.84" #define Module_MajorVersion "4.85"
#define Module_Version 484 #define Module_Version 485
#define Module_MinorVersion "" #define Module_MinorVersion ""
#define Module_Date "20 Dec 2002" #define Module_Date "17 Jan 2003"
#define Module_ApplicationDate "20-Dec-02" #define Module_ApplicationDate "17-Jan-03"
#define Module_ComponentName "Wimp" #define Module_ComponentName "Wimp"
#define Module_ComponentPath "RiscOS/Sources/Desktop/Wimp" #define Module_ComponentPath "RiscOS/Sources/Desktop/Wimp"
#define Module_FullVersion "4.84" #define Module_FullVersion "4.85"
#define Module_HelpVersion "4.84 (20 Dec 2002)" #define Module_HelpVersion "4.85 (17 Jan 2003)"
#define Module_LibraryVersionInfo "4:84" #define Module_LibraryVersionInfo "4:85"
...@@ -317,6 +317,10 @@ SWIWimp_Extend ...@@ -317,6 +317,10 @@ SWIWimp_Extend
[ NCErrorBox [ NCErrorBox
TEQ R0,#12 TEQ R0,#12
BEQ %FT12 BEQ %FT12
]
[ Sprites11
TEQ R0,#13
BEQ %FT13
] ]
B ExitWimp B ExitWimp
...@@ -385,6 +389,80 @@ SWIWimp_Extend ...@@ -385,6 +389,80 @@ SWIWimp_Extend
B ExitWimp B ExitWimp
] ]
[ Sprites11
13 ; Work out for the client what resolution suffix to append to a sprites file
; First available in Wimp 4.85
; Older Wimps don't return error, but can be detected because all registers are preserved
; On entry:
; r0 = 13 (reason code)
; r1 -> pathname of file without suffix
; r2 -> buffer for result
; r3 = size of buffer (0 to read size required)
; On exit:
; r0 corrupted
; r3 = space left in buffer (ie negative of size required if r3=0 on entry)
; other registers preserved
; contents of buffer are only valid if r3>=0
; error "File not found" may be returned
MOV R0, R1
loop1 LDRB LR, [R0], #1
CMP LR, #32
BCS loop1
SUB R0, R0, R1 ; length of original string (incl terminator)
ADD R0, R0, #2 ; for the moment, we know the resultant string will be at most 2 bytes longer
SUBS R3, R3, R0
STR R3, [SP, #2*4] ; put result in stack frame
BMI ExitWimp ; exit now if buffer not big enough
loop2 LDRB LR, [R1], #1
CMP LR, #32
STRCSB LR, [R2], #1 ; copy string into buffer
BCS loop2
MOV LR, #0
STRB LR, [R2, #2] ; insert terminator after two more characters
LDRB R5, romspr_suffix
LDRB R6, romspr_suffix+1
SUB R5, R5, #'0'
SUB R6, R6, #'0'
loop3 ADD LR, R5, #'0'
STRB LR, [R2]
ADD LR, R6, #'0'
STRB LR, [R2, #1]
MOV R0, #&4C ; try opening a file on File$Path (matches *SLoad etc)
LDR R1, [SP, #1*4] ; retrieve pointer to start of buffer
SWI XOS_Find
MOVVC R1, R0
MOVVC R0, #0
SWIVC XOS_Find
BVC ExitWimp ; buffer contains a valid file, so exit
TEQ R6, #3
MOVEQ R6, #2
BEQ loop3 ; after Sprites23, try Sprites22
CMP R5, R6
MOVLO R5, R5, LSL #1
MOVHI R6, R6, LSL #1
BNE loop3 ; after rectangular pixels, try next squarer version
TEQ R5, #1
MOVEQ R5, #2
MOVEQ R6, #2
BEQ loop3 ; after Sprites11, try Sprites22
MOV LR, #0
STRB LR, [R2]
MOV R0, #&4C
LDR R1, [SP, #1*4]
SWI XOS_Find ; finally, try with no suffix
MOVVC R1, R0
MOVVC R0, #0
SWIVC XOS_Find
B ExitWimp ; return any error we got from this last one
]
extendjumptable extendjumptable
B getspriteaddr B getspriteaddr
[ CnP [ CnP
......
...@@ -2790,23 +2790,61 @@ greys_16 ...@@ -2790,23 +2790,61 @@ greys_16
; tries "<filename>23" if hi-res mono, and/or "<filename>22" if 2x2 OS units ; tries "<filename>23" if hi-res mono, and/or "<filename>22" if 2x2 OS units
IconSprites_Code IconSprites_Code
Push "R12,LR" [ Sprites11
Push "R7-R8,LR"
LDR wsptr,[R12] LDR wsptr,[R12]
; ;
[ Sprites11 MOV R8,R0 ; R8 -> original filename
MOV R3,R0 ; R3 -> original filename MOV R5,R0 ; R5 = position at which to insert system variable
LDRB R5,romspr_suffix 01 LDRB LR,[R0],#1 ; skip leading space
TEQ LR,#' '
BEQ %BT01
02 TEQ LR,#'.' ; remember last '.' or ':'
TEQNE LR,#':'
MOVEQ R5,R0
CMP LR,#' '
LDRHIB LR,[R0],#1
BHI %BT02
SUB R7,R0,R8 ; length of original string incl terminator
ADD R7,R7,#IconThemeSysVarLen + 3
BIC R7,R7,#3 ; R7 = length to allocate for string with inserted system variable
SUB SP,SP,R7
MOV R0,R8
MOV R3,SP
03 LDRB LR,[R0] ; skip leading spaces
TEQ LR,#' '
ADDEQ R0,R0,#1
BEQ %BT03
04 TEQ R0,R5 ; if at appropriate position
BNE %FT06
ADR R2,IconThemeSysVar
MOV R4,#IconThemeSysVarLen
05 LDRB LR,[R2],#1 ; then insert system variable
STRB LR,[R3],#1
SUBS R4,R4,#1
BNE %BT05
06 LDRB LR,[R0],#1 ; copy rest of string as is, including terminator
STRB LR,[R3],#1
CMP LR,#' '
BHI %BT04
MOV R3,SP ; R3 -> pathname with system variable inserted
01 LDRB R5,romspr_suffix
LDRB R6,romspr_suffix+1 LDRB R6,romspr_suffix+1
SUB R5,R5,#'0' SUB R5,R5,#'0'
SUB R6,R6,#'0' SUB R6,R6,#'0'
SUB sp,sp,#4 SUB sp,sp,#4
01 ADD R14,R5,R6,LSL #8 02 ADD R14,R5,R6,LSL #8
ADD R14,R14,#'0' ADD R14,R14,#'0'
ADD R14,R14,#'0':SHL:8 ADD R14,R14,#'0':SHL:8
STR R14,[sp] STR R14,[sp]
MOV R0,sp MOV R0,sp
MOV R1,R3 MOV R1,R3
| |
Push "LR"
LDR wsptr,[R12]
;
MOV R1,R0 MOV R1,R0
MOV R3,R0 ; R3 -> original filename MOV R3,R0 ; R3 -> original filename
] ]
...@@ -2816,32 +2854,40 @@ IconSprites_Code ...@@ -2816,32 +2854,40 @@ IconSprites_Code
MOV R0,#SpriteReason_MergeSpriteFile MOV R0,#SpriteReason_MergeSpriteFile
SWI XWimp_SpriteOp SWI XWimp_SpriteOp
[ Sprites11 [ Sprites11
BVC %FT04 BVC %FT03
TEQ R6,#3 TEQ R6,#3
MOVEQ R6,#2 MOVEQ R6,#2
BEQ %BT01 ; after Sprites23, try Sprites22 BEQ %BT02 ; after Sprites23, try Sprites22
CMP R5,R6 CMP R5,R6
MOVLO R5,R5,LSL#1 MOVLO R5,R5,LSL#1
MOVHI R6,R6,LSL#1 MOVHI R6,R6,LSL#1
BNE %BT01 ; after rectangular pixels, try next squarer version BNE %BT02 ; after rectangular pixels, try next squarer version
TEQ R5,#1 TEQ R5,#1
MOVEQ R5,#2 MOVEQ R5,#2
MOVEQ R6,#2 MOVEQ R6,#2
BEQ %BT01 ; after Sprites11, try Sprites22 BEQ %BT02 ; after Sprites11, try Sprites22
MOV R2,R3 ; R2 -> original filename MOV R2,R3 ; R2 -> original filename
MOV R0,#SpriteReason_MergeSpriteFile MOV R0,#SpriteReason_MergeSpriteFile
SWI XWimp_SpriteOp SWI XWimp_SpriteOp
04 ADD sp,sp,#4 03 ADD sp,sp,#4
TEQ R3,R8 ; were we trying with the system variable inserted?
ADDNE SP,SP,R7 ; yes, so junk stack frame
BVC %FT04
BEQ %FT05 ; no, and an error, so give up
MOV R3,R8 ; yes, and an error, so try again without the system variable
B %BT01
04
| |
MOVVS R2,R3 ; R2 -> original filename MOVVS R2,R3 ; R2 -> original filename
MOVVS R0,#SpriteReason_MergeSpriteFile MOVVS R0,#SpriteReason_MergeSpriteFile
SWIVS XWimp_SpriteOp SWIVS XWimp_SpriteOp
]
BVS %FT05 BVS %FT05
]
[ windowsprite [ windowsprite
[ ThreeDPatch [ ThreeDPatch
...@@ -2868,15 +2914,17 @@ IconSprites_Code ...@@ -2868,15 +2914,17 @@ IconSprites_Code
CLRV ; ignore errors CLRV ; ignore errors
] ]
[ Medusa [ :LNOT: Medusa ; Medusa uses DA
Pull "R12,PC" ; Medusa uses DA
|
; this merge bumps the RMA up, compress it again just in case. ; this merge bumps the RMA up, compress it again just in case.
MOV R0,#1 MOV R0,#1
MOV R1,#-&10000000 ; try and shrink RMA MOV R1,#-&10000000 ; try and shrink RMA
SWI XOS_ChangeDynamicArea SWI XOS_ChangeDynamicArea
CLRV ; may cause an error, but ok. CLRV ; may cause an error, but ok.
Pull "R12,PC" ]
[ Sprites11
Pull "R7-R8,PC"
|
Pull "PC"
] ]
05 05
Push "R0" Push "R0"
...@@ -2886,7 +2934,17 @@ IconSprites_Code ...@@ -2886,7 +2934,17 @@ IconSprites_Code
TEQ R0,R14 ; not really an error! TEQ R0,R14 ; not really an error!
CLRV EQ CLRV EQ
] ]
Pull "R0,R12,PC" [ Sprites11
Pull "R0,R7-R8,PC"
|
Pull "R0,PC"
]
[ Sprites11
IconThemeSysVar = "<Wimp$IconTheme>"
IconThemeSysVarLen * . - IconThemeSysVar
ALIGN
]
;............................................................................ ;............................................................................
......
...@@ -3173,8 +3173,12 @@ iconfilledCheckMenu ...@@ -3173,8 +3173,12 @@ iconfilledCheckMenu
TEQ r0,#&C0000 ; the main menu item has ESG 12 TEQ r0,#&C0000 ; the main menu item has ESG 12
BNE solidrectangle BNE solidrectangle
[ true ; see argument in createsubmenu
TST r1,#if_sprite
| ; 4.02 code
TST r1,#if_text TST r1,#if_text
TSTNE r1,#if_sprite ; if it's not a text+sprite icon TSTNE r1,#if_sprite ; if it's not a text+sprite icon
]
BEQ solidrectangle BEQ solidrectangle
01 01
Push "cx0-cy1,handle,lr" Push "cx0-cy1,handle,lr"
......
...@@ -3413,11 +3413,21 @@ trymenusdeleted ...@@ -3413,11 +3413,21 @@ trymenusdeleted
; Out R14 = menu root pointer (or dbox window handle) ; Out R14 = menu root pointer (or dbox window handle)
getmenuroot getmenuroot
EntryS [ No32bitCode
Entry
|
Entry "R0"
MRS R0,CPSR
]
LDR R14,menudata ; if menu owner changing, LDR R14,menudata ; if menu owner changing,
TST R14,#3 TST R14,#3
SUBEQ R14,R14,#m_header ; correct for header if menu ptr SUBEQ R14,R14,#m_header ; correct for header if menu ptr
[ No32bitCode
EXITS EXITS
|
MSR CPSR_f,R0
EXIT
]
; In [menuSP] >= 0 => there is a menu tree ; In [menuSP] >= 0 => there is a menu tree
; [menudata] = root node pointer of tree ; [menudata] = root node pointer of tree
...@@ -3773,8 +3783,17 @@ crmenuiconlp ...@@ -3773,8 +3783,17 @@ crmenuiconlp
ORRNE r1,r1,#if_filled ORRNE r1,r1,#if_filled
BNE %FT90 BNE %FT90
[ true
; EOR inversion is only used for icons that are non-sprite, unfilled and unshaded.
; All other icons need to be filled so that the whole icon is visibly changed when selected
; and then the unselected version special-cased in iconfilledCheckMenu.
; Since we never select shaded icons in menus, the appropriate test here is just for if_sprite.
; This allows the !Draw line pattern menu to work.
TST r1,#if_sprite
| ; 4.02 code
TST r1,#if_text TST r1,#if_text
TSTNE r1,#if_sprite ; if text+sprite icon TSTNE r1,#if_sprite ; if text+sprite icon
]
ORRNE r1,r1,#if_filled ; then fill it so inverting works ORRNE r1,r1,#if_filled ; then fill it so inverting works
BICEQ r1,r1,#if_bcol BICEQ r1,r1,#if_bcol
BICEQ r1,r1,#if_filled ; else clear the background and unfill it BICEQ r1,r1,#if_filled ; else clear the background and unfill it
......
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