#include <assert.h>
#include <ewk_context.h>
+#include <ewk_tracing.h>
#include "logger.h"
: toolbox_window_(NULL)
, window_list_(NULL)
, desktop_(desktop)
- , inspector_started_(false) {
+ , inspector_started_(false)
+ , tracing_enabled_(false) {
log_info("UI type: %s", desktop_ ? "desktop" : "mobile");
if (desktop_)
elm_win_activate(toolbox_window_);
}
+void Browser::StartTracing() {
+ log_trace("%s", __PRETTY_FUNCTION__);
+ ewk_start_tracing("*, disabled-by-default-toplevel.flow", "", "");
+ tracing_enabled_ = true;
+}
+
+void Browser::StopTracing() {
+ log_trace("%s", __PRETTY_FUNCTION__);
+ ewk_stop_tracing();
+ tracing_enabled_ = false;
+}
+
void Browser::OnWindowDestroyed(Window::IdType id) {
log_trace("%s: %x", __PRETTY_FUNCTION__, id);
assert(window_map_.find(id) != window_map_.end());
static double kMinViewScale = 1;
static double kMaxViewScale = 4;
static double kViewScaleDelta = 0.1;
+static int kNotificationTimeoutSec = 3;
}
WindowUI::WindowUI(Window& window, Browser& browser)
elm_object_disabled_set(forward_button_, !enable);
}
+void WindowUI::ShowNotification(const char* text) {
+ log_trace("%s : %s", __PRETTY_FUNCTION__, text);
+ Evas_Object* notification = elm_notify_add(window_.GetEvasObject());
+ elm_notify_timeout_set(notification, kNotificationTimeoutSec);
+ Evas_Object* content = elm_label_add(notification);
+ elm_object_text_set(content, text);
+ elm_object_content_set(notification, content);
+ elm_notify_align_set(notification, 0.5, 0.5);
+ evas_object_show(notification);
+}
+
Evas_Object* WindowUI::AddButton(Evas_Object* parent,
const char* icon, const char* label, Evas_Smart_Cb cb) {
Evas_Object *bt = elm_button_add(parent);
&WindowUI::OnSelectTouchInput, this);
}
+ if (!browser_.IsTracingEnabled()) {
+ elm_ctxpopup_item_append(menu, "Start tracing", NULL,
+ &WindowUI::OnStartTracing, this);
+ } else {
+ elm_ctxpopup_item_append(menu, "Stop tracing", NULL,
+ &WindowUI::OnStopTracing, this);
+ }
+
elm_ctxpopup_item_append(menu, "Zoom in", NULL, &WindowUI::OnZoomIn, this);
elm_ctxpopup_item_append(menu, "Zoom out", NULL, &WindowUI::OnZoomOut, this);
WindowUI *thiz = static_cast<WindowUI*>(data);
thiz->window_.EnableTouchEvents(false);
thiz->window_.EnableMouseEvents(true);
+ thiz->ShowNotification("Mouse events enabled");
elm_ctxpopup_dismiss(obj);
}
WindowUI *thiz = static_cast<WindowUI*>(data);
thiz->window_.EnableTouchEvents(true);
thiz->window_.EnableMouseEvents(false);
+ thiz->ShowNotification("Touch events enabled");
elm_ctxpopup_dismiss(obj);
}
_change_zoom(thiz->window_, -kViewScaleDelta);
elm_ctxpopup_dismiss(obj);
}
+
+void WindowUI::OnStartTracing(void* data, Evas_Object* obj, void*) {
+ log_trace("%s", __PRETTY_FUNCTION__);
+ WindowUI *thiz = static_cast<WindowUI*>(data);
+ thiz->browser_.StartTracing();
+ elm_ctxpopup_dismiss(obj);
+ thiz->ShowNotification("Tracing started");
+}
+
+void WindowUI::OnStopTracing(void* data, Evas_Object* obj, void*) {
+ log_trace("%s", __PRETTY_FUNCTION__);
+ WindowUI *thiz = static_cast<WindowUI*>(data);
+ thiz->browser_.StopTracing();
+ elm_ctxpopup_dismiss(obj);
+ thiz->ShowNotification("Tracing finished");
+}
void EnableBackButton(bool);
void EnableForwardButton(bool);
+ void ShowNotification(const char* text);
+
private:
Evas_Object* AddButton(Evas_Object*, const char*,
const char*, Evas_Smart_Cb);
static void OnSelectTouchInput(void* data, Evas_Object*, void*);
static void OnZoomIn(void* data, Evas_Object*, void*);
static void OnZoomOut(void* data, Evas_Object*, void*);
+ static void OnStartTracing(void* data, Evas_Object*, void*);
+ static void OnStopTracing(void* data, Evas_Object*, void*);
Window& window_;
Browser& browser_;