summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-07-28 13:13:28 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-07-28 13:13:28 (GMT)
commitfc93b714852b1bd0741fd75a9dd01358f32fa9f0 (patch)
tree449e9c5add679af58a660a74b056f2827b6eec1f /src
parentf9eeebb91039d88ceb7e4cf4e4aecf374d77e633 (diff)
downloadpowder-fc93b714852b1bd0741fd75a9dd01358f32fa9f0.zip
powder-fc93b714852b1bd0741fd75a9dd01358f32fa9f0.tar.gz
Resize brush X and Y axis seperately using Shift and Control, Addresses issue #27
Diffstat (limited to 'src')
-rw-r--r--src/game/Brush.h2
-rw-r--r--src/game/GameController.cpp15
-rw-r--r--src/game/GameController.h2
-rw-r--r--src/game/GameView.cpp51
-rw-r--r--src/game/GameView.h12
5 files changed, 60 insertions, 22 deletions
diff --git a/src/game/Brush.h b/src/game/Brush.h
index a7737ee..a7f88f6 100644
--- a/src/game/Brush.h
+++ b/src/game/Brush.h
@@ -32,7 +32,7 @@ protected:
{
for(int y = 0; y < size.Y; y++)
{
- if(bitmap[y*size.X+x] && (!y || !x || y == size.X-1 || x == size.Y-1 || !bitmap[y*size.X+(x+1)] || !bitmap[y*size.X+(x-1)] || !bitmap[(y-1)*size.X+x] || !bitmap[(y+1)*size.X+x]))
+ if(bitmap[y*size.X+x] && (!y || !x || x == size.X-1 || y == size.Y-1 || !bitmap[y*size.X+(x+1)] || !bitmap[y*size.X+(x-1)] || !bitmap[(y-1)*size.X+x] || !bitmap[(y+1)*size.X+x]))
outline[y*size.X+x] = 255;
else
outline[y*size.X+x] = 0;
diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp
index db23bb8..aede8d6 100644
--- a/src/game/GameController.cpp
+++ b/src/game/GameController.cpp
@@ -185,9 +185,13 @@ void GameController::PlaceSave(ui::Point position)
}
}
-void GameController::AdjustBrushSize(int direction, bool logarithmic)
+void GameController::AdjustBrushSize(int direction, bool logarithmic, bool xAxis, bool yAxis)
{
+ if(xAxis && yAxis)
+ return;
+
ui::Point newSize(0, 0);
+ ui::Point oldSize = gameModel->GetBrush()->GetRadius();
if(logarithmic)
newSize = gameModel->GetBrush()->GetRadius() + ui::Point(direction * ((gameModel->GetBrush()->GetRadius().X/10)>0?gameModel->GetBrush()->GetRadius().X/10:1), direction * ((gameModel->GetBrush()->GetRadius().Y/10)>0?gameModel->GetBrush()->GetRadius().Y/10:1));
else
@@ -196,7 +200,14 @@ void GameController::AdjustBrushSize(int direction, bool logarithmic)
newSize.X = 0;
if(newSize.Y<0)
newSize.Y = 0;
- gameModel->GetBrush()->SetRadius(newSize);
+
+ if(xAxis)
+ gameModel->GetBrush()->SetRadius(ui::Point(newSize.X, oldSize.Y));
+ else if(yAxis)
+ gameModel->GetBrush()->SetRadius(ui::Point(oldSize.X, newSize.Y));
+ else
+ gameModel->GetBrush()->SetRadius(newSize);
+
BrushChanged(gameModel->GetBrushID(), gameModel->GetBrush()->GetRadius().X, gameModel->GetBrush()->GetRadius().Y);
}
diff --git a/src/game/GameController.h b/src/game/GameController.h
index 335e624..a7e0776 100644
--- a/src/game/GameController.h
+++ b/src/game/GameController.h
@@ -68,7 +68,7 @@ public:
void LoadRenderPreset(RenderPreset preset);
void SetZoomEnabled(bool zoomEnable);
void SetZoomPosition(ui::Point position);
- void AdjustBrushSize(int direction, bool logarithmic = false);
+ void AdjustBrushSize(int direction, bool logarithmic = false, bool xAxis = false, bool yAxis = false);
void AdjustZoomSize(int direction, bool logarithmic = false);
void ToolClick(int toolSelection, ui::Point point);
void DrawPoints(int toolSelection, queue<ui::Point*> & pointQueue);
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp
index a35f524..6544674 100644
--- a/src/game/GameView.cpp
+++ b/src/game/GameView.cpp
@@ -38,7 +38,8 @@ GameView::GameView():
infoTip(""),
infoTipPresence(0),
toolTipPosition(-1, -1),
- alternativeSaveSource(false)
+ shiftBehaviour(false),
+ ctrlBehaviour(false)
{
int currentX = 1;
@@ -50,7 +51,7 @@ GameView::GameView():
SearchAction(GameView * _v) { v = _v; }
void ActionCallback(ui::Button * sender)
{
- if(v->GetAlternativeSourceEnabled())
+ if(v->CtrlBehaviour())
v->c->OpenLocalBrowse();
else
v->c->OpenSearch();
@@ -93,7 +94,7 @@ GameView::GameView():
SaveSimulationAction(GameView * _v) { v = _v; }
void ActionCallback(ui::Button * sender)
{
- if(v->GetAlternativeSourceEnabled())
+ if(v->CtrlBehaviour())
v->c->OpenLocalSaveWindow();
else
v->c->OpenSaveWindow();
@@ -792,7 +793,7 @@ void GameView::OnMouseWheel(int x, int y, int d)
}
else
{
- c->AdjustBrushSize(d);
+ c->AdjustBrushSize(d, false, shiftBehaviour, ctrlBehaviour);
if(isMouseDown)
{
pointQueue.push(new ui::Point(x, y));
@@ -854,7 +855,7 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
drawMode = DrawFill;
else
drawMode = DrawRect;
- enableHDDSave();
+ enableCtrlBehaviour();
break;
case KEY_SHIFT:
if(drawModeReset)
@@ -865,6 +866,7 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
drawMode = DrawFill;
else
drawMode = DrawLine;
+ enableShiftBehaviour();
break;
case ' ': //Space
c->SetPaused();
@@ -920,10 +922,10 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
c->OpenStamps();
break;
case ']':
- c->AdjustBrushSize(1, true);
+ c->AdjustBrushSize(1, true, shiftBehaviour, ctrlBehaviour);
break;
case '[':
- c->AdjustBrushSize(-1, true);
+ c->AdjustBrushSize(-1, true, shiftBehaviour, ctrlBehaviour);
break;
}
@@ -949,7 +951,10 @@ void GameView::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bo
drawSnap = false;
break;
case KEY_CTRL:
- disableHDDSave();
+ disableCtrlBehaviour();
+ break;
+ case KEY_SHIFT:
+ disableShiftBehaviour();
break;
case 'z':
if(!zoomCursorFixed)
@@ -1163,12 +1168,29 @@ void GameView::changeColour()
c->SetColour(ui::Colour(colourRSlider->GetValue(), colourGSlider->GetValue(), colourBSlider->GetValue(), colourASlider->GetValue()));
}
-void GameView::enableHDDSave()
+void GameView::enableShiftBehaviour()
+{
+ if(!shiftBehaviour)
+ {
+ shiftBehaviour = true;
+ }
+}
+
+void GameView::disableShiftBehaviour()
+{
+ if(shiftBehaviour)
+ {
+ shiftBehaviour = false;
+ }
+}
+
+void GameView::enableCtrlBehaviour()
{
- if(!alternativeSaveSource)
+ if(!ctrlBehaviour)
{
- alternativeSaveSource = true;
+ ctrlBehaviour = true;
+ //Show HDD save & load buttons
saveSimulationButton->Appearance.BackgroundInactive = ui::Colour(255, 255, 255);
saveSimulationButton->Appearance.TextInactive = ui::Colour(0, 0, 0);
searchButton->Appearance.BackgroundInactive = ui::Colour(255, 255, 255);
@@ -1176,12 +1198,13 @@ void GameView::enableHDDSave()
}
}
-void GameView::disableHDDSave()
+void GameView::disableCtrlBehaviour()
{
- if(alternativeSaveSource)
+ if(ctrlBehaviour)
{
- alternativeSaveSource = false;
+ ctrlBehaviour = false;
+ //Hide HDD save & load buttons
saveSimulationButton->Appearance.BackgroundInactive = ui::Colour(0, 0, 0);
saveSimulationButton->Appearance.TextInactive = ui::Colour(255, 255, 255);
searchButton->Appearance.BackgroundInactive = ui::Colour(0, 0, 0);
diff --git a/src/game/GameView.h b/src/game/GameView.h
index 2bf8e9e..9010e4a 100644
--- a/src/game/GameView.h
+++ b/src/game/GameView.h
@@ -37,7 +37,8 @@ private:
bool zoomEnabled;
bool zoomCursorFixed;
bool drawSnap;
- bool alternativeSaveSource;
+ bool shiftBehaviour;
+ bool ctrlBehaviour;
int toolIndex;
int infoTipPresence;
@@ -96,15 +97,18 @@ private:
virtual ui::Point lineSnapCoords(ui::Point point1, ui::Point point2);
virtual ui::Point rectSnapCoords(ui::Point point1, ui::Point point2);
- void enableHDDSave();
- void disableHDDSave();
+ void enableShiftBehaviour();
+ void disableShiftBehaviour();
+ void enableCtrlBehaviour();
+ void disableCtrlBehaviour();
public:
GameView();
//Breaks MVC, but any other way is going to be more of a mess.
ui::Point GetMousePosition();
void SetSample(SimulationSample sample);
- bool GetAlternativeSourceEnabled(){ return alternativeSaveSource; }
+ bool CtrlBehaviour(){ return ctrlBehaviour; }
+ bool ShiftBehaviour(){ return shiftBehaviour; }
void AttachController(GameController * _c){ c = _c; }
void NotifyRendererChanged(GameModel * sender);