mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Merge pull request #8248 from jherico/edit_toolbar
Migrate edit.js toolbar to the new toolbar API
This commit is contained in:
commit
574aaa9f28
10 changed files with 175 additions and 395 deletions
|
@ -19,26 +19,13 @@ Window {
|
||||||
shown: true
|
shown: true
|
||||||
width: content.width
|
width: content.width
|
||||||
height: content.height
|
height: content.height
|
||||||
visible: true
|
|
||||||
// Disable this window from being able to call 'desktop.raise() and desktop.showDesktop'
|
// Disable this window from being able to call 'desktop.raise() and desktop.showDesktop'
|
||||||
activator: MouseArea {
|
activator: Item {}
|
||||||
width: frame.decoration ? frame.decoration.width : window.width
|
|
||||||
height: frame.decoration ? frame.decoration.height : window.height
|
|
||||||
x: frame.decoration ? frame.decoration.anchors.leftMargin : 0
|
|
||||||
y: frame.decoration ? frame.decoration.anchors.topMargin : 0
|
|
||||||
propagateComposedEvents: true
|
|
||||||
acceptedButtons: Qt.AllButtons
|
|
||||||
enabled: window.visible
|
|
||||||
hoverEnabled: true
|
|
||||||
onPressed: mouse.accepted = false;
|
|
||||||
onEntered: window.mouseEntered();
|
|
||||||
onExited: window.mouseExited();
|
|
||||||
}
|
|
||||||
property bool horizontal: true
|
property bool horizontal: true
|
||||||
property real buttonSize: 50;
|
property real buttonSize: 50;
|
||||||
property var buttons: []
|
property var buttons: []
|
||||||
property var container: horizontal ? row : column
|
property var container: horizontal ? row : column
|
||||||
|
|
||||||
Settings {
|
Settings {
|
||||||
category: "toolbar/" + window.objectName
|
category: "toolbar/" + window.objectName
|
||||||
property alias x: window.x
|
property alias x: window.x
|
||||||
|
|
|
@ -4,48 +4,20 @@ import QtQuick.Controls 1.4
|
||||||
Item {
|
Item {
|
||||||
id: button
|
id: button
|
||||||
property alias imageURL: image.source
|
property alias imageURL: image.source
|
||||||
property alias alpha: button.opacity
|
property alias alpha: image.opacity
|
||||||
property var subImage;
|
property var subImage;
|
||||||
property int yOffset: 0
|
property int yOffset: 0
|
||||||
property int buttonState: 0
|
property int buttonState: 0
|
||||||
property int hoverOffset: 0
|
property int hoverState: -1
|
||||||
|
property int defaultState: -1
|
||||||
property var toolbar;
|
property var toolbar;
|
||||||
property real size: 50 // toolbar ? toolbar.buttonSize : 50
|
property real size: 50 // toolbar ? toolbar.buttonSize : 50
|
||||||
width: size; height: size
|
width: size; height: size
|
||||||
property bool pinned: false
|
property bool pinned: false
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
Behavior on opacity {
|
|
||||||
NumberAnimation {
|
|
||||||
duration: 150
|
|
||||||
easing.type: Easing.InOutCubic
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
property alias fadeTargetProperty: button.opacity
|
|
||||||
|
|
||||||
onFadeTargetPropertyChanged: {
|
|
||||||
visible = (fadeTargetProperty !== 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
onVisibleChanged: {
|
|
||||||
if ((!visible && fadeTargetProperty != 0.0) || (visible && fadeTargetProperty == 0.0)) {
|
|
||||||
var target = visible;
|
|
||||||
visible = !visible;
|
|
||||||
fadeTargetProperty = target ? 1.0 : 0.0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateOffset() {
|
|
||||||
yOffset = size * (buttonState + hoverOffset);
|
|
||||||
}
|
|
||||||
onButtonStateChanged: {
|
onButtonStateChanged: {
|
||||||
hoverOffset = 0; // subtle: show the new state without hover. don't wait for mouse to be moved away
|
yOffset = size * buttonState;
|
||||||
// The above is per UX design, but ALSO avoid a subtle issue that would be a problem because
|
|
||||||
// the hand controllers don't move the mouse when not triggered, so releasing the trigger would
|
|
||||||
// never show unhovered.
|
|
||||||
updateOffset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
@ -64,18 +36,28 @@ Item {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: asyncClickSender
|
||||||
|
interval: 10
|
||||||
|
repeat: false
|
||||||
|
running: false
|
||||||
|
onTriggered: button.clicked();
|
||||||
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: button.clicked();
|
onClicked: asyncClickSender.start();
|
||||||
onEntered: {
|
onEntered: {
|
||||||
hoverOffset = 2;
|
if (hoverState > 0) {
|
||||||
updateOffset();
|
buttonState = hoverState;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onExited: {
|
onExited: {
|
||||||
hoverOffset = 0;
|
if (defaultState > 0) {
|
||||||
updateOffset();
|
buttonState = defaultState;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,15 +43,19 @@ Rectangle {
|
||||||
// Enable dragging of the window,
|
// Enable dragging of the window,
|
||||||
// detect mouseover of the window (including decoration)
|
// detect mouseover of the window (including decoration)
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
id: decorationMouseArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
drag.target: window
|
drag.target: window
|
||||||
|
hoverEnabled: true
|
||||||
|
onEntered: window.mouseEntered();
|
||||||
|
onExited: window.mouseExited();
|
||||||
}
|
}
|
||||||
Connections {
|
Connections {
|
||||||
target: window
|
target: window
|
||||||
onMouseEntered: {
|
onMouseEntered: {
|
||||||
if (desktop.hmdHandMouseActive) {
|
if (desktop.hmdHandMouseActive) {
|
||||||
root.inflateDecorations()
|
root.inflateDecorations()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onMouseExited: root.deflateDecorations();
|
onMouseExited: root.deflateDecorations();
|
||||||
}
|
}
|
||||||
|
@ -59,7 +63,7 @@ Rectangle {
|
||||||
target: desktop
|
target: desktop
|
||||||
onHmdHandMouseActiveChanged: {
|
onHmdHandMouseActiveChanged: {
|
||||||
if (desktop.hmdHandMouseActive) {
|
if (desktop.hmdHandMouseActive) {
|
||||||
if (window.activator.containsMouse) {
|
if (decorationMouseArea.containsMouse) {
|
||||||
root.inflateDecorations();
|
root.inflateDecorations();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -115,14 +115,10 @@ Fadable {
|
||||||
propagateComposedEvents: true
|
propagateComposedEvents: true
|
||||||
acceptedButtons: Qt.AllButtons
|
acceptedButtons: Qt.AllButtons
|
||||||
enabled: window.visible
|
enabled: window.visible
|
||||||
hoverEnabled: true
|
|
||||||
onPressed: {
|
onPressed: {
|
||||||
//console.log("Pressed on activator area");
|
|
||||||
window.raise();
|
window.raise();
|
||||||
mouse.accepted = false;
|
mouse.accepted = false;
|
||||||
}
|
}
|
||||||
onEntered: window.mouseEntered();
|
|
||||||
onExited: window.mouseExited();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This mouse area serves to swallow mouse events while the mouse is over the window
|
// This mouse area serves to swallow mouse events while the mouse is over the window
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
#include "ToolbarScriptingInterface.h"
|
#include "ToolbarScriptingInterface.h"
|
||||||
|
|
||||||
|
#include <QtCore/QThread>
|
||||||
|
|
||||||
#include <OffscreenUi.h>
|
#include <OffscreenUi.h>
|
||||||
|
|
||||||
class QmlWrapper : public QObject {
|
class QmlWrapper : public QObject {
|
||||||
|
@ -79,7 +81,11 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE QObject* addButton(const QVariant& properties) {
|
Q_INVOKABLE QObject* addButton(const QVariant& properties) {
|
||||||
QVariant resultVar;
|
QVariant resultVar;
|
||||||
bool invokeResult = QMetaObject::invokeMethod(_qmlObject, "addButton", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QVariant, resultVar), Q_ARG(QVariant, properties));
|
Qt::ConnectionType connectionType = Qt::AutoConnection;
|
||||||
|
if (QThread::currentThread() != _qmlObject->thread()) {
|
||||||
|
connectionType = Qt::BlockingQueuedConnection;
|
||||||
|
}
|
||||||
|
bool invokeResult = QMetaObject::invokeMethod(_qmlObject, "addButton", connectionType, Q_RETURN_ARG(QVariant, resultVar), Q_ARG(QVariant, properties));
|
||||||
if (!invokeResult) {
|
if (!invokeResult) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -101,8 +107,12 @@ public:
|
||||||
QObject* ToolbarScriptingInterface::getToolbar(const QString& toolbarId) {
|
QObject* ToolbarScriptingInterface::getToolbar(const QString& toolbarId) {
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
auto desktop = offscreenUi->getDesktop();
|
auto desktop = offscreenUi->getDesktop();
|
||||||
|
Qt::ConnectionType connectionType = Qt::AutoConnection;
|
||||||
|
if (QThread::currentThread() != desktop->thread()) {
|
||||||
|
connectionType = Qt::BlockingQueuedConnection;
|
||||||
|
}
|
||||||
QVariant resultVar;
|
QVariant resultVar;
|
||||||
bool invokeResult = QMetaObject::invokeMethod(desktop, "getToolbar", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QVariant, resultVar), Q_ARG(QVariant, toolbarId));
|
bool invokeResult = QMetaObject::invokeMethod(desktop, "getToolbar", connectionType, Q_RETURN_ARG(QVariant, resultVar), Q_ARG(QVariant, toolbarId));
|
||||||
if (!invokeResult) {
|
if (!invokeResult) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,13 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||||
|
var EDIT_TOGGLE_BUTTON = "com.highfidelity.interface.system.editButton";
|
||||||
|
var SYSTEM_TOOLBAR = "com.highfidelity.interface.toolbar.system";
|
||||||
|
var EDIT_TOOLBAR = "com.highfidelity.interface.toolbar.edit";
|
||||||
|
|
||||||
Script.include([
|
Script.include([
|
||||||
"libraries/stringHelpers.js",
|
"libraries/stringHelpers.js",
|
||||||
"libraries/dataViewHelpers.js",
|
"libraries/dataViewHelpers.js",
|
||||||
"libraries/toolBars.js",
|
|
||||||
"libraries/progressDialog.js",
|
"libraries/progressDialog.js",
|
||||||
|
|
||||||
"libraries/entitySelectionTool.js",
|
"libraries/entitySelectionTool.js",
|
||||||
|
@ -50,11 +52,6 @@ selectionManager.addEventListener(function() {
|
||||||
lightOverlayManager.updatePositions();
|
lightOverlayManager.updatePositions();
|
||||||
});
|
});
|
||||||
|
|
||||||
var toolIconUrl = Script.resolvePath("assets/images/tools/");
|
|
||||||
var toolHeight = 50;
|
|
||||||
var toolWidth = 50;
|
|
||||||
var TOOLBAR_MARGIN_Y = 0;
|
|
||||||
|
|
||||||
var DEGREES_TO_RADIANS = Math.PI / 180.0;
|
var DEGREES_TO_RADIANS = Math.PI / 180.0;
|
||||||
var RADIANS_TO_DEGREES = 180.0 / Math.PI;
|
var RADIANS_TO_DEGREES = 180.0 / Math.PI;
|
||||||
var epsilon = 0.001;
|
var epsilon = 0.001;
|
||||||
|
@ -98,12 +95,11 @@ var INSUFFICIENT_PERMISSIONS_IMPORT_ERROR_MSG = "You do not have the necessary p
|
||||||
var mode = 0;
|
var mode = 0;
|
||||||
var isActive = false;
|
var isActive = false;
|
||||||
|
|
||||||
var placingEntityID = null;
|
|
||||||
|
|
||||||
IMPORTING_SVO_OVERLAY_WIDTH = 144;
|
IMPORTING_SVO_OVERLAY_WIDTH = 144;
|
||||||
IMPORTING_SVO_OVERLAY_HEIGHT = 30;
|
IMPORTING_SVO_OVERLAY_HEIGHT = 30;
|
||||||
IMPORTING_SVO_OVERLAY_MARGIN = 5;
|
IMPORTING_SVO_OVERLAY_MARGIN = 5;
|
||||||
IMPORTING_SVO_OVERLAY_LEFT_MARGIN = 34;
|
IMPORTING_SVO_OVERLAY_LEFT_MARGIN = 34;
|
||||||
|
|
||||||
var importingSVOImageOverlay = Overlays.addOverlay("image", {
|
var importingSVOImageOverlay = Overlays.addOverlay("image", {
|
||||||
imageURL: Script.resolvePath("assets") + "/images/hourglass.svg",
|
imageURL: Script.resolvePath("assets") + "/images/hourglass.svg",
|
||||||
width: 20,
|
width: 20,
|
||||||
|
@ -168,241 +164,15 @@ function toggleMarketplace() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var toolBar = (function() {
|
var toolBar = (function() {
|
||||||
|
var EDIT_SETTING = "io.highfidelity.isEditting"; // for communication with other scripts
|
||||||
|
var TOOL_ICON_URL = Script.resolvePath("assets/images/tools/");
|
||||||
var that = {},
|
var that = {},
|
||||||
toolBar,
|
toolBar,
|
||||||
activeButton,
|
systemToolbar,
|
||||||
newModelButton,
|
activeButton;
|
||||||
newCubeButton,
|
|
||||||
newSphereButton,
|
function createNewEntity(properties) {
|
||||||
newLightButton,
|
Settings.setValue(EDIT_SETTING, false);
|
||||||
newTextButton,
|
|
||||||
newWebButton,
|
|
||||||
newZoneButton,
|
|
||||||
newParticleButton
|
|
||||||
|
|
||||||
function initialize() {
|
|
||||||
toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL, "highfidelity.edit.toolbar", function(windowDimensions, toolbar) {
|
|
||||||
return {
|
|
||||||
x: (windowDimensions.x / 2) + (Tool.IMAGE_WIDTH * 2),
|
|
||||||
y: windowDimensions.y
|
|
||||||
};
|
|
||||||
}, {
|
|
||||||
x: toolWidth,
|
|
||||||
y: -TOOLBAR_MARGIN_Y - toolHeight
|
|
||||||
});
|
|
||||||
|
|
||||||
activeButton = toolBar.addTool({
|
|
||||||
imageURL: toolIconUrl + "edit.svg",
|
|
||||||
subImage: {
|
|
||||||
x: 0,
|
|
||||||
y: Tool.IMAGE_WIDTH,
|
|
||||||
width: Tool.IMAGE_WIDTH,
|
|
||||||
height: Tool.IMAGE_HEIGHT
|
|
||||||
},
|
|
||||||
width: toolWidth,
|
|
||||||
height: toolHeight,
|
|
||||||
alpha: 0.9,
|
|
||||||
visible: true
|
|
||||||
}, true, false);
|
|
||||||
|
|
||||||
newModelButton = toolBar.addTool({
|
|
||||||
imageURL: toolIconUrl + "model-01.svg",
|
|
||||||
subImage: {
|
|
||||||
x: 0,
|
|
||||||
y: Tool.IMAGE_WIDTH,
|
|
||||||
width: Tool.IMAGE_WIDTH,
|
|
||||||
height: Tool.IMAGE_HEIGHT
|
|
||||||
},
|
|
||||||
width: toolWidth,
|
|
||||||
height: toolHeight,
|
|
||||||
alpha: 0.9,
|
|
||||||
showButtonDown: true,
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
|
|
||||||
newCubeButton = toolBar.addTool({
|
|
||||||
imageURL: toolIconUrl + "cube-01.svg",
|
|
||||||
subImage: {
|
|
||||||
x: 0,
|
|
||||||
y: Tool.IMAGE_WIDTH,
|
|
||||||
width: Tool.IMAGE_WIDTH,
|
|
||||||
height: Tool.IMAGE_HEIGHT
|
|
||||||
},
|
|
||||||
width: toolWidth,
|
|
||||||
height: toolHeight,
|
|
||||||
alpha: 0.9,
|
|
||||||
showButtonDown: true,
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
|
|
||||||
newSphereButton = toolBar.addTool({
|
|
||||||
imageURL: toolIconUrl + "sphere-01.svg",
|
|
||||||
subImage: {
|
|
||||||
x: 0,
|
|
||||||
y: Tool.IMAGE_WIDTH,
|
|
||||||
width: Tool.IMAGE_WIDTH,
|
|
||||||
height: Tool.IMAGE_HEIGHT
|
|
||||||
},
|
|
||||||
width: toolWidth,
|
|
||||||
height: toolHeight,
|
|
||||||
alpha: 0.9,
|
|
||||||
showButtonDown: true,
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
|
|
||||||
newLightButton = toolBar.addTool({
|
|
||||||
imageURL: toolIconUrl + "light-01.svg",
|
|
||||||
subImage: {
|
|
||||||
x: 0,
|
|
||||||
y: Tool.IMAGE_WIDTH,
|
|
||||||
width: Tool.IMAGE_WIDTH,
|
|
||||||
height: Tool.IMAGE_HEIGHT
|
|
||||||
},
|
|
||||||
width: toolWidth,
|
|
||||||
height: toolHeight,
|
|
||||||
alpha: 0.9,
|
|
||||||
showButtonDown: true,
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
|
|
||||||
newTextButton = toolBar.addTool({
|
|
||||||
imageURL: toolIconUrl + "text-01.svg",
|
|
||||||
subImage: {
|
|
||||||
x: 0,
|
|
||||||
y: Tool.IMAGE_WIDTH,
|
|
||||||
width: Tool.IMAGE_WIDTH,
|
|
||||||
height: Tool.IMAGE_HEIGHT
|
|
||||||
},
|
|
||||||
width: toolWidth,
|
|
||||||
height: toolHeight,
|
|
||||||
alpha: 0.9,
|
|
||||||
showButtonDown: true,
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
|
|
||||||
newWebButton = toolBar.addTool({
|
|
||||||
imageURL: toolIconUrl + "web-01.svg",
|
|
||||||
subImage: {
|
|
||||||
x: 0,
|
|
||||||
y: Tool.IMAGE_WIDTH,
|
|
||||||
width: Tool.IMAGE_WIDTH,
|
|
||||||
height: Tool.IMAGE_HEIGHT
|
|
||||||
},
|
|
||||||
width: toolWidth,
|
|
||||||
height: toolHeight,
|
|
||||||
alpha: 0.9,
|
|
||||||
showButtonDown: true,
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
|
|
||||||
newZoneButton = toolBar.addTool({
|
|
||||||
imageURL: toolIconUrl + "zone-01.svg",
|
|
||||||
subImage: {
|
|
||||||
x: 0,
|
|
||||||
y: Tool.IMAGE_WIDTH,
|
|
||||||
width: Tool.IMAGE_WIDTH,
|
|
||||||
height: Tool.IMAGE_HEIGHT
|
|
||||||
},
|
|
||||||
width: toolWidth,
|
|
||||||
height: toolHeight,
|
|
||||||
alpha: 0.9,
|
|
||||||
showButtonDown: true,
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
|
|
||||||
newParticleButton = toolBar.addTool({
|
|
||||||
imageURL: toolIconUrl + "particle-01.svg",
|
|
||||||
subImage: {
|
|
||||||
x: 0,
|
|
||||||
y: Tool.IMAGE_WIDTH,
|
|
||||||
width: Tool.IMAGE_WIDTH,
|
|
||||||
height: Tool.IMAGE_HEIGHT
|
|
||||||
},
|
|
||||||
width: toolWidth,
|
|
||||||
height: toolHeight,
|
|
||||||
alpha: 0.9,
|
|
||||||
showButtonDown: true,
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
|
|
||||||
that.setActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
that.clearEntityList = function() {
|
|
||||||
entityListTool.clearEntityList();
|
|
||||||
};
|
|
||||||
|
|
||||||
var EDIT_SETTING = "io.highfidelity.isEditting"; // for communication with other scripts
|
|
||||||
Settings.setValue(EDIT_SETTING, false);
|
|
||||||
that.setActive = function(active) {
|
|
||||||
if (active != isActive) {
|
|
||||||
if (active && !Entities.canRez() && !Entities.canRezTmp()) {
|
|
||||||
Window.alert(INSUFFICIENT_PERMISSIONS_ERROR_MSG);
|
|
||||||
} else {
|
|
||||||
Messages.sendLocalMessage("edit-events", JSON.stringify({
|
|
||||||
enabled: active
|
|
||||||
}));
|
|
||||||
isActive = active;
|
|
||||||
Settings.setValue(EDIT_SETTING, active);
|
|
||||||
if (!isActive) {
|
|
||||||
entityListTool.setVisible(false);
|
|
||||||
gridTool.setVisible(false);
|
|
||||||
grid.setEnabled(false);
|
|
||||||
propertiesTool.setVisible(false);
|
|
||||||
selectionManager.clearSelections();
|
|
||||||
cameraManager.disable();
|
|
||||||
selectionDisplay.triggerMapping.disable();
|
|
||||||
} else {
|
|
||||||
UserActivityLogger.enabledEdit();
|
|
||||||
hasShownPropertiesTool = false;
|
|
||||||
entityListTool.setVisible(true);
|
|
||||||
gridTool.setVisible(true);
|
|
||||||
grid.setEnabled(true);
|
|
||||||
propertiesTool.setVisible(true);
|
|
||||||
// Not sure what the following was meant to accomplish, but it currently causes
|
|
||||||
selectionDisplay.triggerMapping.enable();
|
|
||||||
// everybody else to think that Interface has lost focus overall. fogbugzid:558
|
|
||||||
// Window.setFocus();
|
|
||||||
}
|
|
||||||
that.showTools(isActive);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
toolBar.selectTool(activeButton, isActive);
|
|
||||||
lightOverlayManager.setVisible(isActive && Menu.isOptionChecked(MENU_SHOW_LIGHTS_IN_EDIT_MODE));
|
|
||||||
Entities.setDrawZoneBoundaries(isActive && Menu.isOptionChecked(MENU_SHOW_ZONES_IN_EDIT_MODE));
|
|
||||||
};
|
|
||||||
|
|
||||||
// Sets visibility of tool buttons, excluding the power button
|
|
||||||
that.showTools = function(doShow) {
|
|
||||||
toolBar.showTool(newModelButton, doShow);
|
|
||||||
toolBar.showTool(newCubeButton, doShow);
|
|
||||||
toolBar.showTool(newSphereButton, doShow);
|
|
||||||
toolBar.showTool(newLightButton, doShow);
|
|
||||||
toolBar.showTool(newTextButton, doShow);
|
|
||||||
toolBar.showTool(newWebButton, doShow);
|
|
||||||
toolBar.showTool(newZoneButton, doShow);
|
|
||||||
toolBar.showTool(newParticleButton, doShow);
|
|
||||||
};
|
|
||||||
|
|
||||||
var RESIZE_INTERVAL = 50;
|
|
||||||
var RESIZE_TIMEOUT = 120000; // 2 minutes
|
|
||||||
var RESIZE_MAX_CHECKS = RESIZE_TIMEOUT / RESIZE_INTERVAL;
|
|
||||||
|
|
||||||
function addModel(url) {
|
|
||||||
var entityID = createNewEntity({
|
|
||||||
type: "Model",
|
|
||||||
modelURL: url
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
if (entityID) {
|
|
||||||
print("Model added: " + url);
|
|
||||||
selectionManager.setSelections([entityID]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function createNewEntity(properties, dragOnCreate) {
|
|
||||||
// Default to true if not passed in
|
|
||||||
dragOnCreate = dragOnCreate == undefined ? true : dragOnCreate;
|
|
||||||
|
|
||||||
var dimensions = properties.dimensions ? properties.dimensions : DEFAULT_DIMENSIONS;
|
var dimensions = properties.dimensions ? properties.dimensions : DEFAULT_DIMENSIONS;
|
||||||
var position = getPositionToCreateEntity();
|
var position = getPositionToCreateEntity();
|
||||||
|
@ -410,11 +180,7 @@ var toolBar = (function() {
|
||||||
if (position != null) {
|
if (position != null) {
|
||||||
position = grid.snapToSurface(grid.snapToGrid(position, false, dimensions), dimensions),
|
position = grid.snapToSurface(grid.snapToGrid(position, false, dimensions), dimensions),
|
||||||
properties.position = position;
|
properties.position = position;
|
||||||
|
|
||||||
entityID = Entities.addEntity(properties);
|
entityID = Entities.addEntity(properties);
|
||||||
if (dragOnCreate) {
|
|
||||||
placingEntityID = entityID;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Window.alert("Can't create " + properties.type + ": " + properties.type + " would be out of bounds.");
|
Window.alert("Can't create " + properties.type + ": " + properties.type + " would be out of bounds.");
|
||||||
}
|
}
|
||||||
|
@ -426,35 +192,69 @@ var toolBar = (function() {
|
||||||
return entityID;
|
return entityID;
|
||||||
}
|
}
|
||||||
|
|
||||||
that.mousePressEvent = function(event) {
|
function cleanup() {
|
||||||
var clickedOverlay,
|
that.setActive(false);
|
||||||
url,
|
systemToolbar.removeButton(EDIT_TOGGLE_BUTTON);
|
||||||
file;
|
}
|
||||||
|
|
||||||
if (!event.isLeftButton) {
|
function addButton(name, image, handler) {
|
||||||
// if another mouse button than left is pressed ignore it
|
var imageUrl = TOOL_ICON_URL + image;
|
||||||
return false;
|
var button = toolBar.addButton({
|
||||||
|
objectName: name,
|
||||||
|
imageURL: imageUrl,
|
||||||
|
buttonState: 1,
|
||||||
|
alpha: 0.9,
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
if (handler) {
|
||||||
|
button.clicked.connect(function() {
|
||||||
|
Script.setTimeout(handler, 100);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
clickedOverlay = Overlays.getOverlayAtPoint({
|
function initialize() {
|
||||||
x: event.x,
|
print("QQQ creating edit toolbar");
|
||||||
y: event.y
|
Script.scriptEnding.connect(cleanup);
|
||||||
|
|
||||||
|
Window.domainChanged.connect(function() {
|
||||||
|
that.setActive(false);
|
||||||
|
that.clearEntityList();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (activeButton === toolBar.clicked(clickedOverlay)) {
|
Entities.canAdjustLocksChanged.connect(function(canAdjustLocks) {
|
||||||
that.setActive(!isActive);
|
if (isActive && !canAdjustLocks) {
|
||||||
return true;
|
that.setActive(false);
|
||||||
}
|
|
||||||
|
|
||||||
if (newModelButton === toolBar.clicked(clickedOverlay)) {
|
|
||||||
url = Window.prompt("Model URL");
|
|
||||||
if (url !== null && url !== "") {
|
|
||||||
addModel(url);
|
|
||||||
}
|
}
|
||||||
return true;
|
});
|
||||||
}
|
|
||||||
|
|
||||||
if (newCubeButton === toolBar.clicked(clickedOverlay)) {
|
systemToolbar = Toolbars.getToolbar(SYSTEM_TOOLBAR);
|
||||||
|
activeButton = systemToolbar.addButton({
|
||||||
|
objectName: EDIT_TOGGLE_BUTTON,
|
||||||
|
imageURL: TOOL_ICON_URL + "edit.svg",
|
||||||
|
visible: true,
|
||||||
|
buttonState: 1,
|
||||||
|
});
|
||||||
|
activeButton.clicked.connect(function() {
|
||||||
|
that.setActive(!isActive);
|
||||||
|
activeButton.writeProperty("buttonState", isActive ? 0 : 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
toolBar = Toolbars.getToolbar(EDIT_TOOLBAR);
|
||||||
|
toolBar.writeProperty("shown", false);
|
||||||
|
|
||||||
|
addButton("newModelButton", "model-01.svg", function() {
|
||||||
|
var url = Window.prompt("Model URL");
|
||||||
|
if (url !== null && url !== "") {
|
||||||
|
createNewEntity({
|
||||||
|
type: "Model",
|
||||||
|
modelURL: url
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
addButton("newCubeButton", "cube-01.svg", function() {
|
||||||
createNewEntity({
|
createNewEntity({
|
||||||
type: "Box",
|
type: "Box",
|
||||||
dimensions: DEFAULT_DIMENSIONS,
|
dimensions: DEFAULT_DIMENSIONS,
|
||||||
|
@ -464,11 +264,9 @@ var toolBar = (function() {
|
||||||
blue: 0
|
blue: 0
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
addButton("newSphereButton", "sphere-01.svg", function() {
|
||||||
}
|
|
||||||
|
|
||||||
if (newSphereButton === toolBar.clicked(clickedOverlay)) {
|
|
||||||
createNewEntity({
|
createNewEntity({
|
||||||
type: "Sphere",
|
type: "Sphere",
|
||||||
dimensions: DEFAULT_DIMENSIONS,
|
dimensions: DEFAULT_DIMENSIONS,
|
||||||
|
@ -478,11 +276,9 @@ var toolBar = (function() {
|
||||||
blue: 0
|
blue: 0
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
addButton("newLightButton", "light-01.svg", function() {
|
||||||
}
|
|
||||||
|
|
||||||
if (newLightButton === toolBar.clicked(clickedOverlay)) {
|
|
||||||
createNewEntity({
|
createNewEntity({
|
||||||
type: "Light",
|
type: "Light",
|
||||||
dimensions: DEFAULT_LIGHT_DIMENSIONS,
|
dimensions: DEFAULT_LIGHT_DIMENSIONS,
|
||||||
|
@ -499,11 +295,9 @@ var toolBar = (function() {
|
||||||
exponent: 0,
|
exponent: 0,
|
||||||
cutoff: 180, // in degrees
|
cutoff: 180, // in degrees
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
addButton("newTextButton", "text-01.svg", function() {
|
||||||
}
|
|
||||||
|
|
||||||
if (newTextButton === toolBar.clicked(clickedOverlay)) {
|
|
||||||
createNewEntity({
|
createNewEntity({
|
||||||
type: "Text",
|
type: "Text",
|
||||||
dimensions: {
|
dimensions: {
|
||||||
|
@ -524,11 +318,9 @@ var toolBar = (function() {
|
||||||
text: "some text",
|
text: "some text",
|
||||||
lineHeight: 0.06
|
lineHeight: 0.06
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
addButton("newWebButton", "web-01.svg", function() {
|
||||||
}
|
|
||||||
|
|
||||||
if (newWebButton === toolBar.clicked(clickedOverlay)) {
|
|
||||||
createNewEntity({
|
createNewEntity({
|
||||||
type: "Web",
|
type: "Web",
|
||||||
dimensions: {
|
dimensions: {
|
||||||
|
@ -538,11 +330,9 @@ var toolBar = (function() {
|
||||||
},
|
},
|
||||||
sourceUrl: "https://highfidelity.com/",
|
sourceUrl: "https://highfidelity.com/",
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
addButton("newZoneButton", "zone-01.svg", function() {
|
||||||
}
|
|
||||||
|
|
||||||
if (newZoneButton === toolBar.clicked(clickedOverlay)) {
|
|
||||||
createNewEntity({
|
createNewEntity({
|
||||||
type: "Zone",
|
type: "Zone",
|
||||||
dimensions: {
|
dimensions: {
|
||||||
|
@ -551,11 +341,9 @@ var toolBar = (function() {
|
||||||
z: 10
|
z: 10
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
addButton("newParticleButton", "particle-01.svg", function() {
|
||||||
}
|
|
||||||
|
|
||||||
if (newParticleButton === toolBar.clicked(clickedOverlay)) {
|
|
||||||
createNewEntity({
|
createNewEntity({
|
||||||
type: "ParticleEffect",
|
type: "ParticleEffect",
|
||||||
isEmitting: true,
|
isEmitting: true,
|
||||||
|
@ -577,33 +365,63 @@ var toolBar = (function() {
|
||||||
emitRate: 100,
|
emitRate: 100,
|
||||||
textures: "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png",
|
textures: "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png",
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
return false;
|
that.setActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
that.clearEntityList = function() {
|
||||||
|
entityListTool.clearEntityList();
|
||||||
};
|
};
|
||||||
|
|
||||||
that.mouseReleaseEvent = function(event) {
|
that.setActive = function(active) {
|
||||||
return false;
|
if (active == isActive) {
|
||||||
}
|
return;
|
||||||
|
|
||||||
Window.domainChanged.connect(function() {
|
|
||||||
that.setActive(false);
|
|
||||||
that.clearEntityList();
|
|
||||||
});
|
|
||||||
|
|
||||||
Entities.canAdjustLocksChanged.connect(function(canAdjustLocks) {
|
|
||||||
if (isActive && !canAdjustLocks) {
|
|
||||||
that.setActive(false);
|
|
||||||
}
|
}
|
||||||
});
|
if (active && !Entities.canRez() && !Entities.canRezTmp()) {
|
||||||
|
Window.alert(INSUFFICIENT_PERMISSIONS_ERROR_MSG);
|
||||||
that.cleanup = function() {
|
return;
|
||||||
toolBar.cleanup();
|
}
|
||||||
|
Messages.sendLocalMessage("edit-events", JSON.stringify({
|
||||||
|
enabled: active
|
||||||
|
}));
|
||||||
|
isActive = active;
|
||||||
|
Settings.setValue(EDIT_SETTING, active);
|
||||||
|
if (!isActive) {
|
||||||
|
entityListTool.setVisible(false);
|
||||||
|
gridTool.setVisible(false);
|
||||||
|
grid.setEnabled(false);
|
||||||
|
propertiesTool.setVisible(false);
|
||||||
|
selectionManager.clearSelections();
|
||||||
|
cameraManager.disable();
|
||||||
|
selectionDisplay.triggerMapping.disable();
|
||||||
|
} else {
|
||||||
|
UserActivityLogger.enabledEdit();
|
||||||
|
hasShownPropertiesTool = false;
|
||||||
|
entityListTool.setVisible(true);
|
||||||
|
gridTool.setVisible(true);
|
||||||
|
grid.setEnabled(true);
|
||||||
|
propertiesTool.setVisible(true);
|
||||||
|
selectionDisplay.triggerMapping.enable();
|
||||||
|
// Not sure what the following was meant to accomplish, but it currently causes
|
||||||
|
// everybody else to think that Interface has lost focus overall. fogbugzid:558
|
||||||
|
// Window.setFocus();
|
||||||
|
}
|
||||||
|
// Sets visibility of tool buttons, excluding the power button
|
||||||
|
toolBar.writeProperty("shown", active);
|
||||||
|
var visible = toolBar.readProperty("visible");
|
||||||
|
if (active && !visible) {
|
||||||
|
toolBar.writeProperty("shown", false);
|
||||||
|
toolBar.writeProperty("shown", true);
|
||||||
|
}
|
||||||
|
//toolBar.selectTool(activeButton, isActive);
|
||||||
|
lightOverlayManager.setVisible(isActive && Menu.isOptionChecked(MENU_SHOW_LIGHTS_IN_EDIT_MODE));
|
||||||
|
Entities.setDrawZoneBoundaries(isActive && Menu.isOptionChecked(MENU_SHOW_ZONES_IN_EDIT_MODE));
|
||||||
};
|
};
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
return that;
|
return that;
|
||||||
}());
|
})();
|
||||||
|
|
||||||
|
|
||||||
function isLocked(properties) {
|
function isLocked(properties) {
|
||||||
|
@ -712,7 +530,7 @@ function mousePressEvent(event) {
|
||||||
mouseHasMovedSincePress = false;
|
mouseHasMovedSincePress = false;
|
||||||
mouseCapturedByTool = false;
|
mouseCapturedByTool = false;
|
||||||
|
|
||||||
if (propertyMenu.mousePressEvent(event) || toolBar.mousePressEvent(event) || progressDialog.mousePressEvent(event)) {
|
if (propertyMenu.mousePressEvent(event) || progressDialog.mousePressEvent(event)) {
|
||||||
mouseCapturedByTool = true;
|
mouseCapturedByTool = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -755,16 +573,6 @@ function mouseMove(event) {
|
||||||
mouseHasMovedSincePress = true;
|
mouseHasMovedSincePress = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (placingEntityID) {
|
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
|
||||||
var distance = cameraManager.enabled ? cameraManager.zoomDistance : DEFAULT_ENTITY_DRAG_DROP_DISTANCE;
|
|
||||||
var offset = Vec3.multiply(distance, pickRay.direction);
|
|
||||||
var position = Vec3.sum(Camera.position, offset);
|
|
||||||
Entities.editEntity(placingEntityID, {
|
|
||||||
position: position,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!isActive) {
|
if (!isActive) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -796,20 +604,10 @@ function mouseReleaseEvent(event) {
|
||||||
mouseMove(lastMouseMoveEvent);
|
mouseMove(lastMouseMoveEvent);
|
||||||
lastMouseMoveEvent = null;
|
lastMouseMoveEvent = null;
|
||||||
}
|
}
|
||||||
if (propertyMenu.mouseReleaseEvent(event) || toolBar.mouseReleaseEvent(event)) {
|
if (propertyMenu.mouseReleaseEvent(event)) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (placingEntityID) {
|
|
||||||
|
|
||||||
if (isActive) {
|
|
||||||
|
|
||||||
selectionManager.setSelections([placingEntityID]);
|
|
||||||
}
|
|
||||||
placingEntityID = null;
|
|
||||||
}
|
|
||||||
if (isActive && selectionManager.hasSelection()) {
|
if (isActive && selectionManager.hasSelection()) {
|
||||||
|
|
||||||
tooltip.show(false);
|
tooltip.show(false);
|
||||||
}
|
}
|
||||||
if (mouseCapturedByTool) {
|
if (mouseCapturedByTool) {
|
||||||
|
@ -1094,7 +892,6 @@ Script.scriptEnding.connect(function() {
|
||||||
Settings.setValue(SETTING_SHOW_ZONES_IN_EDIT_MODE, Menu.isOptionChecked(MENU_SHOW_ZONES_IN_EDIT_MODE));
|
Settings.setValue(SETTING_SHOW_ZONES_IN_EDIT_MODE, Menu.isOptionChecked(MENU_SHOW_ZONES_IN_EDIT_MODE));
|
||||||
|
|
||||||
progressDialog.cleanup();
|
progressDialog.cleanup();
|
||||||
toolBar.cleanup();
|
|
||||||
cleanupModelMenus();
|
cleanupModelMenus();
|
||||||
tooltip.cleanup();
|
tooltip.cleanup();
|
||||||
selectionDisplay.cleanup();
|
selectionDisplay.cleanup();
|
||||||
|
|
|
@ -69,6 +69,7 @@ browseExamplesButton.clicked.connect(onClick);
|
||||||
examplesWindow.visibleChanged.connect(onExamplesWindowVisibilityChanged);
|
examplesWindow.visibleChanged.connect(onExamplesWindowVisibilityChanged);
|
||||||
|
|
||||||
Script.scriptEnding.connect(function () {
|
Script.scriptEnding.connect(function () {
|
||||||
|
toolBar.removeButton("examples");
|
||||||
browseExamplesButton.clicked.disconnect(onClick);
|
browseExamplesButton.clicked.disconnect(onClick);
|
||||||
examplesWindow.visibleChanged.disconnect(onExamplesWindowVisibilityChanged);
|
examplesWindow.visibleChanged.disconnect(onExamplesWindowVisibilityChanged);
|
||||||
});
|
});
|
||||||
|
|
|
@ -30,6 +30,7 @@ button.clicked.connect(onClicked);
|
||||||
DialogsManager.addressBarShown.connect(onAddressBarShown);
|
DialogsManager.addressBarShown.connect(onAddressBarShown);
|
||||||
|
|
||||||
Script.scriptEnding.connect(function () {
|
Script.scriptEnding.connect(function () {
|
||||||
|
toolBar.removeButton("goto");
|
||||||
button.clicked.disconnect(onClicked);
|
button.clicked.disconnect(onClicked);
|
||||||
DialogsManager.addressBarShown.disconnect(onAddressBarShown);
|
DialogsManager.addressBarShown.disconnect(onAddressBarShown);
|
||||||
});
|
});
|
||||||
|
|
|
@ -40,6 +40,7 @@ if (headset) {
|
||||||
HMD.displayModeChanged.connect(onHmdChanged);
|
HMD.displayModeChanged.connect(onHmdChanged);
|
||||||
|
|
||||||
Script.scriptEnding.connect(function () {
|
Script.scriptEnding.connect(function () {
|
||||||
|
toolBar.removeButton("hmdToggle");
|
||||||
button.clicked.disconnect(onClicked);
|
button.clicked.disconnect(onClicked);
|
||||||
HMD.displayModeChanged.disconnect(onHmdChanged);
|
HMD.displayModeChanged.disconnect(onHmdChanged);
|
||||||
});
|
});
|
||||||
|
|
|
@ -34,6 +34,7 @@ button.clicked.connect(onClicked);
|
||||||
AudioDevice.muteToggled.connect(onMuteToggled);
|
AudioDevice.muteToggled.connect(onMuteToggled);
|
||||||
|
|
||||||
Script.scriptEnding.connect(function () {
|
Script.scriptEnding.connect(function () {
|
||||||
|
toolBar.removeButton("mute");
|
||||||
button.clicked.disconnect(onClicked);
|
button.clicked.disconnect(onClicked);
|
||||||
AudioDevice.muteToggled.disconnect(onMuteToggled);
|
AudioDevice.muteToggled.disconnect(onMuteToggled);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue