Files
clide/qml/Components/ClideScrollBar.qml

75 lines
2.0 KiB
QML
Raw Normal View History

2026-02-02 23:05:53 -05:00
// SPDX-FileCopyrightText: 2026, Shaun Reed <shaunrd0@gmail.com>
//
// SPDX-License-Identifier: GNU General Public License v3.0 or later
import QtQuick
import QtQuick.Controls
import clide.module 1.0
ScrollBar {
id: scrollBar
2026-02-04 19:52:05 -05:00
// Height, opacitiy, width
2026-02-08 14:26:26 -05:00
property int h: scrollBar.interactive ? sizeModifier * 2 : sizeModifier
2026-02-04 19:52:05 -05:00
property int o: scrollBar.active && scrollBar.size < 1.0 ? 1.0 : 0.0
2026-02-08 14:26:26 -05:00
property int sizeModifier: 4
property int w: scrollBar.interactive ? sizeModifier * 2 : sizeModifier
2026-02-04 19:52:05 -05:00
2026-02-02 23:05:53 -05:00
// Scroll bar gutter
background: Rectangle {
2026-02-04 19:52:05 -05:00
id: gutter
2026-02-02 23:05:53 -05:00
color: RustColors.scrollbar_gutter
2026-02-04 19:52:05 -05:00
implicitHeight: scrollBar.h
implicitWidth: scrollBar.w
2026-02-02 23:05:53 -05:00
// Fade the scrollbar gutter when inactive.
2026-02-04 19:52:05 -05:00
opacity: scrollBar.o
2026-02-08 14:26:26 -05:00
radius: 20
2026-02-02 23:05:53 -05:00
Behavior on opacity {
OpacityAnimator {
duration: 500
}
}
}
// Scroll bar
contentItem: Rectangle {
2026-02-04 19:52:05 -05:00
readonly property color barColor: {
if (scrollBar.size < 1.0) {
// If the scrollbar is required change it's color based on activity.
if (scrollBar.active) {
return RustColors.scrollbar_active;
} else {
return RustColors.scrollbar;
}
} else {
// If we don't need a scrollbar, fallback to the gutter color.
return gutter.color;
}
}
color: barColor
implicitHeight: scrollBar.h
implicitWidth: scrollBar.w
2026-02-02 23:05:53 -05:00
// Fade the scrollbar when inactive.
2026-02-04 19:52:05 -05:00
opacity: scrollBar.o
2026-02-08 14:26:26 -05:00
radius: 20
2026-02-02 23:05:53 -05:00
// Smooth transition between color changes based on the state above.
Behavior on color {
ColorAnimation {
duration: 1000
}
}
Behavior on opacity {
OpacityAnimator {
duration: 1000
}
}
}
}