Implementation: Edited callback on back event in Popup. Fixed warnings.
Change-Id: Ia04d176761fac7fc4e750ebb33117db0faca1ad1
Signed-off-by: Nataliia Sydorchuk <n.sydorchuk@samsung.com>
*/
typedef std::function<bool()> ButtonCallback;
+ /**
+ * @brief Back button pressed callback
+ * @return true to destroy the Popup, otherwise false
+ */
+ typedef std::function<bool()> BackCallback;
+
Popup();
/**
*/
Evas_Object *addButton(const char *text, ButtonCallback callback = nullptr);
+ /**
+ * @brief Set callback on back button
+ * @param[in] callback Back callback
+ */
+ void setBackCallback(BackCallback callback);
+
protected:
virtual Evas_Object *onCreate(Evas_Object *parent) override;
private:
void onButtonPressed(Evas_Object *obj, void *eventInfo);
+ void onBackPressed(Evas_Object *obj, void *eventInfo);
ButtonCallback m_ButtonCbs[POPUP_BUTTON_MAX_COUNT];
size_t m_ButtonCount;
+ BackCallback m_OnBack;
};
}
return button;
}
+void Popup::setBackCallback(BackCallback callback)
+{
+ m_OnBack = std::move(callback);
+}
+
Evas_Object *Popup::onCreate(Evas_Object *parent)
{
Window *window = getWindow(parent);
Evas_Object *popup = elm_popup_add(parent);
elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
- eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, nullptr);
+ eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK,
+ makeCallback(&Popup::onBackPressed), this);
evas_object_show(popup);
return popup;
delete this;
}
}
+
+void Popup::onBackPressed(Evas_Object *obj, void *eventInfo)
+{
+ if (!m_OnBack || m_OnBack()) {
+ delete this;
+ }
+}
snprintf(progress, sizeof(progress), "%d%%", (int)(100.0 * progressValue));
char total[BUFFER_SIZE] = { 0, };
- snprintf(total, sizeof(total), "%d/%d", value, m_MaxValue);
+ snprintf(total, sizeof(total), "%zu/%zu", value, m_MaxValue);
elm_progressbar_value_set(m_Progressbar, progressValue);
elm_object_part_text_set(m_Progressbar, "elm.text.bottom.left", progress);
elm_progressbar_pulse(m_Progressbar, EINA_TRUE);
char total[BUFFER_SIZE] = { 0, };
- snprintf(total, sizeof(total), "%d/%d", 0, m_MaxValue);
+ snprintf(total, sizeof(total), "%d/%zu", 0, m_MaxValue);
elm_object_part_text_set(m_Progressbar, "elm.text.bottom.left", ZERO_PROGRESS);
elm_object_part_text_set(m_Progressbar, "elm.text.bottom.right", total);