diff --git a/src/editor/EditorStartup.js b/src/editor/EditorStartup.js index 1476ee80..39cb8121 100644 --- a/src/editor/EditorStartup.js +++ b/src/editor/EditorStartup.js @@ -249,7 +249,7 @@ class EditorStartup { }); $id('seg_type').addEventListener('change', (evt) => { - this.svgCanvas.setSegType(evt.currentTarget.value); + this.svgCanvas.setSegType(evt.detail.value); }); const addListenerMulti = (element, eventNames, listener)=> { diff --git a/src/editor/MainMenu.js b/src/editor/MainMenu.js index c7068ffb..37bac189 100644 --- a/src/editor/MainMenu.js +++ b/src/editor/MainMenu.js @@ -289,7 +289,7 @@ class MainMenu { `; - $id('tools_top').prepend(template.content.cloneNode(true)); + this.editor.$svgEditor.append(template.content.cloneNode(true)); // register action to main menu entries /** diff --git a/src/editor/components/index.js b/src/editor/components/index.js index 8f16e993..e59f23c2 100644 --- a/src/editor/components/index.js +++ b/src/editor/components/index.js @@ -10,3 +10,5 @@ import './seMenuItem.js'; import './seList.js'; import './seListItem.js'; import './seColorPicker.js'; +import './seSelect'; + diff --git a/src/editor/components/seButton.js b/src/editor/components/seButton.js index f6e5478a..2b91e39f 100644 --- a/src/editor/components/seButton.js +++ b/src/editor/components/seButton.js @@ -10,7 +10,7 @@ template.innerHTML = ` { height: 24px; width: 24px; - margin: 2px 1px 4px; + margin: 4px 1px 4px; padding: 3px; background-color: var(--icon-bg-color); cursor: pointer; diff --git a/src/editor/components/seInput.js b/src/editor/components/seInput.js index e19e1dbf..19f03594 100644 --- a/src/editor/components/seInput.js +++ b/src/editor/components/seInput.js @@ -23,6 +23,7 @@ template.innerHTML = ` elix-input { background-color: var(--input-color); border-radius: 3px; + height: 24px; }
diff --git a/src/editor/components/seList.js b/src/editor/components/seList.js index 7f573115..4b903a9b 100644 --- a/src/editor/components/seList.js +++ b/src/editor/components/seList.js @@ -11,7 +11,11 @@ elix-dropdown-list:hover { background-color: var(--icon-bg-color-hover); } -::part(popup-toggle) { +elix-dropdown-list::part(value) { + background-color: var(--main-bg-color); +} + +elix-dropdown-list::part(popup-toggle) { display: none; } ::slotted(*) { diff --git a/src/editor/components/seSelect.js b/src/editor/components/seSelect.js new file mode 100644 index 00000000..d1fc629f --- /dev/null +++ b/src/editor/components/seSelect.js @@ -0,0 +1,149 @@ +const template = document.createElement('template'); +template.innerHTML = ` + + + + +`; +/** + * @class SeList + */ +export class SeSelect extends HTMLElement { + /** + * @function constructor + */ + constructor () { + super(); + // create the shadowDom and insert the template + this._shadowRoot = this.attachShadow({ mode: 'open' }); + this._shadowRoot.append(template.content.cloneNode(true)); + this.$select = this._shadowRoot.querySelector('select'); + this.$label = this._shadowRoot.querySelector('label'); + } + /** + * @function observedAttributes + * @returns {any} observed + */ + static get observedAttributes () { + return [ 'label', 'width', 'height', 'options', 'values' ]; + } + + /** + * @function attributeChangedCallback + * @param {string} name + * @param {string} oldValue + * @param {string} newValue + * @returns {void} + */ + attributeChangedCallback (name, oldValue, newValue) { + let options; + if (oldValue === newValue) return; + switch (name) { + case 'label': + this.$label.textContent = newValue; + break; + case 'height': + this.$select.style.height = newValue; + break; + case 'width': + this.$select.style.width = newValue; + break; + case 'options': + options = newValue.split(','); + options.forEach((option) => { + const optionNode = document.createElement("OPTION"); + const text = document.createTextNode(option); + optionNode.appendChild(text); + this.$select.appendChild(optionNode); + }); + break; + case 'values': + options = newValue.split(' '); + options.forEach((option, index) => { + this.$select.children[index].setAttribute('value', option); + }); + break; + default: + // eslint-disable-next-line no-console + console.error(`unknown attribute: ${name}`); + break; + } + } + /** + * @function get + * @returns {any} + */ + get label () { + return this.getAttribute('label'); + } + + /** + * @function set + * @returns {void} + */ + set label (value) { + this.setAttribute('label', value); + } + /** + * @function get + * @returns {any} + */ + get width () { + return this.getAttribute('width'); + } + + /** + * @function set + * @returns {void} + */ + set width (value) { + this.setAttribute('width', value); + } + /** + * @function get + * @returns {any} + */ + get height () { + return this.getAttribute('height'); + } + + /** + * @function set + * @returns {void} + */ + set height (value) { + this.setAttribute('height', value); + } + /** + * @function connectedCallback + * @returns {void} + */ + connectedCallback () { + const currentObj = this; + this.$select.addEventListener('change', () => { + const value = this.$select.value; + const closeEvent = new CustomEvent('change', { detail: { value } }); + currentObj.dispatchEvent(closeEvent); + currentObj.value = value; + }); + } +} + +// Register +customElements.define('se-select', SeSelect); diff --git a/src/editor/components/seSpinInput.js b/src/editor/components/seSpinInput.js index 24c82ed8..694bbfad 100644 --- a/src/editor/components/seSpinInput.js +++ b/src/editor/components/seSpinInput.js @@ -14,6 +14,7 @@ template.innerHTML = ` img { position: relative; right: -4px; + top: 2px; } span { bottom: -0.5em; diff --git a/src/editor/panels/BottomPanel.js b/src/editor/panels/BottomPanel.js index 4fd14c87..801742e3 100644 --- a/src/editor/panels/BottomPanel.js +++ b/src/editor/panels/BottomPanel.js @@ -186,13 +186,10 @@ class BottomPanel { - - - ... - - - - - . - - .. - + + diff --git a/src/editor/panels/TopPanel.js b/src/editor/panels/TopPanel.js index 34928a31..e1709e72 100644 --- a/src/editor/panels/TopPanel.js +++ b/src/editor/panels/TopPanel.js @@ -920,12 +920,13 @@ class TopPanel { - - ${i18next.t('tools.selected_objects')} - ${i18next.t('tools.largest_object')} - ${i18next.t('tools.smallest_object')} - ${i18next.t('tools.page')} - + +
@@ -976,16 +977,17 @@ class TopPanel {
- - ${i18next.t('properties.serif')} - ${i18next.t('properties.sans_serif')} - ${i18next.t('properties.cursive')} - ${i18next.t('properties.fantasy')} - ${i18next.t('properties.monospace')} - ${i18next.t('properties.courier')} - ${i18next.t('properties.helvetica')} - ${i18next.t('properties.times')} - + +
@@ -1025,10 +1027,11 @@ class TopPanel {
- + + diff --git a/src/editor/svgedit.css b/src/editor/svgedit.css index 510b5974..f79e705b 100644 --- a/src/editor/svgedit.css +++ b/src/editor/svgedit.css @@ -18,12 +18,12 @@ .svg_editor { display: grid; grid-template-rows: auto 15px 1fr 40px; - grid-template-columns: 34px 15px 1fr 15px; + grid-template-columns: 34px 15px 50px 1fr 15px; grid-template-areas: - "top top top top" - "left corner rulerX side" - "left rulerY workarea side" - "left bottom bottom bottom"; + "main main main top top" + "left corner rulerX rulerX side" + "left rulerY workarea workarea side" + "left bottom bottom bottom bottom"; font-size: 8pt; background: var(--main-bg-color); font-family: Verdana, Helvetica, Arial; @@ -33,12 +33,7 @@ height: 100%; } -.svg_editor.open { - grid-template-columns: 34px 15px 1fr 150px; -} - /* on smaller screen, allow 2 lines for the toolbar */ - @media screen and (max-width:1250px) { .svg_editor { grid-template-rows: minmax(80px, auto) 15px 1fr 40px; @@ -186,6 +181,7 @@ hr { —————————————————————————————*/ #main_button { + grid-area: main; color: #fff; border-radius: 3px; padding-block: 2px; @@ -299,8 +295,7 @@ hr { display: flex; flex-direction: row; flex-wrap: wrap; - /* leave space for the main menu */ - position: relative; + align-items: flex-start; background-color: var(--main-bg-color); } @@ -325,11 +320,12 @@ hr { width: 3px; } -#tools_bottom se-list { +#tools_bottom se-list, #tools_bottom se-select { margin-bottom: 8px; } + /*—————————————————————————————*/ #tools_left { diff --git a/src/svgcanvas/path-actions.js b/src/svgcanvas/path-actions.js index 852c90bd..39e40878 100644 --- a/src/svgcanvas/path-actions.js +++ b/src/svgcanvas/path-actions.js @@ -1179,7 +1179,7 @@ export const pathActionsMethod = (function () { * @returns {void} */ setSegType (v) { - path.setSegType(v); + path?.setSegType(v); }, /** * @param {string} attr