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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import HelperWidgets as HelperWidgets
import StudioControls as StudioControls
import StudioTheme as StudioTheme
import ContentLibraryBackend
Item {
id: root
property bool adsFocus: false
// objectName is used by the dock widget to find this particular ScrollView
// and set the ads focus on it.
objectName: "__mainSrollView"
// Called also from C++ to close context menu on focus out
function closeContextMenu() {
materialsView.closeContextMenu()
texturesView.closeContextMenu()
environmentsView.closeContextMenu()
effectsView.closeContextMenu()
HelperWidgets.Controller.closeContextMenu()
}
// Called from C++
function clearSearchFilter() {
searchBox.clear()
}
property int numColumns: 4
property real thumbnailSize: 100
readonly property int minThumbSize: 100
readonly property int maxThumbSize: 150
function responsiveResize(width: int, height: int) {
width -= 2 * StudioTheme.Values.sectionPadding
let numColumns = Math.floor(width / root.minThumbSize)
let remainder = width % root.minThumbSize
let space = (numColumns - 1) * StudioTheme.Values.sectionGridSpacing
if (remainder < space)
numColumns -= 1
if (numColumns < 1)
return
let maxItems = Math.max(materialsView.count,
texturesView.count,
environmentsView.count,
effectsView.count)
if (numColumns > maxItems)
numColumns = maxItems
let rest = width - (numColumns * root.minThumbSize)
- ((numColumns - 1) * StudioTheme.Values.sectionGridSpacing)
root.thumbnailSize = Math.min(root.minThumbSize + (rest / numColumns),
root.maxThumbSize)
root.numColumns = numColumns
}
Column {
id: col
anchors.fill: parent
spacing: 5
Rectangle {
width: parent.width
height: StudioTheme.Values.doubleToolbarHeight
color: StudioTheme.Values.themeToolbarBackground
Column {
anchors.fill: parent
anchors.topMargin: StudioTheme.Values.toolbarVerticalMargin
anchors.bottomMargin: StudioTheme.Values.toolbarVerticalMargin
anchors.leftMargin: StudioTheme.Values.toolbarHorizontalMargin
anchors.rightMargin: StudioTheme.Values.toolbarHorizontalMargin
spacing: StudioTheme.Values.toolbarColumnSpacing
StudioControls.SearchBox {
id: searchBox
width: parent.width
style: StudioTheme.Values.searchControlStyle
enabled: {
if (tabBar.currIndex === 0) { // Materials tab
ContentLibraryBackend.materialsModel.matBundleExists
&& ContentLibraryBackend.rootView.hasMaterialLibrary
&& ContentLibraryBackend.materialsModel.hasRequiredQuick3DImport
} else { // Textures / Environments tabs
ContentLibraryBackend.texturesModel.texBundleExists
}
}
onSearchChanged: (searchText) => {
ContentLibraryBackend.rootView.handleSearchFilterChanged(searchText)
// make sure categories with matches are expanded
materialsView.expandVisibleSections()
texturesView.expandVisibleSections()
environmentsView.expandVisibleSections()
effectsView.expandVisibleSections()
}
}
ContentLibraryTabBar {
id: tabBar
width: parent.width
height: StudioTheme.Values.toolbarHeight
tabsModel: [{name: qsTr("Materials"), icon: StudioTheme.Constants.material_medium},
{name: qsTr("Textures"), icon: StudioTheme.Constants.textures_medium},
{name: qsTr("Environments"), icon: StudioTheme.Constants.languageList_medium},
{name: qsTr("Effects"), icon: StudioTheme.Constants.effects}]
}
}
}
UnimportBundleMaterialDialog {
id: confirmUnimportDialog
}
StackLayout {
id: stackLayout
width: root.width
height: root.height - y
currentIndex: tabBar.currIndex
onWidthChanged: root.responsiveResize(stackLayout.width, stackLayout.height)
ContentLibraryMaterialsView {
id: materialsView
adsFocus: root.adsFocus
width: root.width
cellWidth: root.thumbnailSize
cellHeight: root.thumbnailSize + 20
numColumns: root.numColumns
hideHorizontalScrollBar: true
searchBox: searchBox
onUnimport: (bundleMat) => {
confirmUnimportDialog.targetBundleItem = bundleMat
confirmUnimportDialog.targetBundleType = "material"
confirmUnimportDialog.open()
}
onCountChanged: root.responsiveResize(stackLayout.width, stackLayout.height)
}
ContentLibraryTexturesView {
id: texturesView
adsFocus: root.adsFocus
width: root.width
cellWidth: root.thumbnailSize
cellHeight: root.thumbnailSize
numColumns: root.numColumns
hideHorizontalScrollBar: true
model: ContentLibraryBackend.texturesModel
sectionCategory: "ContentLib_Tex"
searchBox: searchBox
onCountChanged: root.responsiveResize(stackLayout.width, stackLayout.height)
}
ContentLibraryTexturesView {
id: environmentsView
adsFocus: root.adsFocus
width: root.width
cellWidth: root.thumbnailSize
cellHeight: root.thumbnailSize
numColumns: root.numColumns
hideHorizontalScrollBar: true
model: ContentLibraryBackend.environmentsModel
sectionCategory: "ContentLib_Env"
searchBox: searchBox
onCountChanged: root.responsiveResize(stackLayout.width, stackLayout.height)
}
ContentLibraryEffectsView {
id: effectsView
adsFocus: root.adsFocus
width: root.width
cellWidth: root.thumbnailSize
cellHeight: root.thumbnailSize + 20
numColumns: root.numColumns
hideHorizontalScrollBar: true
searchBox: searchBox
onUnimport: (bundleItem) => {
confirmUnimportDialog.targetBundleItem = bundleItem
confirmUnimportDialog.targetBundleType = "effect"
confirmUnimportDialog.open()
}
onCountChanged: root.responsiveResize(stackLayout.width, stackLayout.height)
}
}
}
}
|