// // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved // LICENSE: Atomic Game Engine Editor and Tools EULA // Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for // license information: https://github.com/AtomicGameEngine/AtomicGameEngine // #include #include #include #include #include #include #include #include #include #include #include #include "JSResourceEditor.h" using namespace tb; namespace AtomicEditor { JSResourceEditor ::JSResourceEditor(Context* context, const String &fullpath, UITabContainer *container) : ResourceEditor(context, fullpath, container) { TBLayout* layout = new TBLayout(); layout->SetLayoutSize(LAYOUT_SIZE_GRAVITY); layout->SetGravity(WIDGET_GRAVITY_ALL); layout->SetLayoutDistribution(LAYOUT_DISTRIBUTION_GRAVITY); rootContentWidget_->GetInternalWidget()->AddChild(layout); TBContainer* c = new TBContainer(); c->SetGravity(WIDGET_GRAVITY_ALL); layout->AddChild(c); String url = "file://"; webView_ = new UIWebView(context_, "file:///Users/josh/Dev/atomic/AtomicGameEngine/Data/AtomicEditor/CodeEditor/Editor.html"); webClient_ = webView_->GetWebClient(); SubscribeToEvent(webClient_, E_WEBVIEWLOADEND, HANDLER(JSResourceEditor, HandleWebViewLoadEnd)); c->AddChild(webView_->GetInternalWidget()); // FIXME: Set the size at the end of setup, so all children are updated accordingly // future size changes will be handled automatically IntRect rect = container_->GetContentRoot()->GetRect(); rootContentWidget_->SetSize(rect.Width(), rect.Height()); } JSResourceEditor::~JSResourceEditor() { } void JSResourceEditor::HandleWebViewLoadEnd(StringHash eventType, VariantMap& eventData) { webClient_->ExecuteJavaScript("sayHi();"); } void JSResourceEditor::FormatCode() { } bool JSResourceEditor::OnEvent(const TBWidgetEvent &ev) { if (ev.type == EVENT_TYPE_SHORTCUT) { if (ev.ref_id == TBIDC("close")) { RequestClose(); } } return false; } void JSResourceEditor::FindTextClose() { } bool JSResourceEditor::FindText(const String& findText, unsigned flags) { return true; } void JSResourceEditor::SetFocus() { //editField_->SetFocus(WIDGET_FOCUS_REASON_UNKNOWN); } void JSResourceEditor::GotoTokenPos(int tokenPos) { } void JSResourceEditor::GotoLineNumber(int lineNumber) { } bool JSResourceEditor::Save() { if (!modified_) return true; SetModified(false); return true; } }