-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnergyBar.qml
More file actions
45 lines (35 loc) · 1.05 KB
/
EnergyBar.qml
File metadata and controls
45 lines (35 loc) · 1.05 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
import QtQuick
import QtQuick.Layouts
RowLayout {
property int currentValue: 0
property int maxValue: 0
property alias symbolImage: symbol.source
property alias barBorderImage: outerBar.source
property alias barFillImage: barFill.source
spacing: TibiaStyle.marginNarrow
Image {
id: symbol
smooth: false
} // Image
Image {
id: outerBar
smooth: false
Image {
id: barFill
horizontalAlignment: Image.AlignLeft
fillMode: Image.Pad
property double fillPercent: maxValue > 0 ? Math.max(0.0, Math.min(1.0, (currentValue / maxValue))) : 0
width: Math.round(outerBar.width * fillPercent) // XXX: The software renderer uses incorrect width for very small decimal values, so round to integer
smooth: false
} // Image
} // Image
Item {
Layout.fillWidth: true
} //Item
TibiaText {
text: currentValue
Layout.preferredWidth: TibiaStyle.sideBarPanelRightSideWith
Layout.preferredHeight: outerBar.height
verticalAlignment: Text.AlignVCenter
} // TibiaText
} // RowLayout