Skip to content

Commit e13f044

Browse files
tool groups
1 parent 0fa3770 commit e13f044

File tree

11 files changed

+312
-80
lines changed

11 files changed

+312
-80
lines changed

source/wsedit/tools/camera/package.d

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module wsedit.tools.camera;
2+
import wsedit.tools;
3+
4+
public import wsedit.tools.camera.zonetool;
5+
6+
class CameraGroup : ToolGroup {
7+
public:
8+
this(Workspace workspace) {
9+
super("Camera", "camera-video-symbolic", workspace);
10+
tools = [new ZoneTool(workspace, this)];
11+
}
12+
}

source/wsedit/tools/camera/zonetool.d

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module wsedit.tools.camera.zonetool;
2+
import wsedit.tools;
3+
4+
/**
5+
Select tool
6+
*/
7+
class ZoneTool : Tool {
8+
private:
9+
10+
public:
11+
this(Workspace workspace, ToolGroup group) {
12+
super("Zone Tool", "edit-select-all-symbolic", group, workspace);
13+
}
14+
15+
override void draw(Renderer renderer) {
16+
17+
}
18+
19+
override void update(Mouse mouse) {
20+
21+
}
22+
}

source/wsedit/tools/package.d

+37-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ public import wsedit.workspace;
33
public import wsedit.subsystem.wsrenderer;
44
public import wsedit.subsystem.mouse;
55

6-
public import wsedit.tools.tiletool;
7-
public import wsedit.tools.selecttool;
8-
public import wsedit.tools.erasetool;
6+
public import wsedit.tools.tiles;
7+
public import wsedit.tools.camera;
98

109
/**
1110
A tool provides functionality on the canvas
@@ -14,10 +13,11 @@ class Tool {
1413
protected:
1514
Workspace workspace;
1615

17-
this(string name, string iconName, Workspace workspace) {
16+
this(string name, string iconName, ToolGroup parent, Workspace workspace) {
1817
this.name = name;
1918
this.iconName = iconName;
2019
this.workspace = workspace;
20+
this.parent = parent;
2121
}
2222

2323
public:
@@ -31,6 +31,11 @@ public:
3131
*/
3232
immutable(string) iconName;
3333

34+
/**
35+
The group this tool belongs to
36+
*/
37+
ToolGroup parent;
38+
3439
/**
3540
Draw tool related UI on to the canvas
3641
Selections, etc.
@@ -43,3 +48,31 @@ public:
4348
abstract void update(Mouse mouse);
4449
}
4550

51+
/**
52+
A group of tools
53+
*/
54+
class ToolGroup {
55+
protected:
56+
Workspace workspace;
57+
58+
this(string name, string iconName, Workspace workspace) {
59+
this.name = name;
60+
this.iconName = iconName;
61+
this.workspace = workspace;
62+
}
63+
public:
64+
/**
65+
Name of the tool
66+
*/
67+
immutable(string) name;
68+
69+
/**
70+
Name of the tool's icon
71+
*/
72+
immutable(string) iconName;
73+
74+
/**
75+
Tools in the tool group
76+
*/
77+
Tool[] tools;
78+
}

source/wsedit/tools/selecttool.d

-14
This file was deleted.

source/wsedit/tools/erasetool.d renamed to source/wsedit/tools/tiles/erasetool.d

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module wsedit.tools.erasetool;
1+
module wsedit.tools.tiles.erasetool;
22
import wsedit.tools;
33
import wsedit;
44
import wsedit.fmt;
@@ -16,8 +16,8 @@ private:
1616

1717

1818
public:
19-
this(Workspace workspace) {
20-
super("Erase Tile", "edit-delete-symbolic", workspace);
19+
this(Workspace workspace, ToolGroup group) {
20+
super("Erase Tool", "edit-delete-symbolic", group, workspace);
2121
}
2222

2323
override void draw(Renderer renderer) {

source/wsedit/tools/tiles/package.d

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module wsedit.tools.tiles;
2+
import wsedit.tools;
3+
public import wsedit.tools.tiles.erasetool;
4+
public import wsedit.tools.tiles.tiletool;
5+
public import wsedit.tools.tiles.selecttool;
6+
7+
class TileGroup : ToolGroup {
8+
public:
9+
this(Workspace workspace) {
10+
super("Tiles", "view-grid-symbolic", workspace);
11+
tools = [new TileTool(workspace, this), new SelectTool(workspace, this), new EraseTool(workspace, this)];
12+
}
13+
}
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module wsedit.tools.tiles.selecttool;
2+
import wsedit.tools;
3+
4+
/**
5+
Select tool
6+
*/
7+
class SelectTool : Tool {
8+
private:
9+
10+
public:
11+
this(Workspace workspace, ToolGroup group) {
12+
super("Select Tool", "edit-select-all-symbolic", group, workspace);
13+
}
14+
15+
override void draw(Renderer renderer) {
16+
17+
}
18+
19+
override void update(Mouse mouse) {
20+
21+
}
22+
}

source/wsedit/tools/tiletool.d renamed to source/wsedit/tools/tiles/tiletool.d

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module wsedit.tools.tiletool;
1+
module wsedit.tools.tiles.tiletool;
22
import wsedit.tools;
33
import wsedit;
44
import wsedit.fmt;
@@ -16,8 +16,8 @@ private:
1616

1717

1818
public:
19-
this(Workspace workspace) {
20-
super("Tile", "view-grid-symbolic", workspace);
19+
this(Workspace workspace, ToolGroup group) {
20+
super("Tile Tool", "insert-object-symbolic", group, workspace);
2121
}
2222

2323
override void draw(Renderer renderer) {

0 commit comments

Comments
 (0)