TabContainer.qml 1.28 KB
Newer Older
Ronan's avatar
Ronan committed
1
import QtQuick 2.7
2
import QtQuick.Controls 2.2
3
import QtQuick.Layouts 1.3
Ronan's avatar
Ronan committed
4

5
import Common 1.0
Ronan's avatar
Ronan committed
6
import Common.Styles 1.0
7
import Utils 1.0
Ronan's avatar
Ronan committed
8 9 10 11 12 13 14 15

// =============================================================================

Rectangle {
  default property alias _content: content.data

  color: TabContainerStyle.color

16 17 18
  ColumnLayout {
    anchors.fill: parent
    spacing: 0
Ronan's avatar
Ronan committed
19

20 21 22 23
    Flickable {
      ScrollBar.vertical: ForceScrollBar {
        id: scrollBar
      }
Ronan's avatar
Ronan committed
24

25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
      Layout.fillHeight: true
      Layout.fillWidth: true

      boundsBehavior: Flickable.StopAtBounds
      clip: true

      contentHeight: Utils.ensureArray(_content).reduce(function (acc, item) { return item.height }, 0, []) +
        TabContainerStyle.topMargin + TabContainerStyle.bottomMargin
      contentWidth: width

      Item {
        id: content

        anchors {
          left: parent.left
          leftMargin: TabContainerStyle.leftMargin
          right: parent.right
          rightMargin: TabContainerStyle.rightMargin
          top: parent.top
          topMargin: TabContainerStyle.topMargin
        }
      }
    }

    Rectangle {
      Layout.fillWidth: true
      Layout.preferredHeight: TabContainerStyle.separator.height

      color: TabContainerStyle.separator.color
      visible: scrollBar.visible
Ronan's avatar
Ronan committed
55 56 57
    }
  }
}