Skip to content

Commit 8ff4156

Browse files
committed
Context menu offset
1 parent 9b18367 commit 8ff4156

File tree

14 files changed

+69
-58
lines changed

14 files changed

+69
-58
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@
159159
- Resize is now a part of Object3D
160160
- Improvements to nsp files
161161
- Moved from base64 to raw binary data.
162+
- Cube camera preview
163+
- Fixed dropdown menus getting out of screen
162164

163165
### Tech
164166
nunuStudio is built on top of a number of open source projects

build/nunu.editor.min.js

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/editor/nunu.editor.min.js

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/core/objects/misc/LensFlare.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ LensFlare.prototype.copy = function (source)
123123
*/
124124
LensFlare.prototype.addFlare = function(texture, size, distance, blending, color, opacity)
125125
{
126-
if(size === undefined) size = -1;
127-
if(distance === undefined) distance = 0;
128-
if(opacity === undefined) opacity = 1;
129-
if(color === undefined) color = new Color(0xffffff);
130-
if(blending === undefined) blending = NormalBlending;
126+
if(size === undefined){size = -1;}
127+
if(distance === undefined){distance = 0;}
128+
if(opacity === undefined){opacity = 1;}
129+
if(color === undefined){color = new Color(0xffffff)}
130+
if(blending === undefined){blending = NormalBlending;}
131131

132132
distance = Math.min(distance, Math.max(0, distance));
133133

source/editor/helpers/PhysicsObjectHelper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use strict";
22

33
//Based on code from cannonjs debug shape renderer made by schteppe
4-
function PhysicsObjectHelper(obj)
4+
function PhysicsObjectHelper(obj, color)
55
{
66
THREE.Object3D.call(this);
77

@@ -11,7 +11,7 @@ function PhysicsObjectHelper(obj)
1111

1212
this.material = new THREE.MeshBasicMaterial(
1313
{
14-
color: 0x00FF00,
14+
color: (color !== undefined) ? color : 0x00FF00,
1515
wireframe: false,
1616
transparent: true,
1717
opacity: 0.5

source/editor/ui/ContextMenu.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ function ContextMenu(parent)
1313
//Attributes
1414
this.size = new THREE.Vector2(130, 20);
1515
this.position = new THREE.Vector2(0, 0);
16+
this.offset = new THREE.Vector2(20, 10);
1617
this.visible = true;
1718

1819
//Options
@@ -93,7 +94,6 @@ ContextMenu.prototype.addMenu = function(name)
9394
//Update interface
9495
ContextMenu.prototype.updateInterface = function()
9596
{
96-
//Visibility
9797
if(this.visible)
9898
{
9999
this.element.style.visibility = "visible";
@@ -108,10 +108,21 @@ ContextMenu.prototype.updateInterface = function()
108108
}
109109

110110
//Element
111-
this.element.style.top = this.position.y + "px";
112-
this.element.style.left = this.position.x + "px";
111+
this.element.style.top = (this.position.y - this.offset.y) + "px";
112+
this.element.style.left = (this.position.x - this.offset.x) + "px";
113113
this.element.style.width = this.size.x + "px";
114-
this.element.style.height = (this.size.y * this.options.length)+ "px";
114+
this.element.style.height = (this.size.y * this.options.length) + "px";
115+
116+
//Check if its inside window
117+
var out = DOMUtils.checkBorder(this.element);
118+
if(out.x !== 0)
119+
{
120+
this.element.style.left = (this.position.x + this.offset.x - this.size.x) + "px";
121+
}
122+
if(out.y !== 0)
123+
{
124+
this.element.style.top = (this.position.y - this.offset.y - out.y) + "px";
125+
}
115126
}
116127
else
117128
{

source/editor/ui/DropdownMenu.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,6 @@ DropdownMenu.prototype.setExpanded = function(expanded)
273273
this.panel.style.top = (this.position.y - out.y) + "px";
274274
}
275275
}
276-
277-
console.log(out);
278276
}
279277
else
280278
{

source/editor/ui/TreeElement.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ function TreeElement(container)
189189
//Context menu
190190
var context = new ContextMenu();
191191
context.size.set(150, 20);
192-
context.position.set(event.clientX - 5, event.clientY - 5);
192+
context.position.set(event.clientX, event.clientY);
193193

194194
//Open editor
195195
if(self.obj instanceof Scene)

source/editor/ui/asset/AudioAsset.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function AudioAsset(parent)
2121
{
2222
var context = new ContextMenu();
2323
context.size.set(130, 20);
24-
context.position.set(event.clientX - 5, event.clientY - 5);
24+
context.position.set(event.clientX, event.clientY);
2525

2626
context.addOption("Create Emitter", function()
2727
{

source/editor/ui/asset/FontAsset.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function FontAsset(parent)
2121
{
2222
var context = new ContextMenu();
2323
context.size.set(130, 20);
24-
context.position.set(event.clientX - 5, event.clientY - 5);
24+
context.position.set(event.clientX, event.clientY);
2525

2626
context.addOption("Rename", function()
2727
{

0 commit comments

Comments
 (0)