@croquet/worldcore-widget2
Advanced tools
Comparing version 1.4.0 to 2.0.0-alpha.0
@@ -7,3 +7,9 @@ # Changelog | ||
## [Unreleased] | ||
### Changed | ||
Ignores right mouse clicks | ||
### Added | ||
ImageToggleWidget2 | ||
## [1.4.0] - 2022-10-3 | ||
@@ -13,3 +19,3 @@ ### Added | ||
## Pending | ||
{ | ||
"name": "@croquet/worldcore-widget2", | ||
"version": "1.4.0", | ||
"version": "2.0.0-alpha.0", | ||
"description": "Canvas-based Widget Component for Croquet Worldcore", | ||
@@ -26,3 +26,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@croquet/worldcore-kernel": "^1.4.0" | ||
"@croquet/worldcore-kernel": "^2.0.0-alpha.0" | ||
}, | ||
@@ -32,3 +32,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "ada83b1dc609ca939c2ceeff646ad00cd4a49c6e" | ||
"gitHead": "76941c2806b50b1f57ea61c428f1992d842272bc" | ||
} |
@@ -44,11 +44,14 @@ import { WorldcoreView, viewRoot, ViewService, v2_add, v3_add, v2_magnitude, v2_scale, v2_normalize, v2_sub} from "@croquet/worldcore-kernel"; | ||
this.subscribe("input", "pointerDown", this.pointerDown); | ||
this.subscribe("input", "pointerUp", this.pointerUp); | ||
this.subscribe("input", "pointerMove", this.pointerMove); | ||
this.subscribe("input", { event: "pointerDown", handling: "immediate" }, this.pointerDown); | ||
this.subscribe("input", { event: "pointerUp", handling: "immediate" }, this.pointerUp); | ||
this.subscribe("input", { event: "pointerMove", handling: "immediate" }, this.pointerMove); | ||
this.subscribe("input", "keyDown", this.keyDown); | ||
this.subscribe("input", "keyRepeat", this.keyDown); | ||
this.subscribe("input", "keyUp", this.keyUp); | ||
this.subscribe("input", {event: "resize", handling: "immediate"}, this.resize); | ||
} | ||
destroy() { | ||
@@ -63,7 +66,18 @@ super.destroy(); | ||
resize() { | ||
const x = window.innerWidth; | ||
const y = window.innerHeight; | ||
this.root.set({size: [x,y]}); | ||
} | ||
pointerDown(e) { | ||
this.root.pointerDown(e); | ||
if (e.button == 0) { | ||
if (this.root.pointerDown(e)) return; | ||
}; | ||
this.publish("ui", "pointerDown", e); | ||
} | ||
pointerUp(e) { | ||
if (e.button === 2) return; | ||
this.root.pointerUp(e); | ||
@@ -73,2 +87,3 @@ } | ||
pointerMove(e) { | ||
if (e.button === 2) return; | ||
this.root.pointerMove(e); | ||
@@ -263,4 +278,6 @@ } | ||
pointerDown(e) { | ||
if (!this.visible) return; | ||
if (this.children) this.children.forEach( child => child.pointerDown(e)); | ||
if (!this.visible) return false; | ||
let consumed = false; | ||
if (this.children) this.children.forEach( child => consumed = child.pointerDown(e) || consumed); | ||
return consumed; | ||
} | ||
@@ -569,3 +586,3 @@ | ||
export function ParentControl(w) { | ||
export function ParentControl2(w) { | ||
do { | ||
@@ -588,4 +605,5 @@ if (w instanceof ControlWidget3) return w; | ||
this.onPress(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
@@ -628,3 +646,3 @@ | ||
buildDefault() { | ||
this.frame = new CanvasWidget2({parent: this, autoSize: [1,1], color: [0,0,1]}); | ||
this.frame = new CanvasWidget2({parent: this, autoSize: [1,1], color: [0.5,0.5,0.7]}); | ||
this.label = new TextWidget2({ parent: this.frame, autoSize: [1,1], border: [5, 5, 5, 5], color: [0.8,0.8,0.8], text: "Button" }); | ||
@@ -708,4 +726,5 @@ } | ||
export class ToggleSet2 { | ||
export class ToggleSet2 extends WorldcoreView { | ||
constructor() { | ||
super(viewRoot.model); | ||
this.set = new Set(); | ||
@@ -719,2 +738,3 @@ } | ||
}); | ||
this.publish(this.id, "pick",on.name); | ||
} | ||
@@ -725,2 +745,33 @@ | ||
//------------------------------------------------------------------------------------------ | ||
//-- ImageToggleWidget2 -------------------------------------------------------------------- | ||
//------------------------------------------------------------------------------------------ | ||
export class ImageToggleWidget2 extends ToggleWidget2 { | ||
buildDefault() { | ||
this.frame = new CanvasWidget2({parent: this, autoSize: [1,1], color: [0.5,0.5,0.5]}); | ||
this.label = new ImageWidget2({parent: this.frame, autoSize: [1,1], border: [2.5, 2.5, 2.5, 2.5], color: [0.6,0.6,0.6], url: this.offURL}); | ||
} | ||
get offURL() {return this._offURL} | ||
get onURL() {return this._onURL} | ||
onHover() { | ||
this.frame.set({color: [0.4,0.4,0.4]}); | ||
} | ||
onPress() { | ||
this.frame.set({color: [0.8,0.8,0.8]}); | ||
} | ||
onNormal() { | ||
this.frame.set({color: [0.6,0.6,0.6]}); | ||
} | ||
onToggle() { | ||
this.isOn ? this.label.set({url: this.onURL}) : this.label.set({url: this.offURL}); | ||
} | ||
} | ||
//------------------------------------------------------------------------------------------ | ||
//-- SliderWidget2 ----------------------------------------------------------------------- | ||
@@ -783,2 +834,3 @@ //------------------------------------------------------------------------------------------ | ||
this.set({percent: p}); | ||
return true; | ||
} | ||
@@ -853,2 +905,3 @@ } | ||
this.change(xy); | ||
return true; | ||
} | ||
@@ -939,3 +992,3 @@ } | ||
} | ||
this.close.pointerDown(e); | ||
return this.close.pointerDown(e); | ||
} | ||
@@ -1018,2 +1071,3 @@ | ||
this.hiliteEntry(w); | ||
return true; | ||
} | ||
@@ -1020,0 +1074,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34984
884
1
+ Added@croquet/croquet@2.0.0-31(transitive)
+ Added@croquet/worldcore-kernel@2.0.0-alpha.24(transitive)
- Removed@croquet/croquet@1.1.0(transitive)
- Removed@croquet/worldcore-kernel@1.4.0(transitive)