Better sliders for Decoration editor
This commit is contained in:
parent
55acb6aa80
commit
81f3114cb2
@ -11,20 +11,29 @@ public:
|
||||
|
||||
ToolType decoMode;
|
||||
|
||||
unsigned char Red;
|
||||
unsigned char Green;
|
||||
unsigned char Blue;
|
||||
unsigned char Alpha;
|
||||
|
||||
DecorationTool(ToolType decoMode_, string name, int r, int g, int b):
|
||||
Tool(0, name, r, g, b),
|
||||
decoMode(decoMode_)
|
||||
decoMode(decoMode_),
|
||||
Red(0),
|
||||
Green(0),
|
||||
Blue(0),
|
||||
Alpha(0)
|
||||
{
|
||||
}
|
||||
virtual ~DecorationTool() {}
|
||||
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position){
|
||||
sim->ApplyDecorationPoint(position.X, position.Y, 1, 1, colRed, colGreen, colBlue, 255, decoMode, brush);
|
||||
sim->ApplyDecorationPoint(position.X, position.Y, 1, 1, Red, Green, Blue, Alpha, decoMode, brush);
|
||||
}
|
||||
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {
|
||||
sim->ApplyDecorationLine(position1.X, position1.Y, position2.X, position2.Y, 1, 1, colRed, colGreen, colBlue, 255, decoMode, brush);
|
||||
sim->ApplyDecorationLine(position1.X, position1.Y, position2.X, position2.Y, 1, 1, Red, Green, Blue, Alpha, decoMode, brush);
|
||||
}
|
||||
virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {
|
||||
sim->ApplyDecorationBox(position1.X, position1.Y, position2.X, position2.Y, colRed, colGreen, colBlue, 255, decoMode);
|
||||
sim->ApplyDecorationBox(position1.X, position1.Y, position2.X, position2.Y, Red, Green, Blue, Alpha, decoMode);
|
||||
}
|
||||
virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position) {
|
||||
|
||||
|
@ -348,10 +348,16 @@ bool GameModel::GetColourSelectorVisibility()
|
||||
|
||||
void GameModel::SetColourSelectorColour(ui::Colour colour_)
|
||||
{
|
||||
//if(this->colour!=colour)
|
||||
colour = colour_;
|
||||
notifyColourSelectorColourChanged();
|
||||
|
||||
vector<Tool*> tools = GetMenuList()[SC_DECO]->GetToolList();
|
||||
for(int i = 0; i < tools.size(); i++)
|
||||
{
|
||||
colour = colour_;
|
||||
notifyColourSelectorColourChanged();
|
||||
((DecorationTool*)tools[i])->Red = colour.Red;
|
||||
((DecorationTool*)tools[i])->Green = colour.Green;
|
||||
((DecorationTool*)tools[i])->Blue = colour.Blue;
|
||||
((DecorationTool*)tools[i])->Alpha = colour.Alpha;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,6 +213,8 @@ GameView::GameView():
|
||||
colourGSlider->SetActionCallback(colC);
|
||||
colourBSlider = new ui::Slider(ui::Point(185, Size.Y-39), ui::Point(80, 14), 255);
|
||||
colourBSlider->SetActionCallback(colC);
|
||||
colourASlider = new ui::Slider(ui::Point(275, Size.Y-39), ui::Point(50, 14), 255);
|
||||
colourASlider->SetActionCallback(colC);
|
||||
}
|
||||
|
||||
class GameView::MenuAction: public ui::ButtonAction
|
||||
@ -355,11 +357,14 @@ void GameView::NotifyColourSelectorVisibilityChanged(GameModel * sender)
|
||||
colourGSlider->SetParentWindow(NULL);
|
||||
RemoveComponent(colourBSlider);
|
||||
colourBSlider->SetParentWindow(NULL);
|
||||
RemoveComponent(colourASlider);
|
||||
colourASlider->SetParentWindow(NULL);
|
||||
if(sender->GetColourSelectorVisibility())
|
||||
{
|
||||
AddComponent(colourRSlider);
|
||||
AddComponent(colourGSlider);
|
||||
AddComponent(colourBSlider);
|
||||
AddComponent(colourASlider);
|
||||
}
|
||||
|
||||
}
|
||||
@ -372,15 +377,8 @@ void GameView::NotifyColourSelectorColourChanged(GameModel * sender)
|
||||
colourGSlider->SetColour(ui::Colour(sender->GetColourSelectorColour().Red, 0, sender->GetColourSelectorColour().Blue), ui::Colour(sender->GetColourSelectorColour().Red, 255, sender->GetColourSelectorColour().Blue));
|
||||
colourBSlider->SetValue(sender->GetColourSelectorColour().Blue);
|
||||
colourBSlider->SetColour(ui::Colour(sender->GetColourSelectorColour().Red, sender->GetColourSelectorColour().Green, 0), ui::Colour(sender->GetColourSelectorColour().Red, sender->GetColourSelectorColour().Green, 255));
|
||||
|
||||
vector<Tool*> tools = sender->GetMenuList()[SC_DECO]->GetToolList();
|
||||
for(int i = 0; i < tools.size(); i++)
|
||||
{
|
||||
tools[i]->colRed = sender->GetColourSelectorColour().Red;
|
||||
tools[i]->colGreen = sender->GetColourSelectorColour().Green;
|
||||
tools[i]->colBlue = sender->GetColourSelectorColour().Blue;
|
||||
}
|
||||
NotifyToolListChanged(sender);
|
||||
colourASlider->SetValue(sender->GetColourSelectorColour().Alpha);
|
||||
colourASlider->SetColour(ui::Colour(0, 0, 0), ui::Colour(255, 255, 255));
|
||||
}
|
||||
|
||||
void GameView::NotifyRendererChanged(GameModel * sender)
|
||||
@ -622,7 +620,7 @@ void GameView::NotifyZoomChanged(GameModel * sender)
|
||||
|
||||
void GameView::changeColour()
|
||||
{
|
||||
c->SetColour(ui::Colour(colourRSlider->GetValue(), colourGSlider->GetValue(), colourBSlider->GetValue()));
|
||||
c->SetColour(ui::Colour(colourRSlider->GetValue(), colourGSlider->GetValue(), colourBSlider->GetValue(), colourASlider->GetValue()));
|
||||
}
|
||||
|
||||
void GameView::OnDraw()
|
||||
|
@ -52,6 +52,7 @@ private:
|
||||
ui::Slider * colourRSlider;
|
||||
ui::Slider * colourGSlider;
|
||||
ui::Slider * colourBSlider;
|
||||
ui::Slider * colourASlider;
|
||||
|
||||
bool drawModeReset;
|
||||
ui::Point drawPoint1;
|
||||
|
@ -6,9 +6,13 @@ namespace ui
|
||||
class Colour
|
||||
{
|
||||
public:
|
||||
unsigned char Red, Green, Blue;
|
||||
unsigned char Red, Green, Blue, Alpha;
|
||||
Colour(unsigned char red, unsigned char green, unsigned char blue):
|
||||
Red(red), Green(green), Blue(blue)
|
||||
Red(red), Green(green), Blue(blue), Alpha(255)
|
||||
{
|
||||
}
|
||||
Colour(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha):
|
||||
Red(red), Green(green), Blue(blue), Alpha(alpha)
|
||||
{
|
||||
}
|
||||
Colour()
|
||||
|
@ -325,36 +325,29 @@ void Simulation::ApplyDecoration(int x, int y, int colR_, int colG_, int colB_,
|
||||
}
|
||||
else if (mode == DECO_ADD)
|
||||
{
|
||||
tr += colR*0.05f;
|
||||
tg += colG*0.05f;
|
||||
tb += colB*0.05f;
|
||||
ta += (colA*0.1f)*colA;
|
||||
tr += (colR*0.1f)*colA;
|
||||
tg += (colG*0.1f)*colA;
|
||||
tb += (colB*0.1f)*colA;
|
||||
}
|
||||
else if (mode == DECO_SUBTRACT)
|
||||
{
|
||||
tr -= colR*0.05f;
|
||||
tg -= colG*0.05f;
|
||||
tb -= colB*0.05f;
|
||||
ta -= (colA*0.1f)*colA;
|
||||
tr -= (colR*0.1f)*colA;
|
||||
tg -= (colG*0.1f)*colA;
|
||||
tb -= (colB*0.1f)*colA;
|
||||
}
|
||||
else if (mode == DECO_MULTIPLY)
|
||||
{
|
||||
tr *= colR*0.05f;
|
||||
tg *= colG*0.05f;
|
||||
tb *= colB*0.05f;
|
||||
tr *= 1.0f+(colR*0.1f)*colA;
|
||||
tg *= 1.0f+(colG*0.1f)*colA;
|
||||
tb *= 1.0f+(colB*0.1f)*colA;
|
||||
}
|
||||
else if (mode == DECO_DIVIDE)
|
||||
{
|
||||
if(colR>0)
|
||||
tr /= colR*0.05f;
|
||||
else
|
||||
tr = 0.0f;
|
||||
if(colG>0)
|
||||
tg /= colG*0.05f;
|
||||
else
|
||||
tg = 0.0f;
|
||||
if(colB>0)
|
||||
tb /= colB*0.05f;
|
||||
else
|
||||
tb = 0.0f;
|
||||
tr /= 1.0f+(colR*0.1f)*colA;
|
||||
tg /= 1.0f+(colG*0.1f)*colA;
|
||||
tb /= 1.0f+(colB*0.1f)*colA;
|
||||
}
|
||||
|
||||
colA_ = ta*255.0f;
|
||||
|
Reference in New Issue
Block a user