Fix & improve EventImage thumbnail sizes

This commit is contained in:
miruka 2019-12-20 08:32:57 -04:00
parent be6292a521
commit 5e26188dfe
5 changed files with 16 additions and 14 deletions

View File

@ -49,7 +49,6 @@
## Issues ## Issues
- load_past raise - load_past raise
- Room pane slightly overlaps chat at small width
- invisible uploaded mxc images? - invisible uploaded mxc images?
- first undecryptable message - first undecryptable message
- Join button 502 - Join button 502

View File

@ -43,7 +43,7 @@ HRowLayout {
) : ) :
0 0
// 600px max with a 16px font // ~600px max with a 16px font
readonly property int maxMessageWidth: theme.fontSize.normal * 0.5 * 75 readonly property int maxMessageWidth: theme.fontSize.normal * 0.5 * 75
@ -85,6 +85,8 @@ HRowLayout {
HColumnLayout { HColumnLayout {
id: contentColumn id: contentColumn
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
HSelectableLabel { HSelectableLabel {
@ -185,9 +187,8 @@ HRowLayout {
transform: Translate { x: xOffset } transform: Translate { x: xOffset }
Layout.bottomMargin: pureMedia ? 0 : contentLabel.bottomPadding Layout.bottomMargin: pureMedia ? 0 : contentLabel.bottomPadding
Layout.leftMargin: pureMedia ? 0 : contentLabel.leftPadding Layout.leftMargin: pureMedia ? 0 : eventContent.spacing
Layout.rightMargin: pureMedia ? 0 : contentLabel.rightPadding Layout.rightMargin: pureMedia ? 0 : eventContent.spacing
Layout.preferredWidth: item ? item.width : -1 Layout.preferredWidth: item ? item.width : -1
Layout.preferredHeight: item ? item.height : -1 Layout.preferredHeight: item ? item.height : -1
} }

View File

@ -25,7 +25,7 @@ HMxcImage {
readonly property bool isEncrypted: ! utils.isEmptyObject(cryptDict) readonly property bool isEncrypted: ! utils.isEmptyObject(cryptDict)
readonly property real maxHeight: readonly property real maxHeight:
theme.chat.message.thumbnailMaxHeightRatio eventList.height * theme.chat.message.thumbnailMaxHeightRatio
readonly property size fitSize: utils.fitSize( readonly property size fitSize: utils.fitSize(
// Minimum display size // Minimum display size
@ -49,10 +49,12 @@ HMxcImage {
// Maximum display size // Maximum display size
Math.min( Math.min(
eventList.height * maxHeight, Math.max(maxHeight, theme.chat.message.thumbnailMinSize.width),
eventContent.maxMessageWidth * Math.min(1, theme.uiScale), // XXX pureMedia ? Infinity : eventContent.maxMessageWidth,
eventDelegate.width - eventContent.spacing - avatarWrapper.width -
eventContent.spacing * 2, // padding
), ),
eventList.height * maxHeight, Math.max(maxHeight, theme.chat.message.thumbnailMinSize.height),
) )

View File

@ -187,11 +187,11 @@ QtObject {
function fitSize(minWidth, minHeight, width, height, maxWidth, maxHeight) { function fitSize(minWidth, minHeight, width, height, maxWidth, maxHeight) {
if (width >= height) { if (width >= height) {
let new_width = Math.max(Math.min(width, maxWidth), minWidth) let new_width = Math.min(Math.max(width, minWidth), maxWidth)
return Qt.size(new_width, height / (width / new_width)) return Qt.size(new_width, height / (width / new_width))
} }
let new_height = Math.max(Math.min(height, maxHeight), minHeight) let new_height = Math.min(Math.max(height, minHeight), maxHeight)
return Qt.size(width / (height / new_height), new_height) return Qt.size(width / (height / new_height), new_height)
} }

View File

@ -365,11 +365,11 @@ chat:
// Don't scale down thumbnails below this size in pixels, if // Don't scale down thumbnails below this size in pixels, if
// the becomes too small to show it at normal size. // the becomes too small to show it at normal size.
size thumbnailMinSize: Qt.size(192 * uiScale, 192 * uiScale) size thumbnailMinSize: Qt.size(256 * uiScale, 256 * uiScale)
// How much of the chat height thumbnails can take at most, // How much of the chat height thumbnails can take at most,
// by default 0.3 for 30%. // by default 0.4 for 40%.
real thumbnailMaxHeightRatio: 0.3 * Math.min(1, uiScale) real thumbnailMaxHeightRatio: 0.4 * Math.min(1, uiScale)
daybreak: daybreak:
color background: colors.strongBackground color background: colors.strongBackground