Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Unified Diff: tools/viewer/Viewer.cpp

Issue 2035923002: Add Softkey UIState to Viewer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/viewer/sk_app/CommandSet.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/viewer/Viewer.cpp
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index c73b1ba9ce51fb4f4258f6951e2698fd512268cc..7e345c5bbc8032420f3200e563fa7208c123878d 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -65,6 +65,9 @@ const char* kValue = "value";
const char* kOptions = "options";
const char* kSlideStateName = "Slide";
const char* kBackendStateName = "Backend";
+const char* kSoftkeyStateName = "Softkey";
+const char* kSoftkeyHint = "Please select a softkey";
+
Viewer::Viewer(int argc, char** argv, void* platformData)
: fCurrentMeasurement(0)
@@ -411,6 +414,7 @@ void Viewer::onIdle(double ms) {
}
void Viewer::updateUIState() {
+ // Slide state
Json::Value slideState(Json::objectValue);
slideState[kName] = kSlideStateName;
slideState[kValue] = fSlides[fCurrentSlide]->getName().c_str();
@@ -420,19 +424,29 @@ void Viewer::updateUIState() {
}
slideState[kOptions] = allSlideNames;
- // This state is currently a demo for the one without options.
- // We will be able to change the backend too.
+ // Backend state
Json::Value backendState(Json::objectValue);
backendState[kName] = kBackendStateName;
backendState[kValue] = kBackendTypeStrings[fBackendType];
backendState[kOptions] = Json::Value(Json::arrayValue);
- for(auto str : kBackendTypeStrings) {
+ for (auto str : kBackendTypeStrings) {
backendState[kOptions].append(Json::Value(str));
}
+ // Softkey state
+ Json::Value softkeyState(Json::objectValue);
+ softkeyState[kName] = kSoftkeyStateName;
+ softkeyState[kValue] = kSoftkeyHint;
+ softkeyState[kOptions] = Json::Value(Json::arrayValue);
+ softkeyState[kOptions].append(kSoftkeyHint);
+ for (const auto& softkey : fCommands.getCommandsAsSoftkeys()) {
+ softkeyState[kOptions].append(Json::Value(softkey.c_str()));
+ }
+
Json::Value state(Json::arrayValue);
state.append(slideState);
state.append(backendState);
+ state.append(softkeyState);
fWindow->setUIState(state);
}
@@ -470,6 +484,11 @@ void Viewer::onUIStateChanged(const SkString& stateName, const SkString& stateVa
break;
}
}
+ } else if (stateName.equals(kSoftkeyStateName)) {
+ if (!stateValue.equals(kSoftkeyHint)) {
+ fCommands.onSoftkey(stateValue);
+ updateUIState(); // This is still needed to reset the value to kSoftkeyHint
+ }
} else {
SkDebugf("Unknown stateName: %s", stateName.c_str());
}
« no previous file with comments | « no previous file | tools/viewer/sk_app/CommandSet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698