#include <dpl/log/log.h>
namespace {
+char const* const PLATFORM_EDJ_PATH = "/usr/share/edje/wrt/Platform.edj";
char const* const DAEMON_EDJ_PATH = "/usr/share/edje/wrt/Daemon.edj";
char const* const THEME_EDJ_PATH = "/usr/share/edje/wrt/wrt_theme.edj";
char const* const ELM_STATE_SHOW_CONTENT = "elm,state,show,content";
char const* const ELM_SWALLOW_CONTENT = "elm.swallow.content";
char const* const ELM_SWALLOW_BACKWARD = "elm.swallow.backward";
+char const* const ELM_SWALLOW_TOOLBAR = "elm.swallow.toolbar";
+char const* const ELM_RECT_HIDDENOPTION = "elm.rect.hiddenOption";
+
+const char *EDJE_SHOW_TOOLBAR_SIGNAL = "show,toolbar,signal";
+const char *EDJE_HIDE_TOOLBAR_SIGNAL = "hide,toolbar,signal";
+const char *EDJE_SHOW_HIDDENOPTION_SIGNAL = "show,hiddenOption,signal";
+const char *EDJE_HIDE_HIDDENOPTION_SIGNAL = "hide,hiddenOption,signal";
+
char const* const ELM = "elm";
char const* const LAYOUT = "layout";
char const* const APPLICATION = "application";
char const* const INDICATOR = "indicator";
char const* const NOINDICATOR = "noindicator";
-char const* const LIST_PROCESS = "list_process";
char const* const INTERNAL_LAYOUT = "internal_layout";
char const* const FLOATBACKWARD_BUTTON_STYLE = "wrt/backward";
-const double PROGRESS_POSITION_X = 0.5;
-const double PROGRESS_POSITION_Y = 0.5;
-const int PROGRESS_SIZE_RATIO = 12; //ResolutionWidth / ProgressWidth = 12
-const int PROGRESS_COLOR_R = 153;
-const int PROGRESS_COLOR_G = 153;
-const int PROGRESS_COLOR_B = 153;
-const int PROGRESS_COLOR_A = 255;
-
} // anonymous namespace
WindowData::WindowData(unsigned long pid, bool manualInit) :
- m_naviBackButton(NULL), m_win(NULL)
+ m_win(NULL), m_naviBackButton(NULL),
+ m_toolbarTimer(NULL),
+ m_debugMode(false)
{
m_win = createWindow(pid);
{
Assert(m_win != NULL && "m_win is null");
- int result;
// import button theme
elm_theme_overlay_add(NULL, THEME_EDJ_PATH);
evas_object_show(m_user_layout);
m_conformant = createConformant(m_user_layout);
evas_object_show(m_conformant);
- m_progress = createProgress(m_user_layout);
-
- result = ug_init(
- static_cast<Display*>(ecore_x_display_get()),
- elm_win_xwindow_get(m_win),
- m_win,
- UG_OPT_INDICATOR_ENABLE);
-
- if (result != 0) {
- LogError("Gadget creation failed for window: " << m_win);
- Assert(false && "UI Gadget creation failed");
- }
}
void WindowData::setEvasObjectForLayout(Evas_Object* evas_object)
elm_object_content_unset(m_conformant);
}
-void WindowData::loadingOn()
+void WindowData::toggleIndicator(bool fullscreen)
{
- LogInfo("loadingOn");
-
- alignProgressPosition();
- elm_progressbar_pulse(m_progress, EINA_TRUE);
- evas_object_show(m_progress);
-}
-
-void WindowData::loadingOff()
-{
- LogInfo("loadingOff");
-
- elm_progressbar_pulse(m_progress, EINA_FALSE);
- evas_object_hide(m_progress);
-}
+ LogDebug("fullscreen=" << (fullscreen?"true":"false"));
-void WindowData::moveProgress()
-{
- LogInfo("moveProgress");
-
- if (evas_object_visible_get(m_progress) == EINA_TRUE) {
- alignProgressPosition();
- } else {
- LogInfo("Progress is hide");
- }
-}
-
-void WindowData::setViewModeFullScreen(bool indicator, bool backbutton)
-{
- LogDebug("indicator: " << indicator << ", backbutton: " << backbutton);
- if (indicator) {
+ if (!fullscreen) {
elm_win_indicator_mode_set(m_win, ELM_WIN_INDICATOR_SHOW);
elm_layout_theme_set(m_platform_layout,
- LAYOUT,
- APPLICATION,
- INDICATOR);
+ LAYOUT,
+ APPLICATION,
+ INDICATOR);
} else {
elm_win_indicator_mode_set(m_win, ELM_WIN_INDICATOR_HIDE);
elm_layout_theme_set(m_platform_layout,
- LAYOUT,
- APPLICATION,
- NOINDICATOR);
- }
- if (backbutton) {
- createFloatBackButton();
+ LAYOUT,
+ APPLICATION,
+ NOINDICATOR);
}
}
-void WindowData::setViewModeMaximized(
- const char *title,
- bool indicator,
- bool backbutton)
+void WindowData::setViewMode(
+ bool fullscreen,
+ bool backbutton,
+ CtxMenuItems ctxMenuItems)
{
- LogDebug("indicator: " << indicator << ", backbutton: " << backbutton);
- if (indicator) {
- elm_win_indicator_mode_set(m_win, ELM_WIN_INDICATOR_SHOW);
- elm_layout_theme_set(m_platform_layout,
- LAYOUT,
- APPLICATION,
- INDICATOR);
- } else {
- elm_win_indicator_mode_set(m_win, ELM_WIN_INDICATOR_HIDE);
- elm_layout_theme_set(m_platform_layout,
- LAYOUT,
- APPLICATION,
- NOINDICATOR);
- }
- createTitle(title);
+ LogDebug("setViewMode " <<m_debugMode);
+ LogDebug("fullscreen: " << fullscreen);
+ LogDebug("backbutton: " << backbutton);
+
+ m_fullscreen = fullscreen;
+
+ toggleIndicator(m_fullscreen);
+
if (backbutton) {
createFloatBackButton();
}
+
+ m_ctxMenuItems = ctxMenuItems;
+
+ if(m_debugMode) {
+ showHiddenOption(m_user_layout);
+ createToolbar(m_ctxMenuItems);
+ }
}
-void WindowData::createTitle(const char* data)
+void WindowData::createToolbar(CtxMenuItems ctxMenuItems)
{
- LogDebug("createTitle");
- Elm_Object_Item* naviIt = elm_naviframe_top_item_get(m_navigation);
- elm_naviframe_item_title_visible_set(naviIt, EINA_TRUE);
- elm_object_item_text_set(naviIt, data);
+ Elm_Object_Item *toolbarIt;
+ Evas_Object *toolbarButton;
+ Evas_Object *toolbar;
+ char buf[100];
+
+ toolbar = elm_toolbar_add(m_user_layout);
+ if (!toolbar)
+ return;
+
+ elm_object_style_set(toolbar, "naviframe");
+ elm_object_part_content_set(m_user_layout,
+ ELM_SWALLOW_TOOLBAR,
+ toolbar);
+
+ std::list<CtxMenuItem>::iterator itor;
+ for (itor = ctxMenuItems.begin(); itor != ctxMenuItems.end(); ++itor) {
+ toolbarButton = elm_button_add(toolbar);
+ if (!toolbarButton)
+ return;
+
+ evas_object_size_hint_align_set(toolbarButton,
+ EVAS_HINT_FILL,
+ EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(toolbarButton,
+ EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+
+ Evas_Object *ic = elm_icon_add(toolbar);
+ snprintf(buf, sizeof(buf), (*itor).icon.c_str());
+ elm_icon_file_set(ic, buf, NULL);
+ evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+ elm_icon_resizable_set(ic, EINA_TRUE, EINA_TRUE);
+ elm_object_part_content_set(toolbarButton, "icon", ic);
+
+ evas_object_smart_callback_add(toolbarButton,
+ "clicked",
+ (*itor).callback,
+ (*itor).data);
+ toolbarIt = elm_toolbar_item_append(toolbar, NULL, NULL, NULL, NULL);
+ elm_object_item_part_content_set(toolbarIt, "object", toolbarButton);
+
+ //for margin button between buttons
+ toolbarButton = elm_button_add(toolbar);
+ if (!toolbarButton)
+ return;
+ evas_object_color_set(
+ toolbarButton,
+ 255,
+ 255,
+ 255,
+ 0);
+ toolbarIt = elm_toolbar_item_append(toolbar, NULL, NULL, NULL, NULL);
+ elm_object_item_part_content_set(toolbarIt, "object", toolbarButton);
+ }
+
+ toolbarButton = elm_button_add(toolbar);
+ if (!toolbarButton)
+ return;
+
+ Evas_Object *ic = elm_icon_add(toolbar);
+ snprintf(buf, sizeof(buf), WRT_OPTION_ICON_WINDOWVIEW);
+ elm_icon_file_set(ic, buf, NULL);
+ evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+ elm_icon_resizable_set(ic, EINA_TRUE, EINA_TRUE);
+ elm_object_part_content_set(toolbarButton, "icon", ic);
+
+ evas_object_size_hint_align_set(toolbarButton,
+ EVAS_HINT_FILL,
+ EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(toolbarButton,
+ EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_smart_callback_add(toolbarButton,
+ "clicked",
+ changeViewModeCallback,
+ this);
+ toolbarIt = elm_toolbar_item_append(toolbar, NULL, NULL, NULL, NULL);
+ elm_object_item_part_content_set(toolbarIt, "object", toolbarButton);
+
+ optionheaderClose = TRUE;
+
+ elm_object_part_content_set(m_user_layout,
+ ELM_SWALLOW_TOOLBAR,
+ toolbar);
}
-void WindowData::removeTitle()
+void WindowData::showToolbar()
{
- Elm_Object_Item* naviIt = elm_naviframe_top_item_get(m_navigation);
- elm_object_item_text_set(naviIt, "");
- elm_naviframe_item_title_visible_set(naviIt, EINA_FALSE);
+ emitSignalForUserLayout(EDJE_SHOW_TOOLBAR_SIGNAL, "");
+ m_toolbarTimer = ecore_timer_add(10.0, hideToolbarCallback, this);
}
-void WindowData::createTitleButton()
+void WindowData::hideToolbar()
{
- // Add left button for back action
- m_naviBackButton = elm_button_add(m_navigation);
- elm_object_style_set(m_naviBackButton, "navigationbar_backbutton/default");
-
- Elm_Object_Item* naviIt = elm_naviframe_top_item_get(m_navigation);
- elm_object_item_part_content_set(naviIt, "prev_btn",
- m_naviBackButton);
+ emitSignalForUserLayout(EDJE_HIDE_TOOLBAR_SIGNAL, "");
+ if(m_toolbarTimer) {
+ ecore_timer_del(m_toolbarTimer);
+ m_toolbarTimer = NULL;
+ }
}
void WindowData::createFloatBackButton()
evas_object_show(m_floatBackButton);
}
-void WindowData::updateTitleButton(const bool display)
-{
- if (display) {
- evas_object_show(m_naviBackButton);
- } else {
- evas_object_hide(m_naviBackButton);
- }
-}
-
Evas_Object* WindowData::createWindow(unsigned long pid)
{
Evas_Object* window = elm_win_add(NULL, "wrt-widget", ELM_WIN_BASIC);
Evas_Object* WindowData::createPlatformLayout(Evas_Object* parent)
{
Evas_Object* platform_layout = elm_layout_add(parent);
- elm_layout_theme_set(platform_layout, LAYOUT, APPLICATION, NOINDICATOR);
+
+ if (!elm_layout_file_set(platform_layout, PLATFORM_EDJ_PATH, "platformlayout"))
+ elm_layout_theme_set(platform_layout, LAYOUT, APPLICATION, NOINDICATOR);
+
evas_object_size_hint_expand_set(platform_layout,
EVAS_HINT_EXPAND,
EVAS_HINT_EXPAND);
- elm_win_resize_object_add(m_win, platform_layout);
+
+ elm_win_resize_object_add(parent, platform_layout);
+
edje_object_signal_emit(
elm_layout_edje_get(platform_layout), ELM_STATE_SHOW_CONTENT, ELM);
return platform_layout;
elm_layout_file_set(layout, DAEMON_EDJ_PATH, "client");
evas_object_size_hint_weight_set(
layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_win_resize_object_add(parent, layout);
+
Elm_Object_Item* naviIt = elm_naviframe_item_push(
/* Evas_Object *obj */
parent,
NULL);
elm_naviframe_item_title_visible_set(naviIt, EINA_FALSE);
+
return layout;
}
return navigation;
}
-Evas_Object* WindowData::createProgress(Evas_Object* parent)
+void WindowData::showHiddenOption(Evas_Object* parent)
{
- Assert(parent != NULL && "Parent for progress is null");
- Evas_Object* progress = elm_progressbar_add(parent);
- progress = elm_progressbar_add(parent);
- elm_object_style_set(progress, LIST_PROCESS);
- evas_object_color_set(
- progress,
- PROGRESS_COLOR_R,
- PROGRESS_COLOR_G,
- PROGRESS_COLOR_B,
- PROGRESS_COLOR_A);
- Evas_Coord x, y, w, h;
- int progressW, progressH;
- evas_object_geometry_get(m_win, &x, &y, &w, &h);
- progressW = w / static_cast<Evas_Coord>(PROGRESS_SIZE_RATIO);
- progressH = progressW;
-
- evas_object_resize(progress, progressW, progressH);
- return progress;
+ Assert(parent != NULL && "Parent for Hiden Option");
+
+ emitSignalForUserLayout(EDJE_SHOW_HIDDENOPTION_SIGNAL, "");
+
+ edje_object_signal_callback_add(elm_layout_edje_get(parent),
+ "mouse,clicked,1",
+ "elm.rect.hiddenOption",
+ controlHiddenOptionCallback,
+ this);
}
-void WindowData::alignProgressPosition()
+void WindowData::hideHiddenOption(Evas_Object* parent)
{
- Evas_Coord layOutX, layOutY, layOutW, layOutH;
- Evas_Coord progressX, progressY, progressW, progressH;
- Evas_Coord alignedX, alignedY;
-
- evas_object_geometry_get(
- m_user_layout,
- &layOutX,
- &layOutY,
- &layOutW,
- &layOutH);
- evas_object_geometry_get(
- m_progress,
- &progressX,
- &progressY,
- &progressW,
- &progressH);
- alignedX = (layOutW - progressW) * PROGRESS_POSITION_X + layOutX;
- alignedY = (layOutH - progressH) * PROGRESS_POSITION_Y + layOutY;
- evas_object_move(m_progress, alignedX, alignedY);
+ Assert(parent != NULL && "Parent for Hiden Option");
+
+ emitSignalForUserLayout(EDJE_HIDE_HIDDENOPTION_SIGNAL, "");
+
+ edje_object_signal_callback_del(elm_layout_edje_get(parent),
+ "mouse,clicked,1",
+ "elm.rect.hiddenOption",
+ controlHiddenOptionCallback);
+}
+
+void WindowData::initFullViewMode ()
+{
+ hideToolbar();
+ showHiddenOption(m_user_layout);
}
void WindowData::addNaviBackButtonCallback(
edje_object_signal_emit(
elm_layout_edje_get(m_user_layout), emission, source);
}
+
+void WindowData::moreButtonCallback(void *data,
+ Evas_Object */*obj*/,
+ void */*event_info*/)
+{
+ WindowData* This = static_cast<WindowData*>(data);
+ Elm_Object_Item *naviIt = elm_naviframe_top_item_get(This->m_navigation);
+
+ if (This->optionheaderClose)
+ elm_object_item_signal_emit(naviIt, "elm,state,optionheader,open", "");
+ else
+ elm_object_item_signal_emit(naviIt, "elm,state,optionheader,close", "");
+
+ This->optionheaderClose = !This->optionheaderClose;
+}
+
+
+void WindowData::changeViewModeCallback(void *data,
+ Evas_Object */*obj*/,
+ void */*event_info*/)
+{
+ WindowData* This = static_cast<WindowData*>(data);
+ Elm_Object_Item *naviIt = elm_naviframe_top_item_get(This->m_navigation);
+
+ if(elm_naviframe_item_title_visible_get(naviIt)) {
+ This->showHiddenOption(This->m_user_layout);
+
+ } else {
+ This ->hideToolbar();
+ }
+}
+
+void WindowData::controlHiddenOptionCallback(void *data,
+ Evas_Object */*obj*/,
+ const char */*emission*/,
+ const char */*source*/)
+{
+ LogDebug("controlHiddenOptionCallback");
+ WindowData* This = static_cast<WindowData *>(data);
+ Elm_Object_Item *naviIt = elm_naviframe_top_item_get(This->m_navigation);
+
+ if(!elm_naviframe_item_title_visible_get(naviIt)) {
+ const char* state = edje_object_part_state_get(
+ elm_layout_edje_get(This->m_user_layout),
+ "elm.swallow.toolbar",
+ NULL);
+
+ if (state && !strncmp(state, "default", strlen("default"))) {
+ This->showToolbar();
+ This->hideHiddenOption(This->m_user_layout);
+ }
+ else {
+ This->initFullViewMode();
+ }
+
+ }
+}
+
+Eina_Bool WindowData::hideToolbarCallback(void *data)
+{
+ WindowData *This = static_cast<WindowData *>(data);
+
+ This->initFullViewMode();
+ return TRUE;
+}
+
+void WindowData::toggleFullscreen(bool fullscreen)
+{
+ LogDebug(__PRETTY_FUNCTION__);
+
+ static bool alreadyFullscreen = false;
+
+ if (alreadyFullscreen == fullscreen) {
+ // window is in fullscreen mode and fullscreen mode is requested, or
+ // window is not in fullscreen and a request is made to exit fullscreen
+ // In these two situations we don't have to do anything here.
+ return;
+ }
+
+ if (!m_fullscreen) {
+ //If ViewMode is not fullscreen, toggle the title bar and indicator
+ toggleIndicator(fullscreen);
+ }
+ alreadyFullscreen = !alreadyFullscreen;
+}