UI: Persist selected tab on resize.

This commit is contained in:
Unknown W. Brackets committed 2016-01-22 22:40:36 -08:00
1 parent f6772ec526
commit 1c2ac798cd
2 files changed
+24

No files matched your search

+22
View File
@@ -1053,6 +1053,28 @@ EventReturn TabHolder::OnTabClick(EventParams &e) {
return EVENT_DONE;
}
void TabHolder::PersistData(PersistStatus status, PersistMap &storage) {
const std::string &tag = Tag();
if (tag.empty()) {
return;
}
PersistBuffer &buffer = storage["TabHolder::" + tag];
switch (status) {
case PERSIST_SAVE:
buffer.resize(1);
buffer[0] = currentTab_;
break;
case PERSIST_RESTORE:
if (buffer.size() == 1) {
SetCurrentTab(buffer[0]);
}
break;
}
}
ChoiceStrip::ChoiceStrip(Orientation orientation, LayoutParams *layoutParams)
: LinearLayout(orientation, layoutParams), selected_(0), topTabs_(false) {
SetSpacing(0.0f);
+2
View File
@@ -323,6 +323,8 @@ public:
int GetCurrentTab() const { return currentTab_; }
std::string Describe() const override { return "TabHolder: " + View::Describe(); }
void PersistData(PersistStatus status, PersistMap &storage) override;
private:
EventReturn OnTabClick(EventParams &e);