1
0
forked from mirrors/0ad

Fix chat line button sizing

The issue was that the rright value was 100%.
That's why the buttons would always extend across the full width of the
screen.
Replacing the value right in the XML would result in an invalid size, so
we can remove it from there and create a full, separate size in the code
each time (Object.assign just edits it), since the top and bottom values
specified in the XML were overwritten anyway.
And since the left margin of 3 is fixed, we better move it to the parent
object to avoid a constant like that in the code.

Fixes #8322
This commit is contained in:
Vantha
2025-09-05 23:02:56 +02:00
committed by Phosit
parent eac96dbcbd
commit a5b5331fa4
2 changed files with 5 additions and 5 deletions
@@ -39,11 +39,11 @@ class ChatOverlay
this.chatLines[i].caption = chatMessage.text;
const newSize = this.chatLines[i].getPreferredTextSize();
Object.assign(this.chatLines[i].size, {
this.chatLines[i].size = {
"top": i * newSize.height,
"bottom": (i + 1) * newSize.height,
"right": this.chatLines[i].size.left + newSize.width
});
"right": newSize.width
};
if (chatMessage.callback)
this.chatLines[i].onPress = chatMessage.callback;
@@ -43,10 +43,10 @@
<include file="gui/session/TimeNotificationOverlay.xml"/>
<!-- Chat messages -->
<object name="chatPanel" size="0 131 100% 100%-240" z="0" absolute="true">
<object name="chatPanel" size="3 131 100% 100%-240" z="0" absolute="true">
<object name="chatLines">
<repeat count="20">
<object name="chatLine[n]" size="3 0 100% 17" type="button" style="chatPanelOverlay" tooltip_style="sessionToolTipBottomBold" ghost="true" hidden="true"/>
<object name="chatLine[n]" type="button" style="chatPanelOverlay" tooltip_style="sessionToolTipBottomBold" ghost="true" hidden="true"/>
</repeat>
</object>
</object>