-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathActionBarMultiActionExpandable.qml
More file actions
280 lines (232 loc) · 8.63 KB
/
Copy pathActionBarMultiActionExpandable.qml
File metadata and controls
280 lines (232 loc) · 8.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import qmlcomponents
import qmlenumvalues
Item {
id: root
enum Direction { Up, Right, Down, Left }
required property QtObject controller
required property list<QtObject> buttonData
property int direction: ActionBarMultiActionExpandable.Direction.Up
readonly property bool vertical: (direction == ActionBarMultiActionExpandable.Direction.Up || direction == ActionBarMultiActionExpandable.Direction.Down)
readonly property bool mirrored: (direction == ActionBarMultiActionExpandable.Direction.Left || direction == ActionBarMultiActionExpandable.Direction.Up)
readonly property var arrangedData: mirrored ? buttonData.slice().reverse() : buttonData
readonly property int infobarSize: 28
implicitWidth: multiActionButtonsWrapper.width
implicitHeight: multiActionButtonsWrapper.height
width: implicitWidth
height: implicitHeight
function getPositioningOffset() {
let offsetPosition = {
x: 0,
y: 0,
};
switch (direction) {
case ActionBarMultiActionExpandable.Direction.Up:
offsetPosition.x = -multiActionButtonsWrapper.width + 4 + TibiaStyle.actionBarSlotSize;
offsetPosition.y = -multiActionButtonsWrapper.height;
break;
case ActionBarMultiActionExpandable.Direction.Left:
offsetPosition.x = -multiActionButtonsWrapper.width;
offsetPosition.y = -multiActionButtonsWrapper.height + 4 + TibiaStyle.actionBarSlotSize;
break;
case ActionBarMultiActionExpandable.Direction.Right:
offsetPosition.x = TibiaStyle.actionBarSlotSize;
offsetPosition.y = -multiActionButtonsWrapper.height + 4 + TibiaStyle.actionBarSlotSize;
break;
default:
break;
}
return offsetPosition;
}
// -- multiaction buttons wrapper
TibiaFrame2PixelUpFilled {
id: multiActionButtonsWrapper
width: vertical
? (TibiaStyle.actionBarSlotSize * 1 + root.infobarSize + TibiaStyle.marginRelated)
: (TibiaStyle.actionBarSlotSize * 3 + TibiaStyle.marginRelated * 2 + 2 * 2) // 2 * 2 = buttons spacing
height: vertical
? (TibiaStyle.actionBarSlotSize * 3 + TibiaStyle.marginRelated * 2 + 2 * 2) // 2 * 2 = buttons spacing
: (TibiaStyle.actionBarSlotSize * 1 + root.infobarSize + TibiaStyle.marginRelated)
// Mouse area to avoid interacting with ui behind the expandable (e.g. the resize separator for the game window)
TibiaMouseShield {
anchors.fill: parent
}
// Drop area blocker avoids dropping objects on slots behind the popup
// see TIBIA-39847
DropArea {
id: blockDropArea
anchors.fill: parent
onDropped: {}
} //DropArea
Tooltip {
anchors.fill: parent
text: qsTrId("actionbar_button_multiaction_tooltip")
maxWidth: TibiaStyle.tooltipRestrictedWidth
} // Tooltip
// -- multiaction buttons
GridLayout {
id: buttonsLayout
flow: (vertical ? GridLayout.TopToBottom : GridLayout.LeftToRight)
property var anchorConfig: {
// left action bar
if (!vertical && !mirrored) {
return {
bottom: multiActionButtonsWrapper.bottom,
bottomMargin: TibiaStyle.marginRelated,
left: multiActionButtonsWrapper.left,
leftMargin: TibiaStyle.marginRelated
};
}
// right action bar
if (!vertical && mirrored) {
return {
bottom: multiActionButtonsWrapper.bottom,
bottomMargin: TibiaStyle.marginRelated,
right: multiActionButtonsWrapper.right,
rightMargin: TibiaStyle.marginRelated
};
}
// bottom action bar
if (vertical && mirrored) {
return {
right: multiActionButtonsWrapper.right,
rightMargin: TibiaStyle.marginRelated,
top: multiActionButtonsWrapper.top,
topMargin: TibiaStyle.marginRelated
};
}
return {};
} // anchorConfig
anchors.top: anchorConfig.top
anchors.topMargin: anchorConfig.topMargin
anchors.right: anchorConfig.right
anchors.rightMargin: anchorConfig.rightMargin
anchors.bottom: anchorConfig.bottom
anchors.bottomMargin: anchorConfig.bottomMargin
anchors.left: anchorConfig.left
anchors.leftMargin: anchorConfig.leftMargin
rowSpacing: 2
columnSpacing: 2
Repeater {
model: arrangedData
ActionBarButton {
required property var modelData
controller: root.controller
buttonData: modelData
}
} // Repeater
} // GridLayout
// -- infobar labels
GridLayout {
id: infobarLabelsLayout
flow: (vertical ? GridLayout.TopToBottom : GridLayout.LeftToRight)
width: vertical ? root.infobarSize : buttonsLayout.width
height: vertical ? buttonsLayout.height : root.infobarSize
uniformCellWidths: true
uniformCellHeights: true
readonly property var infobarButtonLabels: ["I", "II", "III"]
property var anchorConfig: {
// left action bar
if (!vertical && !mirrored) {
return {
top: multiActionButtonsWrapper.top,
left: buttonsLayout.left
};
}
// right action bar
if (!vertical && mirrored) {
return {
top: multiActionButtonsWrapper.top,
right: buttonsLayout.right
};
}
// bottom action bar
if (vertical && mirrored) {
return {
left: multiActionButtonsWrapper.left,
top: buttonsLayout.top
};
}
return {};
}
anchors.top: anchorConfig.top
anchors.topMargin: anchorConfig.topMargin
anchors.right: anchorConfig.right
anchors.rightMargin: anchorConfig.rightMargin
anchors.bottom: anchorConfig.bottom
anchors.bottomMargin: anchorConfig.bottomMargin
anchors.left: anchorConfig.left
anchors.leftMargin: anchorConfig.leftMargin
anchors.horizontalCenter: anchorConfig.horizontalCenter
anchors.verticalCenter: anchorConfig.verticalCenter
Repeater {
model: arrangedData
TibiaText {
Layout.fillWidth: true
Layout.fillHeight: true
text: infobarLabelsLayout.infobarButtonLabels[modelData.multiActionIndex]
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
}
}
}
// -- arrows
Repeater {
// multiaction buttons count - 1
model: 2
Image {
smooth: false
source: vertical || mirrored
? "/images/skin/classic/icon-arrow-greater-vertical.png"
: "/images/skin/classic/icon-arrow-greater-horizontal.png"
rotation: !vertical && mirrored ? -90 : 0
property var anchorConfig: {
let arrowSpacing = (vertical ? buttonsLayout.height : buttonsLayout.width) / 3;
let arrowHorizontalBarMargin = infobarLabelsLayout.height / 2 - height / 2 + 2;
let arrowVerticalBarMargin = infobarLabelsLayout.width / 2 - width / 2;
// left action bar
if (!vertical && !mirrored) {
let arrowDistanceFinal = arrowSpacing * (modelData + 1) - width / 2;
return {
left: buttonsLayout.left,
leftMargin: arrowDistanceFinal,
top: infobarLabelsLayout.top,
topMargin: arrowHorizontalBarMargin
};
}
// right action bar
if (!vertical && mirrored) {
let arrowDistanceFinal = arrowSpacing * (modelData + 1) - width / 2;
return {
right: buttonsLayout.right,
rightMargin: arrowDistanceFinal,
top: infobarLabelsLayout.top,
topMargin: arrowHorizontalBarMargin
};
}
// bottom action bar
if (vertical && mirrored) {
let arrowDistanceFinal = arrowSpacing * (modelData + 1) - height / 2;
return {
top: buttonsLayout.top,
topMargin: arrowDistanceFinal,
left: infobarLabelsLayout.left,
leftMargin: arrowVerticalBarMargin
};
}
return {};
} // anchorConfig
anchors.top: anchorConfig.top
anchors.topMargin: anchorConfig.topMargin
anchors.right: anchorConfig.right
anchors.rightMargin: anchorConfig.rightMargin
anchors.bottom: anchorConfig.bottom
anchors.bottomMargin: anchorConfig.bottomMargin
anchors.left: anchorConfig.left
anchors.leftMargin: anchorConfig.leftMargin
} // Image
} // Repeater
} // TibiaFrame2PixelUpFilled
} // Item