make PROP interface a little easier to use (first part of tpt issue 78)

This commit is contained in:
jacob1 2012-09-25 21:17:49 -04:00 committed by Simon Robertshaw
parent 2f26fac9d0
commit 6ec915df80
2 changed files with 12 additions and 0 deletions

View File

@ -62,6 +62,7 @@ TextPrompt::TextPrompt(std::string title, std::string message, std::string text,
} }
textField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; textField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
AddComponent(textField); AddComponent(textField);
FocusComponent(textField);
ui::Button * cancelButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point((Size.X/2)+1, 16), "Cancel"); ui::Button * cancelButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point((Size.X/2)+1, 16), "Cancel");
cancelButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; cancelButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;

View File

@ -8,6 +8,7 @@
#include "interface/Label.h" #include "interface/Label.h"
#include "interface/Textbox.h" #include "interface/Textbox.h"
#include "interface/DropDown.h" #include "interface/DropDown.h"
#include "interface/Keys.h"
#include "dialogues/ErrorMessage.h" #include "dialogues/ErrorMessage.h"
class PropertyWindow: public ui::Window class PropertyWindow: public ui::Window
@ -23,6 +24,7 @@ public:
PropertyWindow(PropertyTool * tool_, Simulation * sim_, ui::Point position_); PropertyWindow(PropertyTool * tool_, Simulation * sim_, ui::Point position_);
void SetProperty(); void SetProperty();
virtual void OnDraw(); virtual void OnDraw();
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnTryExit(ExitMethod method); virtual void OnTryExit(ExitMethod method);
virtual ~PropertyWindow() {} virtual ~PropertyWindow() {}
class OkayAction: public ui::ButtonAction class OkayAction: public ui::ButtonAction
@ -74,6 +76,7 @@ position(position_)
textField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; textField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
textField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; textField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(textField); AddComponent(textField);
FocusComponent(textField);
ui::Engine::Ref().ShowWindow(this); ui::Engine::Ref().ShowWindow(this);
} }
@ -207,6 +210,14 @@ void PropertyWindow::OnDraw()
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255);
} }
void PropertyWindow::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
{
if (key == KEY_UP)
property->SetOption(property->GetOption().second-1);
else if (key == KEY_DOWN)
property->SetOption(property->GetOption().second+1);
}
void PropertyTool::Click(Simulation * sim, Brush * brush, ui::Point position) void PropertyTool::Click(Simulation * sim, Brush * brush, ui::Point position)
{ {
new PropertyWindow(this, sim, position); new PropertyWindow(this, sim, position);