summaryrefslogtreecommitdiff
path: root/lib-apps-common/inc/Ux/MultiSelector.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib-apps-common/inc/Ux/MultiSelector.h')
-rw-r--r--lib-apps-common/inc/Ux/MultiSelector.h64
1 files changed, 54 insertions, 10 deletions
diff --git a/lib-apps-common/inc/Ux/MultiSelector.h b/lib-apps-common/inc/Ux/MultiSelector.h
index 7810b4c..feb2e66 100644
--- a/lib-apps-common/inc/Ux/MultiSelector.h
+++ b/lib-apps-common/inc/Ux/MultiSelector.h
@@ -21,10 +21,22 @@
namespace Ux
{
- class SelectView;
class EXPORT_API MultiSelector : public Ui::Control
{
public:
+ /**
+ * @brief MultiSelector state
+ */
+ enum State
+ {
+ SelectedAll,
+ SelectedNone,
+ SelectedPartially
+ };
+
+ /**
+ * @brief Translatable strings for selector menu items.
+ */
struct Strings
{
const char *selectAll; /**< "Select all" item text. */
@@ -32,15 +44,25 @@ namespace Ux
};
/**
- * @brief Create selector.
- * @param[in] selectView Select view.
+ * @brief Change callback.
+ * @param[in] Selector state.
+ * @return Whether contol's state should be changed.
+ */
+ typedef std::function<bool(State)> ChangeCallback;
+
+ MultiSelector();
+
+ /**
+ * @brief Set change callback.
+ * @param[in] callback Change callback.
*/
- explicit MultiSelector(SelectView *selectView);
+ void setChangeCallback(ChangeCallback callback);
/**
- * @brief Set count of selected items.
+ * @brief Set state.
+ * @param[in] state MultiSelector state.
*/
- void setCount(size_t count);
+ void setState(State state);
/**
* @brief Set translatable strings for menu.
@@ -48,12 +70,34 @@ namespace Ux
*/
void setStrings(const Strings &strings);
- private:
- virtual Evas_Object *onCreate(Evas_Object *parent) override;
- void onButtonClicked(Evas_Object *button, void *eventInfo);
+ protected:
+ /**
+ * @brief Called when inner state was changed by public @setState method.
+ * @param[in] state Selector state.
+ */
+ virtual void onStateChanged(State state) { }
+
+ /**
+ * @return Selector state.
+ */
+ State getState() const;
+
+ /**
+ * @return Translatable strings.
+ */
+ const Strings &getStrings() const;
+
+ /**
+ * @brief Called when MultiSelector state was changed.
+ * @remark MUST be called only when change was performed by user interaction.
+ * @param[in] state Selector state.
+ */
+ bool notifyChanged(State state);
+ private:
+ ChangeCallback m_OnChanged;
+ State m_State;
Strings m_Strings;
- SelectView *m_SelectView;
};
}