summary refs log tree commit diff
path: root/resources/qml/components/FlatButton.qml
blob: 77d97976e7ab0312c0c33195f171bda5c9cdc572 (plain) (blame)
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
// SPDX-FileCopyrightText: 2021 Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later

import QtGraphicalEffects 1.12
import QtQuick 2.9
import QtQuick.Controls 2.5
import im.nheko 1.0

Button {
    id: control

    implicitHeight: Math.ceil(control.contentItem.implicitHeight * 1.5)
    implicitWidth: Math.ceil(control.contentItem.implicitWidth + control.contentItem.implicitHeight)
    hoverEnabled: true

    DropShadow {
        anchors.fill: control.background
        horizontalOffset: 3
        verticalOffset: 3
        radius: 8
        samples: 17
        cached: true
        color: "#80000000"
        source: control.background
    }

    contentItem: Text {
        text: control.text
        //font: control.font
        font.capitalization: Font.AllUppercase
        font.pointSize: Math.ceil(fontMetrics.font.pointSize * 1.5)
        //font.capitalization: Font.AllUppercase
        color: Nheko.colors.light
        horizontalAlignment: Text.AlignHCenter
        verticalAlignment: Text.AlignVCenter
        elide: Text.ElideRight
    }

    background: Rectangle {
        //height: control.contentItem.implicitHeight * 2
        //width: control.contentItem.implicitWidth * 2
        radius: height / 6
        color: Qt.lighter(Nheko.colors.dark, control.down ? 1.4 : (control.hovered ? 1.2 : 1))
    }

}