Skip to content

Commit 55e0583

Browse files
nonfunctional toolbox, more polish
1 parent 121162c commit 55e0583

File tree

10 files changed

+182
-31
lines changed

10 files changed

+182
-31
lines changed

dub.sdl

-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ authors "Cospec Games" "Luna Nielsen"
44
copyright "Copyright © 2019, Cospec Games"
55
license "BSD 2-clause"
66
dependency "wsfmt" version="~master"
7-
dependency "bindbc-opengl" version="~>0.9.0"
87
dependency "gtk-d" version="~>3.9.0"
98
dependency "sdlang-d" version="~>0.10.5"
10-
dependency "gfm" version="~>8.0.1"
119
dependency "d-dazzle" version="~>1.0.1"
1210
dependency "d-handy" version="~>0.0.11"
13-
dependency "imageformats" version="~>7.0.2"

source/wsedit/subsystem/scenerenderer.d

Whitespace-only changes.

source/wsedit/widgets/headerbar.d

-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ public:
174174
// Set the systemwide window title
175175
appwin.setName(wname);
176176
appwin.setTitle(wname);
177-
appwin.setWmclass(wname, "WSEdit");
178177

179178
// Set the title label.
180179
titleLabel.setText(name.length == 0 ? "Wereshift Scene Editor" : name);

source/wsedit/widgets/package.d

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
module wsedit.widgets;
1313
public import wsedit.widgets.headerbar;
14-
public import wsedit.widgets.workspace;
1514
public import wsedit.widgets.pages;
1615
public import wsedit.widgets.pathbox;
17-
public import wsedit.widgets.veccombo;
16+
public import wsedit.widgets.veccombo;
17+
public import wsedit.widgets.toolbox;

source/wsedit/widgets/pages/package.d

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1111
*/
1212
module wsedit.widgets.pages;
13-
public import wsedit.widgets.pages.newscene;
13+
public import wsedit.widgets.pages.newscene;
14+
public import wsedit.widgets.pages.workspace;

source/wsedit/widgets/workspace.d renamed to source/wsedit/widgets/pages/workspace.d

+42-22
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,24 @@
99
1010
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1111
*/
12-
module wsedit.widgets.workspace;
12+
module wsedit.widgets.pages.workspace;
1313
import gtk.DrawingArea;
14+
import gtk.Overlay;
15+
import gtk.Widget;
16+
import gtk.Revealer;
17+
import gtk.Box;
18+
import gdkpixbuf.Pixbuf;
1419
import gdk.Cairo;
20+
import gdk.DragContext;
21+
import gdk.Cursor;
1522
import cairo.Context;
1623
import cairo.ImageSurface;
1724
import cairo.RecordingSurface;
1825
import cairo.FontFace;
1926
import cairo.FontOption;
2027
import cairo.Pattern;
2128
import cairo.Matrix;
22-
import cairo.c.functions : cairo_matrix_init_identity;
23-
import gdkpixbuf.Pixbuf;
24-
import gtk.Widget;
25-
import gdk.DragContext;
26-
import gdk.Cursor;
27-
import core.memory : GC;
29+
import wsedit.widgets;
2830
import wsedit;
2931

