aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode/SampleApp.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-11-08 15:18:10 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-11-08 15:18:10 +0000
commit2072db89016c4e53a648f4d4cec08b1d6be8558c (patch)
treeac0e8f8552ebf6304905084d8acdea1bed618bc0 /samplecode/SampleApp.cpp
parentac7aa1bc3feb96c68e5c10f7cbed0e6be7704052 (diff)
post event to ourself to update the title after our constructor
(so we can see the title of the first slide) git-svn-id: http://skia.googlecode.com/svn/trunk@2625 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode/SampleApp.cpp')
-rw-r--r--samplecode/SampleApp.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 2578696a96..aeb71ad8e9 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -74,6 +74,10 @@ extern bool is_transition(SkView* view);
static SampleWindow* gSampleWindow;
+static void postEventToSink(SkEvent* evt, SkEventSink* sink) {
+ evt->setTargetID(sink->getSinkID())->post();
+}
+
///////////////
class SampleWindow::DefaultDeviceManager : public SampleWindow::DeviceManager {
public:
@@ -386,6 +390,7 @@ static const char gKeyEvtName[] = "SampleCode_Key_Event";
static const char gTitleEvtName[] = "SampleCode_Title_Event";
static const char gPrefSizeEvtName[] = "SampleCode_PrefSize_Event";
static const char gFastTextEvtName[] = "SampleCode_FastText_Event";
+static const char gUpdateWindowTitleEvtName[] = "SampleCode_UpdateWindowTitle";
bool SampleCode::CharQ(const SkEvent& evt, SkUnichar* outUni) {
if (evt.isType(gCharEvtName, sizeof(gCharEvtName) - 1)) {
@@ -666,6 +671,12 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev
if (this->height() && this->width()) {
this->onSizeChange();
}
+
+ // can't call this synchronously, since it may require a subclass to
+ // to implement, or the caller may need us to have returned from the
+ // constructor first. Hence we post an event to ourselves.
+// this->updateTitle();
+ postEventToSink(new SkEvent(gUpdateWindowTitleEvtName), this);
}
SampleWindow::~SampleWindow() {
@@ -1258,6 +1269,10 @@ void SampleWindow::postAnimatingEvent() {
}
}
bool SampleWindow::onEvent(const SkEvent& evt) {
+ if (evt.isType(gUpdateWindowTitleEvtName)) {
+ this->updateTitle();
+ return true;
+ }
if (evt.isType(ANIMATING_EVENTTYPE)) {
if (fAnimating) {
this->nextSample();