Commit 782467b4 authored by Devin Lin's avatar Devin Lin 🎨
Browse files

Use RectangularGlow instead of DropShadow for performance

parent 08d4d7ab
......@@ -20,9 +20,9 @@ Kirigami.Page {
property color dropShadowColor: Qt.darker(Kirigami.Theme.backgroundColor, 1.15)
property int keypadHeight: {
let rows = 6, columns = 5;
// restrict keypad so that the height of buttons never go past 0.85 times their width
if ((initialPage.height - Kirigami.Units.gridUnit * 7) / rows > 0.85 * initialPage.width / columns) {
return rows * 0.85 * initialPage.width / columns;
// restrict keypad so that the height of buttons never go past 0.7 times their width
if ((initialPage.height - Kirigami.Units.gridUnit * 7) / rows > 0.7 * initialPage.width / columns) {
return rows * 0.7 * initialPage.width / columns;
} else {
return initialPage.height - Kirigami.Units.gridUnit * 7;
}
......@@ -63,16 +63,40 @@ Kirigami.Page {
inputManager.setBinaryMode(true)
}
background: Rectangle {
Kirigami.Theme.colorSet: Kirigami.Theme.View
Kirigami.Theme.inherit: false
color: Kirigami.Theme.backgroundColor
anchors.fill: parent
}
// top panel drop shadow
RectangularGlow {
anchors.fill: topPanelBackground
anchors.topMargin: 1
glowRadius: 4
spread: 0.2
color: dropShadowColor
}
Rectangle {
id: topPanelBackground
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
color: Kirigami.Theme.backgroundColor
implicitHeight: outputScreen.height
}
ColumnLayout {
anchors.fill: parent
spacing: 0
Rectangle {
Item {
id: outputScreen
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
Layout.preferredHeight: initialPage.height - initialPage.keypadHeight
color: Kirigami.Theme.backgroundColor
Column {
id: outputColumn
......@@ -132,15 +156,12 @@ Kirigami.Page {
}
// Binary Input Pad
Rectangle {
Item {
property string expression: ""
id: binaryInputPad
Layout.fillHeight: true
Layout.preferredWidth: initialPage.width
Layout.alignment: Qt.AlignLeft
Kirigami.Theme.colorSet: Kirigami.Theme.View
Kirigami.Theme.inherit: false
color: Kirigami.Theme.backgroundColor
BinaryPad {
id: binaryPad
......@@ -161,17 +182,6 @@ Kirigami.Page {
onClear: inputManager.clear()
}
}
// top panel drop shadow (has to be above the keypad) - from main calculator
DropShadow {
anchors.fill: outputScreen
source: outputScreen
horizontalOffset: 0
verticalOffset: 1
radius: 4
samples: 6
color: initialPage.dropShadowColor
}
}
}
......@@ -78,16 +78,41 @@ Kirigami.Page {
inputManager.setBinaryMode(false)
}
background: Rectangle {
Kirigami.Theme.colorSet: Kirigami.Theme.View
Kirigami.Theme.inherit: false
color: Kirigami.Theme.backgroundColor
anchors.fill: parent
}
// top panel drop shadow
RectangularGlow {
anchors.fill: topPanelBackground
anchors.topMargin: 1
glowRadius: 4
spread: 0.2
color: dropShadowColor
}
Rectangle {
id: topPanelBackground
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
color: Kirigami.Theme.backgroundColor
implicitHeight: outputScreen.height
}
ColumnLayout {
anchors.fill: parent
spacing: 0
Rectangle {
Item {
id: outputScreen
z: 1
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
Layout.preferredHeight: initialPage.height - initialPage.keypadHeight
color: Kirigami.Theme.backgroundColor
Column {
id: outputColumn
......@@ -147,15 +172,12 @@ Kirigami.Page {
}
// keypad area
Rectangle {
Item {
property string expression: ""
id: inputPad
Layout.fillHeight: true
Layout.preferredWidth: inPortrait ? initialPage.width : initialPage.width * 0.5
Layout.alignment: Qt.AlignLeft
Kirigami.Theme.colorSet: Kirigami.Theme.View
Kirigami.Theme.inherit: false
color: Kirigami.Theme.backgroundColor
NumberPad {
id: numberPad
......@@ -177,6 +199,15 @@ Kirigami.Page {
onClear: inputManager.clear()
}
// fast drop shadow
RectangularGlow {
anchors.rightMargin: 1
anchors.fill: drawerIndicator
glowRadius: 4
spread: 0.2
color: initialPage.dropShadowColor
}
Rectangle {
id: drawerIndicator
anchors.top: parent.top
......@@ -185,17 +216,9 @@ Kirigami.Page {
x: parent.width - this.width
Kirigami.Theme.colorSet: Kirigami.Theme.View
Kirigami.Theme.inherit: false
color: Kirigami.Theme.backgroundColor
layer.enabled: true
layer.effect: DropShadow {
horizontalOffset: -2
verticalOffset: 0
radius: 4
samples: 6
color: initialPage.dropShadowColor
}
Rectangle {
anchors.centerIn: parent
height: parent.height / 20
......@@ -237,17 +260,6 @@ Kirigami.Page {
}
}
}
// top panel drop shadow (has to be above the keypad)
DropShadow {
anchors.fill: outputScreen
source: outputScreen
horizontalOffset: 0
verticalOffset: 1
radius: 4
samples: 6
color: initialPage.dropShadowColor
}
}
}
......@@ -46,6 +46,16 @@ Item {
duration: Kirigami.Units.shortDuration
}
// fast drop shadow
RectangularGlow {
anchors.topMargin: 1
anchors.fill: keyRect
cornerRadius: keyRect.radius * 2
glowRadius: 4
spread: 0.3
color: root.dropShadowColor
}
Rectangle {
id: keyRect
anchors.fill: parent
......@@ -68,16 +78,6 @@ Item {
onPressAndHold: root.longClicked()
}
}
DropShadow {
anchors.fill: keyRect
source: keyRect
horizontalOffset: 0
verticalOffset: 1
radius: 4
samples: 6
color: root.dropShadowColor
}
Controls.Label {
id: label
......
......@@ -21,9 +21,9 @@ Kirigami.Page {
property color dropShadowColor: Qt.darker(Kirigami.Theme.backgroundColor, 1.15)
property int keypadHeight: {
let rows = 4, columns = 3;
// restrict keypad so that the height of buttons never go past 0.85 times their width
if ((unitConverter.height - Kirigami.Units.gridUnit * 7) / rows > 0.85 * unitConverter.width / columns) {
return rows * 0.85 * unitConverter.width / columns;
// restrict keypad so that the height of buttons never go past 0.7 times their width
if ((unitConverter.height - Kirigami.Units.gridUnit * 7) / rows > 0.7 * unitConverter.width / columns) {
return rows * 0.7 * unitConverter.width / columns;
} else {
return unitConverter.height - Kirigami.Units.gridUnit * 7;
}
......@@ -39,6 +39,16 @@ Kirigami.Page {
}
}
// top panel drop shadow
RectangularGlow {
anchors.fill: topPanelBackground
anchors.topMargin: 1
z: -2
glowRadius: 4
spread: 0.2
color: dropShadowColor
}
Rectangle {
id: topPanelBackground
z: -1
......@@ -50,17 +60,6 @@ Kirigami.Page {
anchors.margins: -Kirigami.Units.largeSpacing
}
// top panel drop shadow
DropShadow {
anchors.fill: topPanelBackground
source: topPanelBackground
horizontalOffset: 0
verticalOffset: 1
radius: 4
samples: 6
color: dropShadowColor
}
ColumnLayout {
anchors.fill: parent
spacing: 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment