fix circle/rectangle add dialog
This commit is contained in:
parent
e608091603
commit
a930e06603
2 changed files with 28 additions and 11 deletions
|
|
@ -660,7 +660,7 @@ let add = {
|
||||||
|
|
||||||
/** add sketch components */
|
/** add sketch components */
|
||||||
|
|
||||||
circle(opt = {}) {
|
circle() {
|
||||||
let sketch = selection.sketch();
|
let sketch = selection.sketch();
|
||||||
if (!sketch) {
|
if (!sketch) {
|
||||||
return log('select a sketch');
|
return log('select a sketch');
|
||||||
|
|
@ -669,14 +669,14 @@ let add = {
|
||||||
title: "add circle",
|
title: "add circle",
|
||||||
body: [ h.div({ class: "addgear" }, [
|
body: [ h.div({ class: "addgear" }, [
|
||||||
h.label('radius in mm'),
|
h.label('radius in mm'),
|
||||||
h.input({ value: opt.radius || 10, size: 5, id: "_radius" }),
|
h.input({ value: 10, size: 5, id: "_radius" }),
|
||||||
h.hr(),
|
h.hr(),
|
||||||
h.code("optional"),
|
h.code("optional"),
|
||||||
h.hr(),
|
h.hr(),
|
||||||
h.label('point spacing'),
|
h.label('point spacing'),
|
||||||
h.input({ value: opt.spacing || 0, size: 5, id: "_spacing" }),
|
h.input({ value: 0, size: 5, id: "_spacing" }),
|
||||||
h.label('point count'),
|
h.label('point count'),
|
||||||
h.input({ value: opt.points || 0, size: 5, id: "_points" }),
|
h.input({ value: 0, size: 5, id: "_points" }),
|
||||||
h.button({ _: "create", onclick() {
|
h.button({ _: "create", onclick() {
|
||||||
const { _radius, _points, _spacing } = api.modal.bound;
|
const { _radius, _points, _spacing } = api.modal.bound;
|
||||||
sketch.add.circle({
|
sketch.add.circle({
|
||||||
|
|
@ -692,11 +692,28 @@ let add = {
|
||||||
},
|
},
|
||||||
|
|
||||||
rectangle() {
|
rectangle() {
|
||||||
let sel = selection.sketches();
|
let sketch = selection.sketch();
|
||||||
if (!sel.length) {
|
if (!sketch) {
|
||||||
return log('select a sketch');
|
return log('select a sketch');
|
||||||
}
|
}
|
||||||
return sel[0].add.rectangle(...arguments);
|
api.modal.dialog({
|
||||||
|
title: "add rectangle",
|
||||||
|
body: [ h.div({ class: "addgear" }, [
|
||||||
|
h.label('width'),
|
||||||
|
h.input({ value: 20, size: 5, id: "_width" }),
|
||||||
|
h.label('height'),
|
||||||
|
h.input({ value: 20, size: 5, id: "_height" }),
|
||||||
|
h.button({ _: "create", onclick() {
|
||||||
|
const { _width, _height } = api.modal.bound;
|
||||||
|
sketch.add.rectangle({
|
||||||
|
width: parseFloat(_width.value),
|
||||||
|
height: parseFloat(_height.value),
|
||||||
|
});
|
||||||
|
api.modal.hide();
|
||||||
|
} })
|
||||||
|
]) ]
|
||||||
|
});
|
||||||
|
api.modal.bound._width.focus();
|
||||||
},
|
},
|
||||||
|
|
||||||
/** add models */
|
/** add models */
|
||||||
|
|
|
||||||
|
|
@ -392,8 +392,8 @@ function ui_build() {
|
||||||
div({ class: "menu sketch-on" }, [
|
div({ class: "menu sketch-on" }, [
|
||||||
div('Edit'),
|
div('Edit'),
|
||||||
div({ class: "menu-items" }, [
|
div({ class: "menu-items" }, [
|
||||||
menu_item('Add Circle', () => { sketch.selected.one?.add.circle() }),
|
menu_item('Add Circle', api.add.circle),
|
||||||
menu_item('Add Rectangle', () => { sketch.selected.one?.add.rectangle() }),
|
menu_item('Add Rectangle', api.add.rectangle),
|
||||||
hr(),
|
hr(),
|
||||||
menu_item('Add Sketch', add.sketch),
|
menu_item('Add Sketch', add.sketch),
|
||||||
hr(),
|
hr(),
|
||||||
|
|
@ -563,8 +563,8 @@ function ui_build() {
|
||||||
// bind sketch chiclets
|
// bind sketch chiclets
|
||||||
bind(sketchtools, div([
|
bind(sketchtools, div([
|
||||||
tool_item('bi-plus', 'New Sketch', add.sketch),
|
tool_item('bi-plus', 'New Sketch', add.sketch),
|
||||||
tool_item('bi-circle', 'Add Circle', () => { sketch.selected.one?.add.circle() }),
|
tool_item('bi-circle', 'Add Circle', api.add.circle),
|
||||||
tool_item('bi-square', 'Add Rectangle', () => { sketch.selected.one?.add.rectangle() }),
|
tool_item('bi-square', 'Add Rectangle', api.add.rectangle),
|
||||||
tool_item('bi-union', 'Union', sketch.boolean.union),
|
tool_item('bi-union', 'Union', sketch.boolean.union),
|
||||||
tool_item('bi-intersect', 'Intersect', sketch.boolean.intersect),
|
tool_item('bi-intersect', 'Intersect', sketch.boolean.intersect),
|
||||||
tool_item('bi-exclude', 'Difference', sketch.boolean.difference),
|
tool_item('bi-exclude', 'Difference', sketch.boolean.difference),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue