summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Kobec <s.kobec@samsung.com>2017-02-21 14:28:31 +0200
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>2017-02-22 04:30:24 -0800
commit8b37873c307a219ecba45a083dbe7be281140ef5 (patch)
treefbdaea83d3bc4b5d2084187c6c8fb187cf54b17c
parentbeb93cd8bc336c657be8aa4d5628abf9580cbee8 (diff)
downloadalarm-8b37873c307a219ecba45a083dbe7be281140ef5.tar.gz
alarm-8b37873c307a219ecba45a083dbe7be281140ef5.tar.bz2
alarm-8b37873c307a219ecba45a083dbe7be281140ef5.zip
TizenRefApp-7989 Implement Selector component
Change-Id: I6e26aae16e5ac89991fa4c6696fa0c9dd0add682 Signed-off-by: Sergei Kobec <s.kobec@samsung.com>
-rw-r--r--lib-apps-common/inc/Ux/MultiSelector.h54
-rw-r--r--lib-apps-common/src/Ux/MultiSelector.cpp67
2 files changed, 121 insertions, 0 deletions
diff --git a/lib-apps-common/inc/Ux/MultiSelector.h b/lib-apps-common/inc/Ux/MultiSelector.h
new file mode 100644
index 0000000..efb9db2
--- /dev/null
+++ b/lib-apps-common/inc/Ux/MultiSelector.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UX_MULTI_SELECTOR_H
+#define UX_MULTI_SELECTOR_H
+
+#include "Ui/Control.h"
+
+namespace Ux
+{
+ class EXPORT_API MultiSelector : public Ui::Control
+ {
+ public:
+ struct Strings
+ {
+ const char *selectAll; /**< "Select all" item text. */
+ const char *deselectAll; /**< "Deselect all" item text. */
+ };
+
+ MultiSelector();
+
+ /**
+ * @brief Set count of selected items.
+ */
+ void setCount(size_t count);
+
+ /**
+ * @brief Set translatable strings for menu.
+ * @param[in] strings Translatable strings table.
+ */
+ void setStrings(const Strings &strings);
+
+ private:
+ virtual Evas_Object *onCreate(Evas_Object *parent) override;
+ void onButtonClicked(Evas_Object *button, void *eventInfo);
+
+ Strings m_Strings;
+ };
+}
+
+#endif /* UX_MULTI_SELECTOR_H */
diff --git a/lib-apps-common/src/Ux/MultiSelector.cpp b/lib-apps-common/src/Ux/MultiSelector.cpp
new file mode 100644
index 0000000..ed5a7c7
--- /dev/null
+++ b/lib-apps-common/src/Ux/MultiSelector.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "Ux/MultiSelector.h"
+#include "Ui/CircleMenu.h"
+#include "Utils/Callback.h"
+
+#define BUF_SIZE 8
+
+using namespace Ux;
+
+MultiSelector::MultiSelector()
+ : m_Strings { }
+{
+}
+
+void MultiSelector::setCount(size_t count)
+{
+ char buf[BUF_SIZE];
+ snprintf(buf, sizeof(buf), "%zu", count);
+ elm_object_text_set(getEvasObject(), buf);
+}
+
+void MultiSelector::setStrings(const Strings &strings)
+{
+ m_Strings = strings;
+}
+
+Evas_Object *MultiSelector::onCreate(Evas_Object *parent)
+{
+ auto button = elm_button_add(parent);
+ elm_object_style_set(button, "select_mode");
+ elm_object_text_set(button, "0");
+ evas_object_smart_callback_add(button, "clicked",
+ makeCallback(&MultiSelector::onButtonClicked), this);
+
+ elm_layout_content_set(parent, "elm.swallow.icon", button);
+
+ return button;
+}
+
+void MultiSelector::onButtonClicked(Evas_Object *button, void *eventInfo)
+{
+ auto menu = new Ui::CircleMenu();
+ menu->create(button);
+
+ menu->addItem(m_Strings.selectAll, [] {
+ //TODO React on select all event
+ });
+ menu->addItem(m_Strings.deselectAll, [] {
+ //TODO React on deselect all event
+ });
+ menu->show();
+}