Skip to content

Commit

Permalink
Now we report back on events using Json.
Browse files Browse the repository at this point in the history
  • Loading branch information
rec committed Dec 28, 2014
1 parent d80051b commit 5138544
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
18 changes: 15 additions & 3 deletions code/cpp/echomesh/component/LightingWindow.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "echomesh/color/FColorList.h"
#include "echomesh/component/LightingWindow.h"
#include "echomesh/util/EchomeshApplication.h"
#include "echomesh/util/Quit.h"
#include "echomesh/util/RunOnMessageThread.h"

Expand Down Expand Up @@ -44,16 +45,27 @@ LightingWindow* makeLightingWindow() {
return window.release();
}

static string stringBounds(LightingWindow const& window) {
auto bounds = window.getScreenBounds();
return "{\"x\":" + std::to_string(bounds.getX()) +
",\"y\":" + std::to_string(bounds.getY()) +
",\"width\":" + std::to_string(bounds.getWidth()) +
",\"height\":" + std::to_string(bounds.getHeight()) +
"}";
}

void LightingWindow::closeButtonPressed() {
// LOG(INFO) << "closing!!";
callEchomesh("{\"event\":\"closeButtonPressed\"}");
}

void LightingWindow::moved() {
// LOG(INFO) << "Moved!";
callEchomesh("{\"event\":\"moved\",\"bounds\":" +
stringBounds(*this) + "}");
}

void LightingWindow::resized() {
// LOG(INFO) << "Resized!!";
callEchomesh("{\"event\":\"resized\",\"bounds\":" +
stringBounds(*this) + "}");
}

static void deleteWindow(LightingWindow* window) {
Expand Down
5 changes: 5 additions & 0 deletions code/cpp/echomesh/util/EchomeshApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ juce::JUCEApplicationBase* juce_CreateApplication() {

} // namespace

void callEchomesh(string const& s) {
if (CALLBACK and USER_DATA)
CALLBACK(USER_DATA, s.c_str());
}

void startApplication(StringCaller cb, void* userData) {
{
ScopedLock l(LOCK);
Expand Down
1 change: 1 addition & 0 deletions code/cpp/echomesh/util/EchomeshApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace echomesh {

void startApplication(StringCaller, void*);
void callEchomesh(string const&);
bool isStarted();

string timestamp();
Expand Down
2 changes: 2 additions & 0 deletions code/python/echomesh/Instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def main(self):
def callback(self, data):
if data == 'start':
self.after_server_starts()
else:
print(data)

def after_server_starts(self):
if cechomesh.LOADED:
Expand Down

0 comments on commit 5138544

Please sign in to comment.