-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew_operation.cpp
69 lines (51 loc) · 1.53 KB
/
new_operation.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "libtcod.hpp"
#include "gui/gui.hpp"
#include "app.h"
#include "message_box.h"
#include "new_operation.h"
#include "save_operation.h"
NewOperation::NewOperation() {
}
NewOperation::~NewOperation() {
}
void NewOperation::start() {
bool makeNew = true;
if(app->canvasModified) {
MessageBox msgBox("New", "Save changes to file?", 3);
msgBox.show();
int choice = msgBox.getButtonPressed();
if(choice == 1) { // Yes
doSave(app);
}
if(choice == 0 || choice == 3) // User pressed Cancel or escape
makeNew = false;
}
if(makeNew) {
MessageBox msgBox2("New", "New image properties", 2);
// Add Width and Height sliders
// I intentionally add a space after width so that it aligns nicely with
// the height slider
Slider widthSlider(0, 0, 4, 1.0f, 1024.0f, "width ", "Width of the new image");
widthSlider.setFormat("%.0f");
widthSlider.setSensitivity(0.2);
widthSlider.setValue(app->canvasWidth);
Slider heightSlider(0, 0, 4, 1.0f, 1024.0f, "height", "Height of the new image");
heightSlider.setFormat("%.0f");
heightSlider.setSensitivity(0.2);
heightSlider.setValue(app->canvasHeight);
msgBox2.addCustomWidget(&widthSlider);
msgBox2.addCustomWidget(&heightSlider);
msgBox2.show();
if(msgBox2.getButtonPressed() == 1) { // OK
// Make a new canvas
app->canvasWidth = atoi(widthSlider.getValue());
app->canvasHeight = atoi(heightSlider.getValue());
app->initCanvas();
}
}
app->changeOperation(app->previousOperation);
}
void NewOperation::update() {
}
void NewOperation::end() {
}