3032
// status text
@@ -36,9 +38,8 @@ private {
3638
/**
3739
The editor workspace
3840
*/
39-
class Workspace : DrawingArea {
41+
class WorkspaceViewport : DrawingArea {
4042
private:
41-
4243
double animOffset = 0.0;
4344

4445
double mouseX;
@@ -273,24 +274,29 @@ public:
273274
*/
274275
Camera2D camera;
275276

276-
/**
277-
The tile that the mouse is hovering over
278-
*/
279-
Selection selectedTile;
280-
281277
this() {
282278
super(1, 1);
283-
selectedTile = Selection(0, 0);
284-
285279
wereshiftLogo = new Pixbuf("res/wereshift.png");
280+
281+
/* Update */
282+
import gtk.Widget : Widget;
283+
import gdk.FrameClock : FrameClock;
284+
this.addTickCallback((Widget, FrameClock) {
285+
queueDraw();
286+
return true;
287+
});
288+
289+
/* Draw */
286290
this.addOnDraw((Scoped!Context ctx, Widget _) {
287291
return onDraw(ctx);
288292
});
289293

294+
/* Size alloc */
290295
this.addOnSizeAllocate((Allocation alloc, Widget) {
291296
area = GdkRectangle(alloc.x, alloc.y, alloc.width, alloc.height);
292297
});
293298

299+
/* Mouse controls */
294300
this.addOnMotionNotify(&onMotion);
295301
this.addOnButtonPress((GdkEventButton* ev, Widget) {
296302
if (STATE.scene is null) return true;
@@ -349,12 +355,26 @@ public:
349355
queueDraw();
350356
return true;
351357
});
358+
}
359+
}
352360

353-
import gtk.Widget : Widget;
354-
import gdk.FrameClock : FrameClock;
355-
this.addTickCallback((Widget, FrameClock) {
356-
queueDraw();
357-
return true;
358-
});
361+
class Workspace : Box {
362+
public:
363+
Overlay overlay;
364+
WorkspaceViewport viewport;
365+
Toolbox toolbox;
366+
367+
this() {
368+
super(Orientation.HORIZONTAL, 0);
369+
viewport = new WorkspaceViewport();
370+
overlay = new Overlay();
371+
toolbox = new Toolbox();
372+
toolbox.setValign(Align.START);
373+
toolbox.setHalign(Align.START);
374+
overlay.add(viewport);
375+
overlay.addOverlay(toolbox);
376+
377+
this.packStart(overlay, true, true, 0);
359378
}
379+
360380
}

source/wsedit/widgets/sidebar.d

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module wsedit.widgets.sidebar;
2+
import gtk.Box;
3+
import gtk.Widget;
4+
import gtk.ScrolledWindow;
5+
import gtk.Revealer;
6+
import dazzle.DockBin;
7+
8+
class Sidebar : Revealer {
9+
public:
10+
11+
this() {
12+
}
13+
14+
void open() {
15+
this.setRevealChild(true);
16+
}
17+
18+
void close() {
19+
this.setRevealChild(false);
20+
}
21+
22+
}

source/wsedit/widgets/toolbox.d

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
module wsedit.widgets.toolbox;
2+
import gtk.ToggleButton;
3+
import gtk.Label;
4+
import gtk.Box;
5+
import gtk.Image;
6+
import gtk.Widget;
7+
import dazzle.EntryBox;
8+
import gtk.ButtonBox;
9+
10+
class Toolbox : Box {
11+
private:
12+
Label titleBox;
13+
14+
Box buttons;
15+
ToggleButton[] tools;
16+
ToggleButton activeTool;
17+
18+
ToggleButton selectToolButton;
19+
ToggleButton tileToolButton;
20+
ToggleButton objectToolButton;
21+
ToggleButton parallaxRegionTool;
22+
bool isUpdating;
23+
24+
bool toolHoverHandler(Widget widget) {
25+
titleBox.setText(widget.getName());
26+
return false;
27+
}
28+
29+
bool toolLeaveHandler(Widget widget) {
30+
titleBox.setText(activeTool.getName());
31+
return false;
32+
}
33+
34+
void activationHandler(ToggleButton button) {
35+
if (!isUpdating) {
36+
isUpdating = true;
37+
activeTool = button;
38+
39+
foreach(tool; tools) {
40+
41+
// You can't disable tools altogether.
42+
if (tool == button) {
43+
tool.setActive(true);
44+
continue;
45+
}
46+
47+
tool.setActive(false);
48+
}
49+
50+
isUpdating = false;
51+
}
52+
}
53+
54+
55+
public:
56+
this() {
57+
super(Orientation.VERTICAL, 0);
58+
this.setMarginTop(8);
59+
this.setMarginLeft(8);
60+
61+
titleBox = new Label("");
62+
63+
buttons = new Box(Orientation.HORIZONTAL, 0);
64+
buttons.getStyleContext().addClass("linked");
65+
66+
selectToolButton = new ToggleButton();
67+
selectToolButton.setName("Select Tool");
68+
selectToolButton.setImage(new Image("edit-select-all-symbolic", IconSize.MENU));
69+
selectToolButton.addOnEnterNotify((GdkEventCrossing*, _) { return toolHoverHandler(selectToolButton); });
70+
selectToolButton.addOnLeaveNotify((GdkEventCrossing*, _) { return toolLeaveHandler(selectToolButton); });
71+
selectToolButton.addOnToggled(&activationHandler);
72+
activeTool = selectToolButton;
73+
74+
tileToolButton = new ToggleButton();
75+
tileToolButton.setName("Tile Tool");
76+
tileToolButton.setImage(new Image("view-grid-symbolic", IconSize.MENU));
77+
tileToolButton.addOnEnterNotify((GdkEventCrossing*, _) { return toolHoverHandler(tileToolButton); });
78+
tileToolButton.addOnLeaveNotify((GdkEventCrossing*, _) { return toolLeaveHandler(tileToolButton); });
79+
tileToolButton.addOnToggled(&activationHandler);
80+
81+
objectToolButton = new ToggleButton();
82+
objectToolButton.setName("Actor Tool");
83+
objectToolButton.setImage(new Image("insert-object-symbolic", IconSize.MENU));
84+
objectToolButton.addOnEnterNotify((GdkEventCrossing*, _) { return toolHoverHandler(objectToolButton); });
85+
objectToolButton.addOnLeaveNotify((GdkEventCrossing*, _) { return toolLeaveHandler(objectToolButton); });
86+
objectToolButton.addOnToggled(&activationHandler);
87+
88+
parallaxRegionTool = new ToggleButton();
89+
parallaxRegionTool.setName("Parallax Tool");
90+
parallaxRegionTool.setImage(new Image("insert-image-symbolic", IconSize.MENU));
91+
parallaxRegionTool.addOnEnterNotify((GdkEventCrossing*, _) { return toolHoverHandler(parallaxRegionTool); });
92+
parallaxRegionTool.addOnLeaveNotify((GdkEventCrossing*, _) { return toolLeaveHandler(parallaxRegionTool); });
93+
parallaxRegionTool.addOnToggled(&activationHandler);
94+
95+
tools = [selectToolButton, tileToolButton, objectToolButton, parallaxRegionTool];
96+
97+
buttons.packStart(selectToolButton, false, false, 0);
98+
buttons.packStart(tileToolButton, false, false, 0);
99+
buttons.packStart(objectToolButton, false, false, 0);
100+
buttons.packStart(parallaxRegionTool, false, false, 0);
101+
selectToolButton.setActive(true);
102+
103+
104+
this.packStart(buttons, false, false, 0);
105+
this.packEnd(titleBox, false, false, 0);
106+
107+
// Activate select tool by default
108+
selectToolButton.setActive(true);
109+
titleBox.setText(activeTool.getName());
110+
}
111+
}

source/wsedit/widgets/veccombo.d

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public:
121121
x.addOnChanged((_) {
122122
if (lockedTogether && !isChanging) {
123123
isChanging = true;
124-
y.setText(x.getText);
124+
y.setValue(x.getValue);
125125
return;
126126
}
127127

@@ -131,7 +131,7 @@ public:
131131
y.addOnChanged((_) {
132132
if (lockedTogether && !isChanging) {
133133
isChanging = true;
134-
x.setText(y.getText);
134+
x.setValue(y.getValue);
135135
return;
136136
}
137137

source/wsedit/windows/appwin.d

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public:
7171
this.setTitlebar(header);
7272
this.add(stack);
7373
this.setIconFromFile("res/wereshift.png");
74+
this.setWmclass("Wereshift Scene Editor", "WSEdit");
7475
this.setSizeRequest(800, 600);
7576
this.showAll();
7677
}

0 commit comments

Comments
 (0)