Skip to content

Commit f3db37c

Browse files
authored
Merge pull request #33765 from ajuncosa/truncated-text
Re-design PropertiesPanelTabButtons to hug contents instead of having equal widths
2 parents d7f0fa7 + 962ecf3 commit f3db37c

9 files changed

Lines changed: 55 additions & 2 deletions

File tree

src/propertiespanel/qml/MuseScore/PropertiesPanel/common/PropertiesPanelTabBar.qml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,39 @@ StyledTabBar {
3030

3131
background: Item {
3232
implicitHeight: 28
33+
34+
SeparatorLine {
35+
id: underlineStroke
36+
anchors.bottom: parent.bottom
37+
}
38+
}
39+
40+
// Equally divided share given to overflowing tabs, or Infinity when everything fits:
41+
readonly property real truncatedItemWidth: {
42+
let items = contentChildren.filter(i => i.visible)
43+
if (items.length === 0) {
44+
return Infinity
45+
}
46+
47+
let totalSpacing = (items.length - 1) * root.spacing
48+
let totalContent = items.reduce((s, i) => s + i.implicitWidth, 0)
49+
if (totalContent + totalSpacing <= root.width) {
50+
return Infinity
51+
}
52+
53+
let availableWidth = Math.max(0, root.width - totalSpacing)
54+
let share = availableWidth / items.length
55+
let prev = -1
56+
while (share !== prev) {
57+
prev = share
58+
let fittedItems = items.filter(i => i.implicitWidth < share)
59+
let totalFittedWidth = fittedItems.reduce((s, i) => s + i.implicitWidth, 0)
60+
let remaining = items.length - fittedItems.length
61+
share = remaining > 0
62+
? Math.max(0, (root.width - totalFittedWidth - totalSpacing) / remaining)
63+
: 0
64+
}
65+
return share
3366
}
67+
3468
}

src/propertiespanel/qml/MuseScore/PropertiesPanel/common/PropertiesPanelTabButton.qml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ import QtQuick
2424
import Muse.UiComponents
2525

2626
StyledTabButton {
27-
fillWidth: true
27+
required property real maxWidth
28+
2829
font: ui.theme.bodyBoldFont
30+
width: Math.min(implicitWidth, maxWidth)
31+
leftPadding: 4
32+
rightPadding: 4
2933
}

src/propertiespanel/qml/MuseScore/PropertiesPanel/notation/frames/FretFrameSettings.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Column {
5656

5757
PropertiesPanelTabButton {
5858
text: qsTrc("propertiespanel", "Chords")
59+
maxWidth: tabBar.truncatedItemWidth
5960

6061
navigation.name: "ChordsTab"
6162
navigation.panel: root.navigationPanel
@@ -64,6 +65,7 @@ Column {
6465

6566
PropertiesPanelTabButton {
6667
text: qsTrc("propertiespanel", "Frame")
68+
maxWidth: tabBar.truncatedItemWidth
6769

6870
navigation.name: "FrameTab"
6971
navigation.panel: root.navigationPanel

src/propertiespanel/qml/MuseScore/PropertiesPanel/notation/fretdiagrams/internal/FretDiagramTabPanel.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Column {
4848

4949
PropertiesPanelTabButton {
5050
text: qsTrc("propertiespanel", "General")
51+
maxWidth: tabBar.truncatedItemWidth
5152

5253
navigation.name: "GeneralTab"
5354
navigation.panel: root.navigationPanel
@@ -56,6 +57,7 @@ Column {
5657

5758
PropertiesPanelTabButton {
5859
text: qsTrc("propertiespanel", "Settings")
60+
maxWidth: tabBar.truncatedItemWidth
5961

6062
navigation.name: "SettingsTab"
6163
navigation.panel: root.navigationPanel

src/propertiespanel/qml/MuseScore/PropertiesPanel/notation/lines/GradualTempoChangeSettings.qml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Column {
5151

5252
PropertiesPanelTabButton {
5353
text: qsTrc("propertiespanel", "Position")
54+
maxWidth: tabBar.truncatedItemWidth
5455

5556
navigation.name: "PositionTab"
5657
navigation.panel: root.navigationPanel
@@ -59,6 +60,7 @@ Column {
5960

6061
PropertiesPanelTabButton {
6162
text: qsTrc("propertiespanel", "Style")
63+
maxWidth: tabBar.truncatedItemWidth
6264

6365
navigation.name: "StyleTab"
6466
navigation.panel: root.navigationPanel
@@ -67,6 +69,7 @@ Column {
6769

6870
PropertiesPanelTabButton {
6971
text: qsTrc("propertiespanel", "Text")
72+
maxWidth: tabBar.truncatedItemWidth
7073

7174
navigation.name: "TextTab"
7275
navigation.panel: root.navigationPanel

src/propertiespanel/qml/MuseScore/PropertiesPanel/notation/lines/HairpinLineSettings.qml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Column {
5353

5454
PropertiesPanelTabButton {
5555
text: qsTrc("propertiespanel", "Position")
56+
maxWidth: tabBar.truncatedItemWidth
5657

5758
navigation.name: "PositionTab"
5859
navigation.panel: root.navigationPanel
@@ -61,6 +62,7 @@ Column {
6162

6263
PropertiesPanelTabButton {
6364
text: qsTrc("propertiespanel", "Style")
65+
maxWidth: tabBar.truncatedItemWidth
6466

6567
navigation.name: "StyleTab"
6668
navigation.panel: root.navigationPanel
@@ -69,6 +71,7 @@ Column {
6971

7072
PropertiesPanelTabButton {
7173
text: qsTrc("propertiespanel", "Text")
74+
maxWidth: tabBar.truncatedItemWidth
7275

7376
navigation.name: "TextTab"
7477
navigation.panel: root.navigationPanel

src/propertiespanel/qml/MuseScore/PropertiesPanel/notation/lines/LineSettings.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Column {
5353

5454
PropertiesPanelTabButton {
5555
text: qsTrc("propertiespanel", "Style")
56+
maxWidth: tabBar.truncatedItemWidth
5657

5758
navigation.name: "StyleTab"
5859
navigation.panel: root.navigationPanel
@@ -61,6 +62,7 @@ Column {
6162

6263
PropertiesPanelTabButton {
6364
text: qsTrc("propertiespanel", "Text")
65+
maxWidth: tabBar.truncatedItemWidth
6466

6567
navigation.name: "TextTab"
6668
navigation.panel: root.navigationPanel

src/propertiespanel/qml/MuseScore/PropertiesPanel/notation/notes/NoteSettings.qml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Column {
7070

7171
PropertiesPanelTabButton {
7272
text: root.headModel?.title ?? ""
73+
maxWidth: tabBar.truncatedItemWidth
7374

7475
navigation.name: "HeadTab"
7576
navigation.panel: root.navigationPanel
@@ -79,6 +80,7 @@ Column {
7980
PropertiesPanelTabButton {
8081
visible: root.headModel ? !root.headModel.isTrillCueNote : true
8182
text: root.stemModel ? root.stemModel.title : ""
83+
maxWidth: tabBar.truncatedItemWidth
8284

8385
navigation.name: "StemTab"
8486
navigation.panel: root.navigationPanel
@@ -88,6 +90,7 @@ Column {
8890
PropertiesPanelTabButton {
8991
visible: root.headModel ? !root.headModel.isTrillCueNote : true
9092
text: root.beamModel ? root.beamModel.title : ""
93+
maxWidth: tabBar.truncatedItemWidth
9194

9295
navigation.name: "BeamTab"
9396
navigation.panel: root.navigationPanel

0 commit comments

Comments
 (0)