@orbat-mapper/tactical-draw 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +26 -5
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -3164,6 +3164,17 @@ function runEditInteraction(spec) {
|
|
|
3164
3164
|
}
|
|
3165
3165
|
//#endregion
|
|
3166
3166
|
//#region src/tactical-draw/handles.ts
|
|
3167
|
+
/** Size of a `compact` option handle relative to its slot's style. */
|
|
3168
|
+
const COMPACT_HANDLE_SCALE = 2 / 3;
|
|
3169
|
+
/** Shrink a handle style's radius and stroke for a `compact` handle. */
|
|
3170
|
+
function compactHandleStyle(style) {
|
|
3171
|
+
const { pointRadius, strokeWidth } = style;
|
|
3172
|
+
return {
|
|
3173
|
+
...style,
|
|
3174
|
+
...pointRadius !== void 0 && { pointRadius: pointRadius * COMPACT_HANDLE_SCALE },
|
|
3175
|
+
...strokeWidth !== void 0 && { strokeWidth: strokeWidth * COMPACT_HANDLE_SCALE }
|
|
3176
|
+
};
|
|
3177
|
+
}
|
|
3167
3178
|
/**
|
|
3168
3179
|
* Midpoint of the segment between two positions, in lonLat. The single source
|
|
3169
3180
|
* for "where a midpoint handle sits": `buildHandleSet` places the handle here
|
|
@@ -3249,7 +3260,8 @@ function handleStyleFor(kind, interactionStyle, unset = false) {
|
|
|
3249
3260
|
*/
|
|
3250
3261
|
function toFeatures(handles, featureIdPrefix, interactionStyle) {
|
|
3251
3262
|
return handles.map((handle) => {
|
|
3252
|
-
const
|
|
3263
|
+
const slotStyle = handleStyleFor(handle.kind, interactionStyle, handle.unset);
|
|
3264
|
+
const style = slotStyle && handle.compact ? compactHandleStyle(slotStyle) : slotStyle;
|
|
3253
3265
|
return {
|
|
3254
3266
|
type: "Feature",
|
|
3255
3267
|
id: handleFeatureId(featureIdPrefix, handle.kind, handle.index),
|
|
@@ -4608,6 +4620,11 @@ function runEdit(opts) {
|
|
|
4608
4620
|
iconResources: []
|
|
4609
4621
|
}]);
|
|
4610
4622
|
}
|
|
4623
|
+
/** Live view scale for option handles behind pixel-authored sizes. */
|
|
4624
|
+
function optionHandleContext() {
|
|
4625
|
+
const resolution = adapter.getResolution();
|
|
4626
|
+
return hasUsableResolution(resolution) ? { constructionMetersPerCssPixel: resolution } : {};
|
|
4627
|
+
}
|
|
4611
4628
|
function buildCurrentHandleSet() {
|
|
4612
4629
|
const handles = buildHandleSet(workingPoints, modes, {
|
|
4613
4630
|
includeMidpoints: midpointHandlesEnabled,
|
|
@@ -4616,7 +4633,10 @@ function runEdit(opts) {
|
|
|
4616
4633
|
closedRing
|
|
4617
4634
|
});
|
|
4618
4635
|
if (modes.includes("reshape")) {
|
|
4619
|
-
const optionHandles = getControlMeasureOptionHandles(measure.kind, workingPoints, workingOptions, {
|
|
4636
|
+
const optionHandles = getControlMeasureOptionHandles(measure.kind, workingPoints, workingOptions, {
|
|
4637
|
+
detail: detailHandles,
|
|
4638
|
+
...optionHandleContext()
|
|
4639
|
+
});
|
|
4620
4640
|
for (let index = 0; index < optionHandles.length; index++) {
|
|
4621
4641
|
const handle = optionHandles[index];
|
|
4622
4642
|
handles.push({
|
|
@@ -4624,7 +4644,8 @@ function runEdit(opts) {
|
|
|
4624
4644
|
index,
|
|
4625
4645
|
optionId: handle.id,
|
|
4626
4646
|
position: [...handle.position],
|
|
4627
|
-
...handle.unset ? { unset: true } : {}
|
|
4647
|
+
...handle.unset ? { unset: true } : {},
|
|
4648
|
+
...handle.compact ? { compact: true } : {}
|
|
4628
4649
|
});
|
|
4629
4650
|
}
|
|
4630
4651
|
}
|
|
@@ -5145,7 +5166,7 @@ function runEdit(opts) {
|
|
|
5145
5166
|
let activeDrag = null;
|
|
5146
5167
|
let activeOptionDrag = null;
|
|
5147
5168
|
function optionsForOptionHandle(position, drag) {
|
|
5148
|
-
const patch = dragControlMeasureOptionHandle(measure.kind, workingPoints, drag.preDragOptions, drag.handleId, position);
|
|
5169
|
+
const patch = dragControlMeasureOptionHandle(measure.kind, workingPoints, drag.preDragOptions, drag.handleId, position, optionHandleContext());
|
|
5149
5170
|
return patch ? {
|
|
5150
5171
|
...drag.preDragOptions ?? {},
|
|
5151
5172
|
...patch
|
|
@@ -5270,7 +5291,7 @@ function runEdit(opts) {
|
|
|
5270
5291
|
return;
|
|
5271
5292
|
}
|
|
5272
5293
|
if (hit.kind === "option" && hit.optionId && info?.altKey) {
|
|
5273
|
-
const patch = resetControlMeasureOptionHandle(measure.kind, workingPoints, workingOptions, hit.optionId);
|
|
5294
|
+
const patch = resetControlMeasureOptionHandle(measure.kind, workingPoints, workingOptions, hit.optionId, optionHandleContext());
|
|
5274
5295
|
if (patch) {
|
|
5275
5296
|
setOptions(patch, "gesture", "Reset option handle");
|
|
5276
5297
|
shell.suppressNextClickAway();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbat-mapper/tactical-draw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Engine-agnostic draw/edit core for tactical control measures (MIL-STD-2525 / APP-6). The MapAdapter ABI and bring-your-own-engine entry point for the tactical-draw package family.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Orbat Mapper",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@orbat-mapper/control-measures": "^0.
|
|
42
|
+
"@orbat-mapper/control-measures": "^0.31.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"vitest": ">=4.0.0"
|