Skip to content

Commit da57a85

Browse files
committed
Merge pull request livecode#3566 from livecodeali/bugfix-16864
[[ Header Bar ]] Fix regression when setting actionStyle to names
2 parents bf6c9a0 + 3f04fb2 commit da57a85

3 files changed

Lines changed: 63 additions & 3 deletions

File tree

extensions/widgets/header/header.lcb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ private handler drawActions() returns nothing
675675
variable tIconPath as Path
676676
variable tActionRect as Rectangle
677677

678+
variable tHitRect as Rectangle
678679
put the number of elements in mHeaderActions into tActionsCount
679680
repeat with tX from 1 up to tActionsCount
680681

@@ -689,12 +690,13 @@ private handler drawActions() returns nothing
689690
put fetchRect("actionIcon") into tActionRect
690691
put fetchIconPath(mHeaderActions[tX]["icon_name"], tActionRect) into tIconPath
691692
fill tIconPath on this canvas
692-
693+
put the bounding box of tIconPath into tHitRect
693694
else if mActionStyle is "names" then
694695
put the number of chars in mHeaderActions[tX]["label"] into mLetterCount
695696
put fetchRect("actionLabel") into tActionRect
696697
set the font of this canvas to fetchFont("label")
697698
fill text mHeaderActions[tX]["label"] at right of tActionRect on this canvas
699+
put tActionRect into tHitRect
698700
end if
699701

700702
else if mWidgetTheme is kWidgetThemeAndroid then
@@ -703,10 +705,10 @@ private handler drawActions() returns nothing
703705
put fetchIconPath(mHeaderActions[tX]["icon_name"], tActionRect) into tIconPath
704706
translate tIconPath by [my width - (mAndroidBuffer*2 + mAndroidIconDimension)*tX, 0]
705707
fill tIconPath on this canvas
706-
708+
put the bounding box of tIconPath into tHitRect
707709
end if
708710

709-
push the bounding box of tIconPath onto back of mActionRects
711+
push tHitRect onto back of mActionRects
710712
end repeat
711713
end handler
712714

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# [16864] Prevent error when displaying actions as names
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
script "HeaderBarWidgetProperties"
2+
/*
3+
Copyright (C) 2015 LiveCode Ltd.
4+
5+
This file is part of LiveCode.
6+
7+
LiveCode is free software; you can redistribute it and/or modify it under
8+
the terms of the GNU General Public License v3 as published by the Free
9+
Software Foundation.
10+
11+
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
12+
WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
18+
19+
on TestSetup
20+
TestLoadExtension "com.livecode.library.widgetutils"
21+
TestLoadExtension "com.livecode.library.iconSVG"
22+
TestLoadExtension "com.livecode.widget.headerBar"
23+
create widget "testHeader" as "com.livecode.widget.headerBar"
24+
end TestSetup
25+
26+
on TestTeardown
27+
delete widget "testHeader"
28+
end TestTeardown
29+
30+
on TestCreateHeader
31+
TestAssert "created header exists", there is a widget "testHeader"
32+
end TestCreateHeader
33+
34+
on TestSetTheme
35+
set the widgetTheme of widget "testHeader" to "Android"
36+
TestAssert "theme set to Android", the widgetTheme of widget "testHeader" is "Android"
37+
38+
set the widgetTheme of widget "testHeader" to "iOS"
39+
TestAssert "theme set to iOS", the widgetTheme of widget "testHeader" is "iOS"
40+
end TestSetTheme
41+
42+
on TestSetBGOpacity
43+
set the backgroundOpacity of widget "testHeader" to false
44+
TestAssert "set backgroundOpacity to false", the backgroundOpacity of widget "testHeader" is false
45+
46+
set the backgroundOpacity of widget "testHeader" to true
47+
TestAssert "set backgroundOpacity to false", the backgroundOpacity of widget "testHeader" is true
48+
end TestSetBGOpacity
49+
50+
on TestSetActionStyle
51+
set the actionStyle of widget "testHeader" to "names"
52+
TestAssert "actionStyle set to names", the actionStyle of widget "testHeader" is "names"
53+
54+
set the actionStyle of widget "testHeader" to "icons"
55+
TestAssert "actionStyle set to icons", the actionStyle of widget "testHeader" is "icons"
56+
end TestSetActionStyle
57+

0 commit comments

Comments
 (0)