Skip to content

Commit

Permalink
Merge pull request #259 from dubstar-04/blockmanager
Browse files Browse the repository at this point in the history
Sync with core changes to table management
  • Loading branch information
dubstar-04 authored May 31, 2024
2 parents 19226b6 + d58df48 commit 997648c
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion data/ui/preferencePageDimensionStyle.blp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ template $PreferencePageDimensionStyle : Adw.PreferencesPage {

Button {
icon-name: 'list-add-symbolic';
clicked => $addStyle();
clicked => $addItem();
}

Button {
Expand Down
2 changes: 1 addition & 1 deletion data/ui/preferencePageTextStyle.blp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ template $PreferencePageTextStyle : Adw.PreferencesPage {

Button {
icon-name: 'list-add-symbolic';
clicked => $addStyle();
clicked => $addItem();
}

Button {
Expand Down
2 changes: 1 addition & 1 deletion src/Design-Core
Submodule Design-Core updated 42 files
+0 −136 core/blocks/blockManager.js
+4 −4 core/core/core.js
+2 −2 core/entities/baseDimension.js
+5 −5 core/entities/entity.js
+3 −3 core/entities/insert.js
+3 −3 core/entities/text.js
+1 −1 core/lib/canvas.js
+1 −1 core/lib/commandManager.js
+5 −5 core/lib/dxf/dxf.js
+3 −1 core/lib/scene.js
+1 −1 core/lib/selectionManager.js
+1 −1 core/lib/snapping.js
+24 −0 core/styles/blockManager.js
+0 −315 core/styles/styleManagerBase.js
+2 −2 core/tables/block.js
+24 −0 core/tables/blockManager.js
+0 −0 core/tables/dimStyle.js
+9 −9 core/tables/dimStyleManager.js
+0 −0 core/tables/layer.js
+10 −10 core/tables/layerManager.js
+0 −0 core/tables/ltype.js
+10 −10 core/tables/ltypeManager.js
+0 −0 core/tables/style.js
+9 −9 core/tables/styleManager.js
+105 −0 core/tables/styleManagerBase.js
+280 −0 core/tables/tableManagerBase.js
+7 −7 core/tools/purge.js
+0 −54 test/blocks/blockManager.test.js
+2 −2 test/lib/dxf/sections/blocks.test.js
+0 −150 test/styles/layerManager.test.js
+0 −219 test/styles/stylemanagerbase.test.js
+1 −1 test/tables/block.test.js
+54 −0 test/tables/blockManager.test.js
+1 −1 test/tables/dimstyle.test.js
+2 −2 test/tables/layer.test.js
+150 −0 test/tables/layerManager.test.js
+1 −1 test/tables/ltype.test.js
+1 −1 test/tables/ltypeManager.test.js
+1 −1 test/tables/style.test.js
+223 −0 test/tables/stylemanagerbase.test.js
+197 −0 test/tables/tableManagerBase.test.js
+30 −30 test/tools/purge.test.js
20 changes: 10 additions & 10 deletions src/Design/layersWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ export const LayersWindow = GObject.registerClass({

onEditAction(simpleAction, parameters) {
const layerName = parameters.deep_unpack();
this.selected_layer = DesignCore.LayerManager.getStyleByName(layerName);
this.selected_layer = DesignCore.LayerManager.getItemByName(layerName);
this.onEditLayer();
}

onDeleteAction(simpleAction, parameters) {
// console.log("delete action")
const layerName = parameters.deep_unpack();
this.selected_layer = DesignCore.LayerManager.getStyleByName(layerName);
this.selected_layer = DesignCore.LayerManager.getItemByName(layerName);
this.onLayerDelete();
}

Expand All @@ -98,7 +98,7 @@ export const LayersWindow = GObject.registerClass({
}

getLineTypes() {
const lineStyles = DesignCore.LTypeManager.getStyles();
const lineStyles = DesignCore.LTypeManager.getItems();
const lineStyleNames = lineStyles.map((style) => style.name);
return lineStyleNames;
}
Expand All @@ -120,7 +120,7 @@ export const LayersWindow = GObject.registerClass({
}

loadLayers() {
const layers = DesignCore.LayerManager.getStyles();
const layers = DesignCore.LayerManager.getItems();
const clayer = DesignCore.LayerManager.getCstyle();

for (let i = 0; i < layers.length; i++) {
Expand Down Expand Up @@ -156,7 +156,7 @@ export const LayersWindow = GObject.registerClass({

onColourChange(colourButton) {
const row = colourButton.get_ancestor(Adw.ActionRow);
const layer = DesignCore.LayerManager.getStyleByName(row.title);
const layer = DesignCore.LayerManager.getItemByName(row.title);
const rgba = colourButton.rgba.to_string();
const rgb = rgba.substr(4).split(')')[0].split(',');
// log(rgb)
Expand All @@ -170,7 +170,7 @@ export const LayersWindow = GObject.registerClass({
// Get the row of the switch
const row = toggle.get_ancestor(Adw.ActionRow);
// get the layer reference from the layer manager
const layer = DesignCore.LayerManager.getStyleByName(row.title);
const layer = DesignCore.LayerManager.getItemByName(row.title);
// change the layer state
layer.on = state;
// redraw
Expand All @@ -185,14 +185,14 @@ export const LayersWindow = GObject.registerClass({

onNewClicked() {
// console.log("new clicked")
DesignCore.LayerManager.newStyle();
DesignCore.LayerManager.newItem();
this.reload();
}

onLayerSelected(row) {
if (row) {
this._layerList.unselect_row(row);
this.selected_layer = DesignCore.LayerManager.getStyleByName(row.title);
this.selected_layer = DesignCore.LayerManager.getItemByName(row.title);
this.onEditLayer();
}
}
Expand Down Expand Up @@ -230,7 +230,7 @@ export const LayersWindow = GObject.registerClass({
return;
}

const layerIndex = DesignCore.LayerManager.getStyleIndex(this.selected_layer.name);
const layerIndex = DesignCore.LayerManager.getItemIndex(this.selected_layer.name);
DesignCore.LayerManager.renameStyle(layerIndex, this._nameEntry.text);
this.selected_layer.frozen = this._frozenSwitch.active;
this.selected_layer.locked = this._lockedSwitch.active;
Expand Down Expand Up @@ -264,7 +264,7 @@ export const LayersWindow = GObject.registerClass({

deleteStyle(layerName) {
// console.log("delete layer")
DesignCore.LayerManager.deleteStyle(DesignCore.LayerManager.getStyleIndex(layerName));
DesignCore.LayerManager.deleteStyle(DesignCore.LayerManager.getItemIndex(layerName));
this.get_transient_for().getActiveCanvas().queue_draw();
}
}, // window
Expand Down
18 changes: 9 additions & 9 deletions src/Design/preferencePageDimensionStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ export const PreferencePageDimensionStyle = GObject.registerClass({
}

setModels() {
const styles = DesignCore.StyleManager.getStyles();
const styles = DesignCore.StyleManager.getItems();
const styleNames = styles.map((style) => style.name);
const textStyleModel = Gtk.StringList.new(styleNames);
this._DIMTXSTY.set_model(textStyleModel);


/*
// Line Types only supported from R2007
const lineTypes = DesignCore.LTypeManager.getStyles();
const lineTypes = DesignCore.LTypeManager.getItems();
const lineTypeNames = lineTypes.map((ltype) => ltype.name);
const lineTypeModel = Gtk.StringList.new(lineTypeNames);
this._DIMLTYPE.set_model(lineTypeModel);
Expand Down Expand Up @@ -89,7 +89,7 @@ export const PreferencePageDimensionStyle = GObject.registerClass({


load() {
const styles = DesignCore.DimStyleManager.getStyles();
const styles = DesignCore.DimStyleManager.getItems();

styles.forEach((style, index) => {
const row = new Adw.ActionRow({title: style.name, activatable: true});
Expand Down Expand Up @@ -123,7 +123,7 @@ export const PreferencePageDimensionStyle = GObject.registerClass({
// set the selected row
this._stylesList.select_row(row);

const style = DesignCore.DimStyleManager.getStyleByName(row.title);
const style = DesignCore.DimStyleManager.getItemByName(row.title);

for (const property in style) {
if (Object.hasOwn(style, property)) {
Expand Down Expand Up @@ -183,10 +183,10 @@ export const PreferencePageDimensionStyle = GObject.registerClass({
}
}

addStyle() {
DesignCore.DimStyleManager.newStyle();
addItem() {
DesignCore.DimStyleManager.newItem();
this.reload();
const newRow = this._stylesList.get_row_at_index(DesignCore.DimStyleManager.styleCount() - 1);
const newRow = this._stylesList.get_row_at_index(DesignCore.DimStyleManager.itemCount() - 1);
this.onStyleSelected(newRow);
}

Expand Down Expand Up @@ -230,11 +230,11 @@ export const PreferencePageDimensionStyle = GObject.registerClass({
const row = this._stylesList.get_selected_row();
if (row) {
// console.log('Style Update - Property:', widget.name, 'value:', value);
DesignCore.DimStyleManager.updateStyle(row.id, widget.name, value);
DesignCore.DimStyleManager.updateItem(row.id, widget.name, value);

if (widget.name === 'name') {
// update the name in the style list if the name in core has changed
const newName = DesignCore.DimStyleManager.getStyleByIndex(row.id).name;
const newName = DesignCore.DimStyleManager.getItemByIndex(row.id).name;
row.title = newName;
// set the _name string - this is needed when the style name passed to core was invalid and a different name is used
this._name.text = newName;
Expand Down
6 changes: 3 additions & 3 deletions src/Design/preferencePageLineType.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export const PreferencePageLineType = GObject.registerClass({
subtitle: style.description,
});

const styleLoaded = DesignCore.LTypeManager.styleExists(style.name);
const indelibleStyle = DesignCore.LTypeManager.indelibleStyles.some((iStyle) => iStyle.toUpperCase() === style.name);
const styleLoaded = DesignCore.LTypeManager.itemExists(style.name);
const indelibleStyle = DesignCore.LTypeManager.indelibleItems.some((iStyle) => iStyle.toUpperCase() === style.name);

const checkBox = new Gtk.CheckButton({active: styleLoaded, sensitive: !(styleLoaded||indelibleStyle)});
checkBox.connect('toggled', this.styleChecked.bind(this, row));
Expand All @@ -73,7 +73,7 @@ export const PreferencePageLineType = GObject.registerClass({
styleChecked(row, checkBox) {
if (row) {
const optionalStyles = DesignCore.LTypeManager.getOptionalStyles();
DesignCore.LTypeManager.addStyle(optionalStyles[row.id]);
DesignCore.LTypeManager.addItem(optionalStyles[row.id]);
this.reload();
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/Design/preferencePageTextStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const PreferencePageTextStyle = GObject.registerClass({
}

load() {
const styles = DesignCore.StyleManager.getStyles();
const styles = DesignCore.StyleManager.getItems();

styles.forEach((style, index) => {
const row = new Adw.ActionRow({title: style.name, activatable: true});
Expand Down Expand Up @@ -83,7 +83,7 @@ export const PreferencePageTextStyle = GObject.registerClass({
// set the selected row
this._stylesList.select_row(row);

const style = DesignCore.StyleManager.getStyleByName(row.title);
const style = DesignCore.StyleManager.getItemByName(row.title);
const fontDesc = Pango.font_description_from_string(`${style.font} ${style.textHeight}`);
this._name.set_text(style.name);
this._font.set_font_desc(fontDesc);
Expand All @@ -100,11 +100,11 @@ export const PreferencePageTextStyle = GObject.registerClass({
}
}

addStyle() {
DesignCore.StyleManager.newStyle();
addItem() {
DesignCore.StyleManager.newItem();
this.reload();

const newRow = this._stylesList.get_row_at_index(DesignCore.StyleManager.styleCount() - 1);
const newRow = this._stylesList.get_row_at_index(DesignCore.StyleManager.itemCount() - 1);
this.onStyleSelected(newRow);
}

Expand Down Expand Up @@ -149,14 +149,14 @@ export const PreferencePageTextStyle = GObject.registerClass({
if (widget.name === 'font') {
const font = value.get_family();
const textHeight = value.get_size() / Pango.SCALE;
DesignCore.StyleManager.updateStyle(row.id, 'font', font);
DesignCore.StyleManager.updateStyle(row.id, 'textHeight', textHeight);
DesignCore.StyleManager.updateItem(row.id, 'font', font);
DesignCore.StyleManager.updateItem(row.id, 'textHeight', textHeight);
} else {
DesignCore.StyleManager.updateStyle(row.id, widget.name, value);
DesignCore.StyleManager.updateItem(row.id, widget.name, value);

if (widget.name === 'name') {
// update the name in the style list if the name in core has changed
const newName = DesignCore.StyleManager.getStyleByIndex(row.id).name;
const newName = DesignCore.StyleManager.getItemByIndex(row.id).name;
row.title = newName;
// set the _name string - this is needed when the style name passed to core was invalid and a different name is used
this._name.text = newName;
Expand Down
6 changes: 3 additions & 3 deletions src/Design/propertiesWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,12 @@ export const PropertiesWindow = GObject.registerClass({
switch (property) {
case 'layer':
model = [];
for (const layer of DesignCore.LayerManager.getStyles()) {
for (const layer of DesignCore.LayerManager.getItems()) {
model.push(layer.name);
}
break;
case 'styleName':
const styles = DesignCore.StyleManager.getStyles();
const styles = DesignCore.StyleManager.getItems();
const styleNames = styles.map((style) => style.name);
model = styleNames;
break;
Expand All @@ -275,7 +275,7 @@ export const PropertiesWindow = GObject.registerClass({
model = ['Baseline', 'Bottom', 'Middle', 'Top'];
break;
case 'lineType':
const lineStyles = DesignCore.LTypeManager.getStyles();
const lineStyles = DesignCore.LTypeManager.getItems();
const lineStyleNames = lineStyles.map((style) => style.name);
model = lineStyleNames;
break;
Expand Down
24 changes: 12 additions & 12 deletions src/io.github.dubstar_04.design.src.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@
<file>Design-Core/core/entities/solid.js</file>
<file>Design-Core/core/entities/text.js</file>

<file>Design-Core/core/blocks/block.js</file>
<file>Design-Core/core/blocks/blockManager.js</file>

<file>Design-Core/core/tools/copy.js</file>
<file>Design-Core/core/tools/distance.js</file>
<file>Design-Core/core/tools/erase.js</file>
Expand All @@ -90,14 +87,17 @@
<file>Design-Core/core/tools/tool.js</file>
<file>Design-Core/core/tools/purge.js</file>

<file>Design-Core/core/styles/layer.js</file>
<file>Design-Core/core/styles/layerManager.js</file>
<file>Design-Core/core/styles/ltype.js</file>
<file>Design-Core/core/styles/ltypeManager.js</file>
<file>Design-Core/core/styles/styleManagerBase.js</file>
<file>Design-Core/core/styles/dimStyle.js</file>
<file>Design-Core/core/styles/dimStyleManager.js</file>
<file>Design-Core/core/styles/style.js</file>
<file>Design-Core/core/styles/styleManager.js</file>
<file>Design-Core/core/tables/block.js</file>
<file>Design-Core/core/tables/blockManager.js</file>
<file>Design-Core/core/tables/dimStyle.js</file>
<file>Design-Core/core/tables/dimStyleManager.js</file>
<file>Design-Core/core/tables/layer.js</file>
<file>Design-Core/core/tables/layerManager.js</file>
<file>Design-Core/core/tables/ltype.js</file>
<file>Design-Core/core/tables/ltypeManager.js</file>
<file>Design-Core/core/tables/style.js</file>
<file>Design-Core/core/tables/styleManager.js</file>
<file>Design-Core/core/tables/styleManagerBase.js</file>
<file>Design-Core/core/tables/tableManagerBase.js</file>
</gresource>
</gresources>

0 comments on commit 997648c

Please sign in to comment.