diff --git a/src/interface/DropDown.cpp b/src/interface/DropDown.cpp new file mode 100644 index 000000000..6944e6f52 --- /dev/null +++ b/src/interface/DropDown.cpp @@ -0,0 +1,75 @@ +/* + * DropDown.cpp + * + * Created on: Apr 16, 2012 + * Author: Simon + */ + +#include "DropDown.h" + +namespace ui { + +class DropDownWindow: public ui::Window { + Colour background, activeBackground; + Colour border, activeBorder; + Colour text, activeText; + bool isMouseInside; +public: + DropDownWindow(Point position, Point size, Colour background, Colour activeBackground, Colour border, Colour activeBorder, Colour text, Colour activeText): + Window(position, size), + background(background), + activeBackground(activeBackground), + border(border), + activeBorder(activeBorder), + text(text), + activeText(activeText) + { + + } + virtual void OnDraw() + { + Graphics * g = ui::Engine::Ref().g; + g->fillrect(Position.X, Position.Y, Size.X, Size.Y, background.Red, background.Green, background.Blue, 255); + g->drawrect(Position.X, Position.Y, Size.X, Size.Y, border.Red, border.Green, border.Blue, 255); + } + virtual ~DropDownWindow() {} +}; + +DropDown::DropDown(Point position, Point size): + Component(position, size), + isMouseInside(false) +{ + activeText = background = Colour(0, 0, 0); + text = activeBackground = border = activeBorder = Colour(255, 255, 255); +} + +void DropDown::OnMouseClick(int x, int y, unsigned int button) +{ + ui::Engine().Ref().ShowWindow(new DropDownWindow(ui::Point(50, 50), ui::Point(50, 50), background, activeBackground, border, activeBorder, text, activeText)); +} + +void DropDown::Draw(const Point& screenPos) +{ + Graphics * g = ui::Engine::Ref().g; + Point Position = screenPos; + if(isMouseInside) + { + g->fillrect(Position.X-1, Position.Y-1, Size.X+2, Size.Y+2, activeBackground.Red, activeBackground.Green, activeBackground.Blue, 255); + g->drawrect(Position.X, Position.Y, Size.X, Size.Y, activeBorder.Red, activeBorder.Green, activeBorder.Blue, 255); + //g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y+1, displayText, activeText.Red, activeText.Green, activeText.Blue, 255); + } + else + { + g->fillrect(Position.X, Position.Y, Size.X, Size.Y, background.Red, background.Green, background.Blue, 255); + g->drawrect(Position.X, Position.Y, Size.X, Size.Y, border.Red, border.Green, border.Blue, 255); + //g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y+1, displayText, text.Red, text.Green, text.Blue, 255); + } + +} + + +DropDown::~DropDown() { + // TODO Auto-generated destructor stub +} + +} /* namespace ui */ diff --git a/src/interface/DropDown.h b/src/interface/DropDown.h new file mode 100644 index 000000000..619ec5a3b --- /dev/null +++ b/src/interface/DropDown.h @@ -0,0 +1,29 @@ +/* + * DropDown.h + * + * Created on: Apr 16, 2012 + * Author: Simon + */ + +#ifndef DROPDOWN_H_ +#define DROPDOWN_H_ + +#include "Component.h" +#include "Colour.h" + +namespace ui { + +class DropDown: public ui::Component { + Colour background, activeBackground; + Colour border, activeBorder; + Colour text, activeText; + bool isMouseInside; +public: + DropDown(Point position, Point size); + virtual void Draw(const Point& screenPos); + virtual void OnMouseClick(int x, int y, unsigned int button); + virtual ~DropDown(); +}; + +} /* namespace ui */ +#endif /* DROPDOWN_H_ */ diff --git a/src/options/OptionsView.cpp b/src/options/OptionsView.cpp index 9f07df945..d863844de 100644 --- a/src/options/OptionsView.cpp +++ b/src/options/OptionsView.cpp @@ -77,6 +77,9 @@ OptionsView::OptionsView(): tempLabel->SetAlignment(AlignLeft, AlignMiddle); AddComponent(tempLabel); + airMode = new ui::DropDown(ui::Point(Size.X-55, 143), ui::Point(50, 16));//, "Water equalisation \bgIntroduced in version 61"); + //airMode->SetActionCallback(new WaterEqualisationAction(this)); + AddComponent(airMode); tempLabel = new ui::Label(ui::Point(3, 143), ui::Point(Size.X-24, 16), "Air Simulation Mode"); tempLabel->SetAlignment(AlignLeft, AlignMiddle); AddComponent(tempLabel); diff --git a/src/options/OptionsView.h b/src/options/OptionsView.h index 52d84b140..5103f23e4 100644 --- a/src/options/OptionsView.h +++ b/src/options/OptionsView.h @@ -11,6 +11,7 @@ #include "interface/Window.h" #include "OptionsController.h" #include "interface/Checkbox.h" +#include "interface/DropDown.h" #include "OptionsModel.h" class OptionsModel; @@ -21,6 +22,8 @@ class OptionsView: public ui::Window { ui::Checkbox * ambientHeatSimulation; ui::Checkbox * newtonianGravity; ui::Checkbox * waterEqualisation; + ui::DropDown * airMode; + ui::DropDown * gravityMode; public: OptionsView(); void NotifySettingsChanged(OptionsModel * sender);