ScrollView.qml 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright (c) 2020 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Controls 2.3
  5. import UM 1.1 as UM
  6. ScrollView
  7. {
  8. clip: true
  9. // Setting this property to false hides the scrollbar both when the scrollbar is not needed (child height < height)
  10. // and when the scrollbar is not actively being hovered or pressed
  11. property bool scrollAlwaysVisible: true
  12. ScrollBar.vertical: ScrollBar
  13. {
  14. hoverEnabled: true
  15. policy: parent.scrollAlwaysVisible ? ScrollBar.AlwaysOn : ScrollBar.AsNeeded
  16. anchors.top: parent.top
  17. anchors.right: parent.right
  18. anchors.bottom: parent.bottom
  19. contentItem: Rectangle
  20. {
  21. implicitWidth: UM.Theme.getSize("scrollbar").width
  22. opacity: (parent.active || parent.parent.scrollAlwaysVisible) ? 1.0 : 0.0
  23. radius: Math.round(width / 2)
  24. color:
  25. {
  26. if (parent.pressed)
  27. {
  28. return UM.Theme.getColor("scrollbar_handle_down")
  29. }
  30. else if (parent.hovered)
  31. {
  32. return UM.Theme.getColor("scrollbar_handle_hover")
  33. }
  34. return UM.Theme.getColor("scrollbar_handle")
  35. }
  36. Behavior on color { ColorAnimation { duration: 100; } }
  37. Behavior on opacity { NumberAnimation { duration: 100 } }
  38. }
  39. }
  40. }