WL 21508 - Improve upon Skybox Changer

This involved a second PR, due to optimizing the way the Skyboxes are laid  out. All of the Skyboxes will now appear at once, with the random button being removed. You are able to scroll up and down the list and choose which Skybox you'd like to pick.
This commit is contained in:
Cain Kilgore 2017-10-23 19:30:36 +01:00
parent b42afdaff0
commit 3b4185fdb3
2 changed files with 16 additions and 87 deletions

View file

@ -12,6 +12,7 @@
import QtQuick 2.5
import "../styles-uit"
import "../controls-uit" as HifiControls
import QtQuick.Controls 2.2
Item {
id: root;
@ -20,7 +21,7 @@ Item {
property var defaultThumbnails: [];
property var defaultFulls: [];
SkyboxSelectionModel {
ListModel {
id: skyboxModel;
}
@ -41,44 +42,18 @@ Item {
for (var i = 0; i < arr.length; i++) {
defaultThumbnails.push(arr[i].thumb);
defaultFulls.push(arr[i].full);
skyboxModel.append({});
}
setDefaultSkyboxes();
setSkyboxes();
}
function setDefaultSkyboxes() {
function setSkyboxes() {
for (var i = 0; i < skyboxModel.count; i++) {
skyboxModel.setProperty(i, "thumbnailPath", defaultThumbnails[i]);
skyboxModel.setProperty(i, "fullSkyboxPath", defaultFulls[i]);
}
}
function shuffle(array) {
var tmp, current, top = array.length;
if (top) {
while (--top) {
current = Math.floor(Math.random() * (top + 1));
tmp = array[current];
array[current] = array[top];
array[top] = tmp;
}
}
return array;
}
function chooseRandom() {
for (var a = [], i=0; i < defaultFulls.length; ++i) {
a[i] = i;
}
a = shuffle(a);
for (var i = 0; i < skyboxModel.count; i++) {
skyboxModel.setProperty(i, "thumbnailPath", defaultThumbnails[a[i]]);
skyboxModel.setProperty(i, "fullSkyboxPath", defaultFulls[a[i]]);
}
}
Component.onCompleted: {
getSkyboxes();
}
@ -116,33 +91,19 @@ Item {
horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignVCenter;
}
HifiControls.Button {
id: randomButton
text: "Randomize"
color: hifi.buttons.blue
colorScheme: root.colorScheme
width: 100
anchors.right: parent.right
anchors.top: parent.top
anchors.topMargin: 5
anchors.rightMargin: 40
onClicked: {
chooseRandom()
}
}
}
GridView {
id: gridView
interactive: false
interactive: true
clip: true
anchors.top: titleBarContainer.bottom
anchors.topMargin: 20
anchors.horizontalCenter: parent.horizontalCenter
width: 400
height: parent.height
//height: parent.height
anchors.bottom: parent.bottom
currentIndex: -1
cellWidth: 200
cellHeight: 200
model: skyboxModel
@ -168,6 +129,14 @@ Item {
}
}
}
ScrollBar.vertical: ScrollBar {
parent: gridView.parent
anchors.top: gridView.top
anchors.left: gridView.right
anchors.bottom: gridView.bottom
anchors.leftMargin: 10
width: 19
}
}
signal sendToScript(var message);

View file

@ -1,40 +0,0 @@
//
// SkyboxSelectionModel.qml
// qml/hifi
//
// Created by Cain Kilgore on 21st October 2017
// Copyright 2017 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
import QtQuick 2.5
ListModel {
id: root;
ListElement{
thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg"
fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg"
}
ListElement{
thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg"
fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg"
}
ListElement{
thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg"
fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg"
}
ListElement{
thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg"
fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg"
}
ListElement{
thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg"
fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg"
}
ListElement{
thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg"
fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg"
}
}