This commit is contained in:
Henrik Rydgard committed 2013-08-14 23:29:27 +02:00
1 parent 1be5ce83d7
commit 357966447d
4 files changed
+37 -4

No files matched your search

+14 -4
View File
@@ -116,13 +116,13 @@ void PopupScreen::CreateViews() {
root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));
LinearLayout *box = new LinearLayout(ORIENT_VERTICAL,
new AnchorLayoutParams(450, FillVertical() ? dp_yres - 30 : WRAP_CONTENT, dp_xres / 2, dp_yres / 2, NONE, NONE, true));
new AnchorLayoutParams(550, FillVertical() ? dp_yres - 30 : WRAP_CONTENT, dp_xres / 2, dp_yres / 2, NONE, NONE, true));
root_->Add(box);
box->SetBG(UI::Drawable(0xFF303030));
box->SetHasDropShadow(true);
View *title = new ItemHeader(title_);
View *title = new PopupHeader(title_);
box->Add(title);
CreatePopupContents(box);
@@ -170,10 +170,20 @@ void ListPopupScreen::OnCompleted() {
void SliderPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
using namespace UI;
slider_ = parent->Add(new Slider(value_, minValue_, maxValue_, new LinearLayoutParams(UI::Margins(10, 5))));
sliderValue_ = *value_;
slider_ = parent->Add(new Slider(&sliderValue_, minValue_, maxValue_, new LinearLayoutParams(UI::Margins(10, 5))));
}
void SliderFloatPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
using namespace UI;
slider_ = parent->Add(new SliderFloat(value_, minValue_, maxValue_));
sliderValue_ = *value_;
slider_ = parent->Add(new SliderFloat(&sliderValue_, minValue_, maxValue_));
}
void SliderPopupScreen::OnCompleted() {
*value_ = sliderValue_;
}
void SliderFloatPopupScreen::OnCompleted() {
*value_ = sliderValue_;
}
+4
View File
@@ -86,8 +86,10 @@ public:
void CreatePopupContents(UI::ViewGroup *parent);
private:
virtual void OnCompleted();
UI::Slider *slider_;
int *value_;
int sliderValue_;
int minValue_;
int maxValue_;
};
@@ -98,7 +100,9 @@ public:
void CreatePopupContents(UI::ViewGroup *parent);
private:
virtual void OnCompleted();
UI::SliderFloat *slider_;
float sliderValue_;
float *value_;
float minValue_;
float maxValue_;
+5
View File
@@ -320,6 +320,11 @@ void ItemHeader::Draw(UIContext &dc) {
dc.Draw()->DrawImageStretch(dc.theme->whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), 0xFFFFFFFF);
}
void PopupHeader::Draw(UIContext &dc) {
dc.Draw()->DrawText(dc.theme->uiFontSmaller, text_.c_str(), bounds_.x + 12, bounds_.centerY(), dc.theme->popupTitle.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
dc.Draw()->DrawImageStretch(dc.theme->whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), 0xFFFFFFFF);
}
void CheckBox::Draw(UIContext &dc) {
ClickableItem::Draw(dc);
int paddingX = 8;
+14
View File
@@ -91,6 +91,8 @@ struct Theme {
Style itemStyle;
Style itemDownStyle;
Style itemFocusedStyle;
Style popupTitle;
};
// The four cardinal directions should be enough, plus Prev/Next in "element order".
@@ -530,6 +532,18 @@ private:
std::string text_;
};
class PopupHeader : public Item {
public:
PopupHeader(const std::string &text, LayoutParams *layoutParams = 0)
: Item(layoutParams), text_(text) {
layoutParams_->width = FILL_PARENT;
layoutParams_->height = 64;
}
virtual void Draw(UIContext &dc);
private:
std::string text_;
};
class CheckBox : public ClickableItem {
public:
CheckBox(bool *toggle, const std::string &text, const std::string &smallText = "", LayoutParams *layoutParams = 0)