mirror of
https://github.com/overte-org/overte.git
synced 2025-04-09 13:02:24 +02: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
|
||||
width: content.width
|
||||
height: content.height
|
||||
visible: true
|
||||
// Disable this window from being able to call 'desktop.raise() and desktop.showDesktop'
|
||||
activator: MouseArea {
|
||||
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();
|
||||
}
|
||||
activator: Item {}
|
||||
property bool horizontal: true
|
||||
property real buttonSize: 50;
|
||||
property var buttons: []
|
||||
property var container: horizontal ? row : column
|
||||
|
||||
|
||||
Settings {
|
||||
category: "toolbar/" + window.objectName
|
||||
property alias x: window.x
|
||||
|
|
|
@ -4,48 +4,20 @@ import QtQuick.Controls 1.4
|
|||
Item {
|
||||
id: button
|
||||
property alias imageURL: image.source
|
||||
property alias alpha: button.opacity
|
||||
property alias alpha: image.opacity
|
||||
property var subImage;
|
||||
property int yOffset: 0
|
||||
property int buttonState: 0
|
||||
property int hoverOffset: 0
|
||||
property int hoverState: -1
|
||||
property int defaultState: -1
|
||||
property var toolbar;
|
||||
property real size: 50 // toolbar ? toolbar.buttonSize : 50
|
||||
width: size; height: size
|
||||
property bool pinned: false
|
||||
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: {
|
||||
hoverOffset = 0; // subtle: show the new state without hover. don't wait for mouse to be moved away
|
||||
// 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();
|
||||
yOffset = size * buttonState;
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
|
@ -64,18 +36,28 @@ Item {
|
|||
width: parent.width
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: asyncClickSender
|
||||
interval: 10
|
||||
repeat: false
|
||||
running: false
|
||||
onTriggered: button.clicked();
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
hoverEnabled: true
|
||||
anchors.fill: parent
|
||||
onClicked: button.clicked();
|
||||
onClicked: asyncClickSender.start();
|
||||
onEntered: {
|
||||
hoverOffset = 2;
|
||||
updateOffset();
|
||||
if (hoverState > 0) {
|
||||
buttonState = hoverState;
|
||||
}
|
||||
}
|
||||
onExited: {
|
||||
hoverOffset = 0;
|
||||
updateOffset();
|
||||
if (defaultState > 0) {
|
||||
buttonState = defaultState;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,15 +43,19 @@ Rectangle {
|
|||
// Enable dragging of the window,
|
||||
// detect mouseover of the window (including decoration)
|
||||
MouseArea {
|
||||
id: decorationMouseArea
|
||||
anchors.fill: parent
|
||||
drag.target: window
|
||||
hoverEnabled: true
|
||||
onEntered: window.mouseEntered();
|
||||
onExited: window.mouseExited();
|
||||
}
|
||||
Connections {
|
||||
target: window
|
||||
onMouseEntered: {
|
||||
if (desktop.hmdHandMouseActive) {
|
||||
root.inflateDecorations()
|
||||
}
|
||||
}
|
||||
}
|
||||
onMouseExited: root.deflateDecorations();
|
||||
}
|
||||
|
@ -59,7 +63,7 @@ Rectangle {
|
|||
target: desktop
|
||||
onHmdHandMouseActiveChanged: {
|
||||
if (desktop.hmdHandMouseActive) {
|
||||
if (window.activator.containsMouse) {
|
||||
if (decorationMouseArea.containsMouse) {
|
||||
root.inflateDecorations();
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -115,14 +115,10 @@ Fadable {
|
|||
propagateComposedEvents: true
|
||||
acceptedButtons: Qt.AllButtons
|
||||
enabled: window.visible
|
||||
hoverEnabled: true
|
||||
onPressed: {
|
||||
//console.log("Pressed on activator area");
|
||||
window.raise();
|
||||
mouse.accepted = false;
|
||||
}
|
||||
onEntered: window.mouseEntered();
|
||||
onExited: window.mouseExited();
|
||||
}
|
||||
|
||||
// This mouse area serves to swallow mouse events while the mouse is over the window
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
#include "ToolbarScriptingInterface.h"
|
||||
|
||||
#include <QtCore/QThread>
|
||||
|
||||
#include <OffscreenUi.h>
|
||||
|
||||
class QmlWrapper : public QObject {
|
||||
|
@ -79,7 +81,11 @@ public:
|
|||
|
||||
Q_INVOKABLE QObject* addButton(const QVariant& properties) {
|
||||
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) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -101,8 +107,12 @@ public:
|
|||
QObject* ToolbarScriptingInterface::getToolbar(const QString& toolbarId) {
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
auto desktop = offscreenUi->getDesktop();
|
||||
Qt::ConnectionType connectionType = Qt::AutoConnection;
|
||||
if (QThread::currentThread() != desktop->thread()) {
|
||||
connectionType = Qt::BlockingQueuedConnection;
|
||||
}
|
||||
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) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -12,11 +12,13 @@
|
|||
//
|
||||
|
||||
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([
|
||||
"libraries/stringHelpers.js",
|
||||
"libraries/dataViewHelpers.js",
|
||||
"libraries/toolBars.js",
|
||||
"libraries/progressDialog.js",
|
||||
|
||||
"libraries/entitySelectionTool.js",
|
||||
|
@ -50,11 +52,6 @@ selectionManager.addEventListener(function() {
|
|||
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 RADIANS_TO_DEGREES = 180.0 / Math.PI;
|
||||
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 isActive = false;
|
||||
|
||||
var placingEntityID = null;
|
||||
|
||||
IMPORTING_SVO_OVERLAY_WIDTH = 144;
|
||||
IMPORTING_SVO_OVERLAY_HEIGHT = 30;
|
||||
IMPORTING_SVO_OVERLAY_MARGIN = 5;
|
||||
IMPORTING_SVO_OVERLAY_LEFT_MARGIN = 34;
|
||||
|
||||
var importingSVOImageOverlay = Overlays.addOverlay("image", {
|
||||
imageURL: Script.resolvePath("assets") + "/images/hourglass.svg",
|
||||
width: 20,
|
||||
|
@ -168,241 +164,15 @@ function toggleMarketplace() {
|
|||
}
|
||||
|
||||
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 = {},
|
||||
toolBar,
|
||||
activeButton,
|
||||
newModelButton,
|
||||
newCubeButton,
|
||||
newSphereButton,
|
||||
newLightButton,
|
||||
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;
|
||||
systemToolbar,
|
||||
activeButton;
|
||||
|
||||
function createNewEntity(properties) {
|
||||
Settings.setValue(EDIT_SETTING, false);
|
||||
|
||||
var dimensions = properties.dimensions ? properties.dimensions : DEFAULT_DIMENSIONS;
|
||||
var position = getPositionToCreateEntity();
|
||||
|
@ -410,11 +180,7 @@ var toolBar = (function() {
|
|||
if (position != null) {
|
||||
position = grid.snapToSurface(grid.snapToGrid(position, false, dimensions), dimensions),
|
||||
properties.position = position;
|
||||
|
||||
entityID = Entities.addEntity(properties);
|
||||
if (dragOnCreate) {
|
||||
placingEntityID = entityID;
|
||||
}
|
||||
} else {
|
||||
Window.alert("Can't create " + properties.type + ": " + properties.type + " would be out of bounds.");
|
||||
}
|
||||
|
@ -426,35 +192,69 @@ var toolBar = (function() {
|
|||
return entityID;
|
||||
}
|
||||
|
||||
that.mousePressEvent = function(event) {
|
||||
var clickedOverlay,
|
||||
url,
|
||||
file;
|
||||
|
||||
if (!event.isLeftButton) {
|
||||
// if another mouse button than left is pressed ignore it
|
||||
return false;
|
||||
function cleanup() {
|
||||
that.setActive(false);
|
||||
systemToolbar.removeButton(EDIT_TOGGLE_BUTTON);
|
||||
}
|
||||
|
||||
function addButton(name, image, handler) {
|
||||
var imageUrl = TOOL_ICON_URL + image;
|
||||
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({
|
||||
x: event.x,
|
||||
y: event.y
|
||||
function initialize() {
|
||||
print("QQQ creating edit toolbar");
|
||||
Script.scriptEnding.connect(cleanup);
|
||||
|
||||
Window.domainChanged.connect(function() {
|
||||
that.setActive(false);
|
||||
that.clearEntityList();
|
||||
});
|
||||
|
||||
if (activeButton === toolBar.clicked(clickedOverlay)) {
|
||||
that.setActive(!isActive);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (newModelButton === toolBar.clicked(clickedOverlay)) {
|
||||
url = Window.prompt("Model URL");
|
||||
if (url !== null && url !== "") {
|
||||
addModel(url);
|
||||
Entities.canAdjustLocksChanged.connect(function(canAdjustLocks) {
|
||||
if (isActive && !canAdjustLocks) {
|
||||
that.setActive(false);
|
||||
}
|
||||
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({
|
||||
type: "Box",
|
||||
dimensions: DEFAULT_DIMENSIONS,
|
||||
|
@ -464,11 +264,9 @@ var toolBar = (function() {
|
|||
blue: 0
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (newSphereButton === toolBar.clicked(clickedOverlay)) {
|
||||
addButton("newSphereButton", "sphere-01.svg", function() {
|
||||
createNewEntity({
|
||||
type: "Sphere",
|
||||
dimensions: DEFAULT_DIMENSIONS,
|
||||
|
@ -478,11 +276,9 @@ var toolBar = (function() {
|
|||
blue: 0
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (newLightButton === toolBar.clicked(clickedOverlay)) {
|
||||
addButton("newLightButton", "light-01.svg", function() {
|
||||
createNewEntity({
|
||||
type: "Light",
|
||||
dimensions: DEFAULT_LIGHT_DIMENSIONS,
|
||||
|
@ -499,11 +295,9 @@ var toolBar = (function() {
|
|||
exponent: 0,
|
||||
cutoff: 180, // in degrees
|
||||
});
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (newTextButton === toolBar.clicked(clickedOverlay)) {
|
||||
addButton("newTextButton", "text-01.svg", function() {
|
||||
createNewEntity({
|
||||
type: "Text",
|
||||
dimensions: {
|
||||
|
@ -524,11 +318,9 @@ var toolBar = (function() {
|
|||
text: "some text",
|
||||
lineHeight: 0.06
|
||||
});
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (newWebButton === toolBar.clicked(clickedOverlay)) {
|
||||
addButton("newWebButton", "web-01.svg", function() {
|
||||
createNewEntity({
|
||||
type: "Web",
|
||||
dimensions: {
|
||||
|
@ -538,11 +330,9 @@ var toolBar = (function() {
|
|||
},
|
||||
sourceUrl: "https://highfidelity.com/",
|
||||
});
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (newZoneButton === toolBar.clicked(clickedOverlay)) {
|
||||
addButton("newZoneButton", "zone-01.svg", function() {
|
||||
createNewEntity({
|
||||
type: "Zone",
|
||||
dimensions: {
|
||||
|
@ -551,11 +341,9 @@ var toolBar = (function() {
|
|||
z: 10
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (newParticleButton === toolBar.clicked(clickedOverlay)) {
|
||||
addButton("newParticleButton", "particle-01.svg", function() {
|
||||
createNewEntity({
|
||||
type: "ParticleEffect",
|
||||
isEmitting: true,
|
||||
|
@ -577,33 +365,63 @@ var toolBar = (function() {
|
|||
emitRate: 100,
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Window.domainChanged.connect(function() {
|
||||
that.setActive(false);
|
||||
that.clearEntityList();
|
||||
});
|
||||
|
||||
Entities.canAdjustLocksChanged.connect(function(canAdjustLocks) {
|
||||
if (isActive && !canAdjustLocks) {
|
||||
that.setActive(false);
|
||||
that.setActive = function(active) {
|
||||
if (active == isActive) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
that.cleanup = function() {
|
||||
toolBar.cleanup();
|
||||
if (active && !Entities.canRez() && !Entities.canRezTmp()) {
|
||||
Window.alert(INSUFFICIENT_PERMISSIONS_ERROR_MSG);
|
||||
return;
|
||||
}
|
||||
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();
|
||||
return that;
|
||||
}());
|
||||
})();
|
||||
|
||||
|
||||
function isLocked(properties) {
|
||||
|
@ -712,7 +530,7 @@ function mousePressEvent(event) {
|
|||
mouseHasMovedSincePress = false;
|
||||
mouseCapturedByTool = false;
|
||||
|
||||
if (propertyMenu.mousePressEvent(event) || toolBar.mousePressEvent(event) || progressDialog.mousePressEvent(event)) {
|
||||
if (propertyMenu.mousePressEvent(event) || progressDialog.mousePressEvent(event)) {
|
||||
mouseCapturedByTool = true;
|
||||
return;
|
||||
}
|
||||
|
@ -755,16 +573,6 @@ function mouseMove(event) {
|
|||
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) {
|
||||
return;
|
||||
}
|
||||
|
@ -796,20 +604,10 @@ function mouseReleaseEvent(event) {
|
|||
mouseMove(lastMouseMoveEvent);
|
||||
lastMouseMoveEvent = null;
|
||||
}
|
||||
if (propertyMenu.mouseReleaseEvent(event) || toolBar.mouseReleaseEvent(event)) {
|
||||
|
||||
if (propertyMenu.mouseReleaseEvent(event)) {
|
||||
return true;
|
||||
}
|
||||
if (placingEntityID) {
|
||||
|
||||
if (isActive) {
|
||||
|
||||
selectionManager.setSelections([placingEntityID]);
|
||||
}
|
||||
placingEntityID = null;
|
||||
}
|
||||
if (isActive && selectionManager.hasSelection()) {
|
||||
|
||||
tooltip.show(false);
|
||||
}
|
||||
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));
|
||||
|
||||
progressDialog.cleanup();
|
||||
toolBar.cleanup();
|
||||
cleanupModelMenus();
|
||||
tooltip.cleanup();
|
||||
selectionDisplay.cleanup();
|
||||
|
|
|
@ -69,6 +69,7 @@ browseExamplesButton.clicked.connect(onClick);
|
|||
examplesWindow.visibleChanged.connect(onExamplesWindowVisibilityChanged);
|
||||
|
||||
Script.scriptEnding.connect(function () {
|
||||
toolBar.removeButton("examples");
|
||||
browseExamplesButton.clicked.disconnect(onClick);
|
||||
examplesWindow.visibleChanged.disconnect(onExamplesWindowVisibilityChanged);
|
||||
});
|
||||
|
|
|
@ -30,6 +30,7 @@ button.clicked.connect(onClicked);
|
|||
DialogsManager.addressBarShown.connect(onAddressBarShown);
|
||||
|
||||
Script.scriptEnding.connect(function () {
|
||||
toolBar.removeButton("goto");
|
||||
button.clicked.disconnect(onClicked);
|
||||
DialogsManager.addressBarShown.disconnect(onAddressBarShown);
|
||||
});
|
||||
|
|
|
@ -40,6 +40,7 @@ if (headset) {
|
|||
HMD.displayModeChanged.connect(onHmdChanged);
|
||||
|
||||
Script.scriptEnding.connect(function () {
|
||||
toolBar.removeButton("hmdToggle");
|
||||
button.clicked.disconnect(onClicked);
|
||||
HMD.displayModeChanged.disconnect(onHmdChanged);
|
||||
});
|
||||
|
|
|
@ -34,6 +34,7 @@ button.clicked.connect(onClicked);
|
|||
AudioDevice.muteToggled.connect(onMuteToggled);
|
||||
|
||||
Script.scriptEnding.connect(function () {
|
||||
toolBar.removeButton("mute");
|
||||
button.clicked.disconnect(onClicked);
|
||||
AudioDevice.muteToggled.disconnect(onMuteToggled);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue