Skip to content

Commit facec48

Browse files
committed
Change Background/* settings to affect rectangle
Remove text outline Add background rectangle
1 parent cc2b966 commit facec48

File tree

2 files changed

+30
-29
lines changed

2 files changed

+30
-29
lines changed

components/JFVideo.brs

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ sub toggleCaption()
6060
end sub
6161

6262
sub updateCaption ()
63-
m.captionGroup.removeChildrenindex(9, 0)
63+
while m.captionGroup.removeChildIndex(0)
64+
end while
6465
m.captionGroup.appendChildren(m.captionTask.currentCaption)
6566
end sub
6667

components/captionTask.brs

+28-28
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ sub init()
1313

1414
' Caption Style
1515
m.fontSizeDict = { "Default": 60, "Large": 60, "Extra Large": 70, "Medium": 50, "Small": 40 }
16-
m.percentageDict = { "Default": 1.0, "100%": 1.0, "75%": 0.75, "25%": 0.25, "Off": 0 }
16+
m.percentageDict = { "Default": 1.0, "100%": 1.0, "75%": 0.75, "50%": 0.5, "25%": 0.25, "Off": 0 }
1717
m.textColorDict = { "Default": &HFFFFFFFF, "White": &HFFFFFFFF, "Black": &H000000FF, "Red": &HFF0000FF, "Green": &H008000FF, "Blue": &H0000FFFF, "Yellow": &HFFFF00FF, "Magenta": &HFF00FFFF, "Cyan": &H00FFFFFF }
18-
m.outlColorDict = { "Default": &H000000FF, "White": &HFFFFFFFF, "Black": &H000000FF, "Red": &HFF0000FF, "Green": &H008000FF, "Blue": &H0000FFFF, "Yellow": &HFFFF00FF, "Magenta": &HFF00FFFF, "Cyan": &H00FFFFFF }
18+
m.bgColorDict = { "Default": &H000000FF, "White": &HFFFFFFFF, "Black": &H000000FF, "Red": &HFF0000FF, "Green": &H008000FF, "Blue": &H0000FFFF, "Yellow": &HFFFF00FF, "Magenta": &HFF00FFFF, "Cyan": &H00FFFFFF }
1919

2020
m.settings = CreateObject("roDeviceInfo")
2121
m.fontSize = m.fontSizeDict[m.settings.GetCaptionsOption("Text/Size")]
2222
m.textColor = m.textColorDict[m.settings.GetCaptionsOption("Text/Color")]
2323
m.textOpac = m.percentageDict[m.settings.GetCaptionsOption("Text/Opacity")]
24-
m.outlColor = m.outlColorDict[m.settings.GetCaptionsOption("Background/Color")]
25-
m.outlOpac = m.percentageDict[m.settings.GetCaptionsOption("Background/Opacity")]
24+
m.bgColor = m.bgColorDict[m.settings.GetCaptionsOption("Background/Color")]
25+
m.bgOpac = m.percentageDict[m.settings.GetCaptionsOption("Background/Opacity")]
2626
setFont()
2727
end sub
2828

@@ -57,27 +57,37 @@ function newlabel(txt):
5757
label = CreateObject("roSGNode", "Label")
5858
label.text = txt
5959
label.font = m.font
60-
label.color = m.outlColor
61-
label.opacity = m.outlOpac
62-
label.height = 108
60+
label.color = m.textColor
61+
label.opacity = m.textOpac
6362
return label
6463
end function
6564

66-
function newlayout(labels)
67-
invis = CreateObject("roSGNode", "Label")
68-
invis.visible = False
69-
l = labels.count()
65+
function newLayoutGroup(labels)
7066
newlg = CreateObject("roSGNode", "LayoutGroup")
71-
for i = 0 to 7 - l
72-
newlg.appendchild(invis.clone(True))
73-
end for
7467
newlg.appendchildren(labels)
7568
newlg.horizalignment = "center"
7669
newlg.vertalignment = "bottom"
77-
7870
return newlg
7971
end function
8072

73+
function newRect(lg)
74+
rectLG = CreateObject("roSGNode", "LayoutGroup")
75+
rectxy = lg.BoundingRect()
76+
rect = CreateObject("roSGNode", "Rectangle")
77+
rect.color = m.bgColor
78+
rect.opacity = m.bgOpac
79+
rect.width = rectxy.width + 50
80+
rect.height = rectxy.height
81+
if lg.getchildCount() = 0
82+
rect.width = 0
83+
rect.height = 0
84+
end if
85+
rectLG.horizalignment = "center"
86+
rectLG.vertalignment = "bottom"
87+
rectLG.appendchild(rect)
88+
return rectLG
89+
end function
90+
8191

8292
sub updateCaption ()
8393
m.top.currentCaption = []
@@ -94,19 +104,9 @@ sub updateCaption ()
94104
for each text in texts
95105
labels.push(newlabel (text))
96106
end for
97-
lg = newlayout(labels)
98-
lglist = []
99-
coords = [[-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1], [0, 0]]
100-
for p = 0 to 8
101-
lgg = lg.clone(True)
102-
lgg.translation = [coords[p][0] * 5, coords[p][1] * 5]
103-
lglist.push(lgg)
104-
end for
105-
for q = 0 to 7
106-
lglist[8].getchild(q).color = m.textColor
107-
lglist[8].getchild(q).opacity = m.textOpac
108-
end for
109-
m.top.currentCaption = lglist
107+
lines = newLayoutGroup(labels)
108+
rect = newRect(lines)
109+
m.top.currentCaption = [rect, lines]
110110
else if right(m.top.playerState, 4) = "Wait"
111111
m.top.playerState = "playingOn"
112112
else

0 commit comments

Comments
 (0)