ScreenReaderSettings page in MVP 40/205240/8
authorLukasz Oleksak <l.oleksak@samsung.com>
Tue, 7 May 2019 09:16:28 +0000 (11:16 +0200)
committerLukasz Oleksak <l.oleksak@samsung.com>
Mon, 13 May 2019 08:42:41 +0000 (10:42 +0200)
Change-Id: I29a68d95aa427fdf6888dde87c231145edc94c94

24 files changed:
CMakeLists.txt
resource/genlist.edc [new file with mode: 0644]
src/UniversalSwitchSettingsPage.cpp
src/model/ScreenReaderSettingsModel.cpp [new file with mode: 0644]
src/model/ScreenReaderSettingsModel.hpp [new file with mode: 0644]
src/model/StatusBarInformationModel.cpp [new file with mode: 0644]
src/model/StatusBarInformationModel.hpp [new file with mode: 0644]
src/model/TextToSpeechModel.cpp [new file with mode: 0644]
src/model/TextToSpeechModel.hpp [new file with mode: 0644]
src/presenter/ListItem.cpp
src/presenter/ListItem.hpp
src/presenter/MainPagePresenter.cpp
src/presenter/ScreenReaderPresenter.cpp
src/presenter/ScreenReaderSettingsPresenter.cpp [new file with mode: 0644]
src/presenter/ScreenReaderSettingsPresenter.hpp [new file with mode: 0644]
src/presenter/StatusBarInformationPresenter.cpp [new file with mode: 0644]
src/presenter/StatusBarInformationPresenter.hpp [new file with mode: 0644]
src/presenter/TextToSpeechPresenter.cpp [new file with mode: 0644]
src/presenter/TextToSpeechPresenter.hpp [new file with mode: 0644]
src/service/TextToSpeech.cpp
src/ui/GenlistItem.cpp
src/ui/GenlistItem.hpp
src/utils/utils.hpp
src/view/ListView.cpp

index c0fc4e25e053a493c1fd8af6e310b56e54f29440..a048d0adef08af6c1019e5dfd20c6df66eba666b 100644 (file)
@@ -88,6 +88,14 @@ ADD_CUSTOM_TARGET(accessibility-smart-switch-accessory-popup.edj
 ADD_DEPENDENCIES(${PROJECT_NAME} accessibility-smart-switch-accessory-popup.edj)
 INSTALL(FILES ${CMAKE_BINARY_DIR}/accessibility-smart-switch-accessory-popup.edj DESTINATION ${EDJDIR})
 
+ADD_CUSTOM_TARGET(genlist.edj
+               COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/resource/images -id ${CMAKE_SOURCE_DIR}/resource/icons -sd ${CMAKE_SOURCE_DIR}/resource/sounds
+               ${CMAKE_SOURCE_DIR}/resource/genlist.edc ${CMAKE_BINARY_DIR}/genlist.edj
+               DEPENDS ${CMAKE_SOURCE_DIR}/resource/genlist.edc
+)
+ADD_DEPENDENCIES(${PROJECT_NAME} genlist.edj)
+INSTALL(FILES ${CMAKE_BINARY_DIR}/genlist.edj DESTINATION ${EDJDIR})
+
 INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/resource/icons DESTINATION ${RESDIR} FILES_MATCHING PATTERN "*.png")
 
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/${PKGNAME}.xml DESTINATION ${TZ_SYS_RO_PACKAGES})
diff --git a/resource/genlist.edc b/resource/genlist.edc
new file mode 100644 (file)
index 0000000..4fa9d67
--- /dev/null
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  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.
+ *
+ */
+collections {
+   #define POPUP_TEXT_SLIDER_BG_MIN_INC 0 42
+   #define POPUP_TEXT_SLIDER_PADDING_SIZE_INC 47 27
+   base_scale: 3;
+   group { name: "gl_custom_item";
+      styles{
+         style { name: "text_style";
+            base: "color=#FF0000FF font=Tizen:style=Regular font_size=20 text_class=list_item ellipsis=1.0";
+            tag:  "br" "\n";
+            tag:  "ps" "ps";
+            tag:  "tab" "\t";
+            tag:  "b" "+ font_weight=Bold";
+            tag:  "match" "+ color=#0051B5FF";
+         }
+      }
+      parts {
+         part { name: "base";
+            type: SPACER;
+            scale: 1;
+            description { state: "default" 0.0;
+               min: 0 120; //GENLIST_ITEM_1LINE_HEIGHT
+            }
+         }
+         part { name: "left_padding";
+            type: SPACER;
+            scale: 1;
+            description { state: "default" 0.0;
+               min: 24 0;
+               align: 0.0 0.0;
+               rel1 { to: "base"; relative: 0.0 0.0; }
+               rel2 { to: "base"; relative: 0.0 1.0; }
+            }
+         }
+         part { name: "right_padding";
+            type: SPACER;
+            scale: 1;
+            description { state: "default" 0.0;
+               min: 24 0;
+               align: 1.0 0.0;
+               rel1 { to: "base"; relative: 1.0 0.0; }
+               rel2 { to: "base"; relative: 1.0 1.0; }
+            }
+         }
+         part { name: "top_padding";
+            type: SPACER;
+            scale: 1;
+            description { state: "default" 0.0;
+               min: 0 17;
+               align: 0.0 0.0;
+               rel1 { to_x: "left_padding"; to_y: "base"; relative: 1.0 0.0; }
+               rel2 { to_x: "right_padding"; to_y: "base"; relative: 0.0 0.0; }
+            }
+         }
+         part { name: "elm.text";
+            type: SWALLOW;
+            scale: 1;
+            mouse_events: 0;
+            description { state: "default" 0.0;
+               min: 0 41;
+               align: 0.0 0.0;
+               rel1 { to: "top_padding"; relative: 0.0 1.0; }
+               rel2 { to: "top_padding"; relative: 1.0 1.0; }
+            }
+         }
+         part { name: "text_content_padding";
+            type: SPACER;
+            scale: 1;
+            description { state: "default" 0.0;
+               min: 0 10;
+               align: 0.0 0.0;
+               rel1 { to: "elm.text"; relative: 0.0 1.0; }
+               rel2 { to: "elm.text"; relative: 1.0 1.0; }
+            }
+         }
+         part {
+                name: "pad_l_t";
+                type: SPACER;
+                scale: 1;
+                description {
+                    state: "default" 0.0;
+                    min: POPUP_TEXT_SLIDER_PADDING_SIZE_INC;
+                    max: POPUP_TEXT_SLIDER_PADDING_SIZE_INC;
+                    fixed: 1 1;
+                    rel1 {
+                        relative: 0.0 0.0;
+                    }
+                    rel2 {
+                        relative: 0.0 0.0;
+                    }
+                    align: 0.0 0.0;
+                }
+            }
+            part {
+                name: "pad_r_t";
+                type: SPACER;
+                scale: 1;
+                description {
+                    state: "default" 0.0;
+                    min: POPUP_TEXT_SLIDER_PADDING_SIZE_INC;
+                    max: POPUP_TEXT_SLIDER_PADDING_SIZE_INC;
+                    fixed: 1 1;
+                    rel1.relative: 1.0 1.0;
+                    rel2.relative: 1.0 1.0;
+                    align: 1.0 1.0;
+                }
+            }
+         part { name: "elm.swallow.content";
+            type: SWALLOW;
+            scale: 1;
+            description {
+                    state: "default" 0.0;
+                    fixed: 0 1;
+                    min: POPUP_TEXT_SLIDER_BG_MIN_INC;
+                    rel1 {
+                        relative: 1.0 0.0;
+                        to_y: "pad_r_t";
+                        to_x: "pad_l_t";
+                    }
+                    rel2 {
+                        relative: 0.0 0.0;
+                        to: "pad_r_t";
+                    }
+                    align: 0.0 1.0;
+                }
+         }
+         part { name: "bottom_padding";
+            type: SPACER;
+            scale: 1;
+            description { state: "default" 0.0;
+               min: 0 24;
+               align: 0.5 1.0;
+               rel1 { to: "base"; relative: 0.0 1.0; }
+               rel2 { to: "base"; relative: 1.0 1.0; }
+            }
+         }
+      }
+   }
+}
index 3619b67d03dbd941746b38dcb2524ca85d893ce7..b3e9b984bdcec670ddd642647c8e2a561606356e 100644 (file)
@@ -148,6 +148,7 @@ void UniversalSwitchSettingsPage::createFeedbackGroup()
                        context_.usScanningProperties.getScanningProperty(Property::FEEDBACK_SOUND)->setState(item->getState());
                        item->setDescription(item->getState() ? "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_ON" : "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF");
                },
+               {},
                GenlistItem::WidgetType::toggle});
        feedbackSound_->setState(context_.usScanningProperties.getScanningProperty(Property::FEEDBACK_SOUND)->getState());
 
@@ -159,6 +160,7 @@ void UniversalSwitchSettingsPage::createFeedbackGroup()
                        context_.usScanningProperties.getScanningProperty(Property::FEEDBACK_VOICE)->setState(item->getState());
 
                        item->setDescription(item->getState() ? "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_ON" : "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF"); },
+               {},
                GenlistItem::WidgetType::toggle});
        feedbackVoice_->setState(context_.usScanningProperties.getScanningProperty(Property::FEEDBACK_VOICE)->getState());
 }
@@ -199,6 +201,7 @@ void UniversalSwitchSettingsPage::createAdditionalSettingsGroup()
                                !item->getState(),
                                "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF");
                        item->setDescription(str); },
+               {},
                GenlistItem::WidgetType::toggle});
        if (context_.usScanningProperties.getScanningProperty(Property::PAUSE_ON_FIRST_ITEM)->getState()) {
                pauseOnFirst_->setState(true);
@@ -239,6 +242,7 @@ void UniversalSwitchSettingsPage::createAdditionalSettingsGroup()
                                !item->getState(),
                                "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF");
                        item->setDescription(str); },
+               {},
                GenlistItem::WidgetType::toggle});
 
        if (context_.usScanningProperties.getScanningProperty(Property::TAP_DURATION)->getState()) {
@@ -278,6 +282,7 @@ void UniversalSwitchSettingsPage::createAdditionalSettingsGroup()
                                !item->getState(),
                                "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF");
                        item->setDescription(str); },
+               {},
                GenlistItem::WidgetType::toggle});
 
        if (context_.usScanningProperties.getScanningProperty(Property::SINGLE_INTERACTION_INTERVAL)->getState()) {
@@ -317,6 +322,7 @@ void UniversalSwitchSettingsPage::createAdditionalSettingsGroup()
                                !item->getState(),
                                "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF");
                        item->setDescription(str); },
+               {},
                GenlistItem::WidgetType::toggle});
 
        if (context_.usScanningProperties.getScanningProperty(Property::AUTO_TAP)->getState()) {
@@ -353,6 +359,7 @@ void UniversalSwitchSettingsPage::createAdditionalSettingsGroup()
                        auto str = getValueUnitText(NULL, &moveIntervalValue, "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS",
                                                                                !item->getState(), "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF");
                        item->setDescription(str); },
+               {},
                GenlistItem::WidgetType::toggle});
        if (context_.usScanningProperties.getScanningProperty(Property::AUTO_MOVE_INTERVAL)->getState()) {
                autoMoveInterval_->setState(true);
diff --git a/src/model/ScreenReaderSettingsModel.cpp b/src/model/ScreenReaderSettingsModel.cpp
new file mode 100644 (file)
index 0000000..aefac55
--- /dev/null
@@ -0,0 +1,61 @@
+#include "ScreenReaderSettingsModel.hpp"
+#include "TextToSpeech.hpp"
+
+#include <vconf-internal-keys.h>
+
+ScreenReaderSettingsModel::ScreenReaderSettingsModel()
+{
+       speechRate_ = Singleton<TextToSpeech>::instance().getSpeed();
+
+    Singleton<TextToSpeech>::instance().addSpeedChangedCb([this](auto val) {
+               this->speechRate_ = val;
+       });
+
+    speechRateMin_ = Singleton<TextToSpeech>::instance().getSpeedRange().min;
+
+    speechRateMax_ = Singleton<TextToSpeech>::instance().getSpeedRange().max;
+
+       keyboardFeedbackHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(std::string{VCONFKEY_SETAPPL_ACCESSIBILITY_SCREEN_READER_KEYBOARD_FEEDBACK}, false, [this](auto value) {
+               this->keyboardFeedback_ = value;
+       });
+
+       readUsageHintsHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(std::string{VCONFKEY_SETAPPL_ACCESSIBILITY_SCREEN_READER_DESCRIPTION}, false, [this](auto value) {
+               this->readUsageHints_ = value;
+       });
+
+       vibrationFeedbackHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(std::string{VCONFKEY_SETAPPL_ACCESSIBILITY_SCREEN_READER_HAPTIC}, false, [this](auto value) {
+               this->vibrationFeedback_ = value;
+       });
+
+       soundFeedbackHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(std::string{VCONFKEY_SETAPPL_ACCESSIBILITY_SCREEN_READER_SOUND_FEEDBACK}, false, [this](auto value) {
+               this->soundFeedback_ = value;
+       });
+
+    speechRate_.attach([](auto val) {
+               Singleton<TextToSpeech>::instance().setSpeed(val);
+       });
+
+
+       keyboardFeedback_.attach([](auto val) {
+               Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_SCREEN_READER_KEYBOARD_FEEDBACK, val);
+       });
+
+       readUsageHints_.attach([](auto val) {
+               Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_SCREEN_READER_DESCRIPTION, val);
+       });
+
+       vibrationFeedback_.attach([](auto val) {
+               Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_SCREEN_READER_HAPTIC, val);
+       });
+
+       soundFeedback_.attach([](auto val) {
+               Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_SCREEN_READER_SOUND_FEEDBACK, val);
+       });
+
+}
+
+ScreenReaderSettingsModel::~ScreenReaderSettingsModel()
+{
+       Singleton<TextToSpeech>::instance().clearSpeedChangedCallbacks();
+}
+
diff --git a/src/model/ScreenReaderSettingsModel.hpp b/src/model/ScreenReaderSettingsModel.hpp
new file mode 100644 (file)
index 0000000..fcfa909
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef SCREEN_READER_SETTINGS_MODEL_HPP
+#define SCREEN_READER_SETTINGS_MODEL_HPP
+
+#include "ObservableProperty.hpp"
+#include "VConf.hpp"
+
+class ScreenReaderSettingsModel
+{
+       public:
+       ScreenReaderSettingsModel();
+       ~ScreenReaderSettingsModel();
+
+       size_t speechRateMin_;
+       size_t speechRateMax_;
+       ObservableProperty<int> speechRate_;
+       ObservableProperty<bool> keyboardFeedback_;
+       ObservableProperty<bool> readUsageHints_;
+       ObservableProperty<bool> vibrationFeedback_;
+       ObservableProperty<bool> soundFeedback_;
+
+       private:
+       VConfInterface::CallbackHandle keyboardFeedbackHandle_;
+       VConfInterface::CallbackHandle readUsageHintsHandle_;
+       VConfInterface::CallbackHandle vibrationFeedbackHandle_;
+       VConfInterface::CallbackHandle soundFeedbackHandle_;
+};
+
+#endif
diff --git a/src/model/StatusBarInformationModel.cpp b/src/model/StatusBarInformationModel.cpp
new file mode 100644 (file)
index 0000000..3edd2f8
--- /dev/null
@@ -0,0 +1,57 @@
+#include "StatusBarInformationModel.hpp"
+
+#include <vconf-internal-keys.h>
+
+StatusBarInformationModel::StatusBarInformationModel()
+{
+       timeEnabledHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(std::string{VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_TIME}, false, [this](auto value) {
+               this->timeEnabled_ = value;
+       });
+
+       dateEnabledHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(std::string{VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_DATE}, false, [this](auto value) {
+               this->dateEnabled_ = value;
+       });
+
+       batteryEnabledHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(std::string{VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_BATTERY}, false, [this](auto value) {
+               this->batteryEnabled_ = value;
+       });
+
+       signalStrenghtEnabledHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(std::string{VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_SIGNAL_STRENGHT}, false, [this](auto value) {
+               this->signalStrenghtEnabled_ = value;
+       });
+
+       bluetoothEnabledHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(std::string{VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_BLUETOOTH}, false, [this](auto value) {
+               this->bluetoothEnabled_ = value;
+       });
+
+       missedEventsEnabledHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(std::string{VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_MISSED_EVENTS}, false, [this](auto value) {
+               this->missedEventsEnabled_ = value;
+       });
+
+
+       timeEnabled_.attach([](auto val) {
+               Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_TIME, val);
+       });
+
+       dateEnabled_.attach([](auto val) {
+               Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_DATE, val);
+       });
+
+       batteryEnabled_.attach([](auto val) {
+               Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_BATTERY, val);
+       });
+
+       signalStrenghtEnabled_.attach([](auto val) {
+               Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_SIGNAL_STRENGHT, val);
+       });
+
+       bluetoothEnabled_.attach([](auto val) {
+                       Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_BLUETOOTH, val);
+               });
+
+       missedEventsEnabled_.attach([](auto val) {
+                       Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS_INDICATOR_INFORMATION_MISSED_EVENTS, val);
+       });
+
+}
+
diff --git a/src/model/StatusBarInformationModel.hpp b/src/model/StatusBarInformationModel.hpp
new file mode 100644 (file)
index 0000000..f189e6b
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef STATUS_BAR_INFORMATION_MODEL_HPP
+#define STATUS_BAR_INFORMATION_MODEL_HPP
+
+#include "ObservableProperty.hpp"
+#include "VConf.hpp"
+
+class StatusBarInformationModel
+{
+       public:
+       StatusBarInformationModel();
+
+       ObservableProperty<bool> timeEnabled_;
+       ObservableProperty<bool> dateEnabled_;
+       ObservableProperty<bool> batteryEnabled_;
+       ObservableProperty<bool> signalStrenghtEnabled_;
+       ObservableProperty<bool> bluetoothEnabled_;
+       ObservableProperty<bool> missedEventsEnabled_;
+
+       private:
+       VConfInterface::CallbackHandle timeEnabledHandle_;
+       VConfInterface::CallbackHandle dateEnabledHandle_;
+       VConfInterface::CallbackHandle batteryEnabledHandle_;
+       VConfInterface::CallbackHandle signalStrenghtEnabledHandle_;
+       VConfInterface::CallbackHandle bluetoothEnabledHandle_;
+       VConfInterface::CallbackHandle missedEventsEnabledHandle_;
+};
+
+#endif
diff --git a/src/model/TextToSpeechModel.cpp b/src/model/TextToSpeechModel.cpp
new file mode 100644 (file)
index 0000000..4c567d9
--- /dev/null
@@ -0,0 +1,27 @@
+#include "TextToSpeechModel.hpp"
+#include "Singleton.hpp"
+#include "TextToSpeech.hpp"
+
+TextToSpeechModel::TextToSpeechModel() {
+
+       speechRate_ = Singleton<TextToSpeech>::instance().getSpeed();
+
+    Singleton<TextToSpeech>::instance().addSpeedChangedCb([this](auto val) {
+               this->speechRate_ = val;
+       });
+
+    speechRate_.attach([](auto val) {
+               Singleton<TextToSpeech>::instance().setSpeed(val);
+    });
+
+    auto speedRange = Singleton<TextToSpeech>::instance().getSpeedRange();
+    speechRateMin_ = speedRange.min;
+    speechRateMax_ = speedRange.max;
+}
+
+TextToSpeechModel::~TextToSpeechModel() {
+
+       Singleton<TextToSpeech>::instance().clearSpeedChangedCallbacks();
+
+}
+
diff --git a/src/model/TextToSpeechModel.hpp b/src/model/TextToSpeechModel.hpp
new file mode 100644 (file)
index 0000000..adeb985
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef MODEL_TEXT_TO_SPEECH_MODEL_HPP
+#define MODEL_TEXT_TO_SPEECH_MODEL_HPP
+
+#include "ObservableProperty.hpp"
+
+class TextToSpeechModel
+{
+       public:
+       TextToSpeechModel();
+       ~TextToSpeechModel();
+       ObservableProperty<int> speechRate_;
+       size_t speechRateMin_;
+       size_t speechRateMax_;
+};
+
+#endif /* MODEL_TEXT_TO_SPEECH_MODEL_HPP */
index a8a44fd0023703631db532c9df291b9d60ce071d..c8939788b6c4a63919a37a779213d48dd265b908 100644 (file)
@@ -5,6 +5,7 @@ ListItem::ListItem(std::string title,
        std::function<void(ListItem *item)> onItemSelection,
        WidgetType type,
        std::function<void(ListItem *item)> onWidgetSelection,
+       std::function<void(ListItem *item)> onWidgetChanged,
        bool state,
        std::string iconPath)
        : title_(std::move(title)),
@@ -12,6 +13,7 @@ ListItem::ListItem(std::string title,
          onItemSelection_(std::move(onItemSelection)),
          widgetType_(type),
          onWidgetSelection_(std::move(onWidgetSelection)),
+         onWidgetChanged_(std::move(onWidgetChanged)),
          widgetState_(state),
          iconPath_(std::move(iconPath))
 {}
index 32d6ef9ab3591a2c2bbfd8f28c731af2da0382ba..4725625d256ae35ac64075bb9be1b1260266a8ba 100644 (file)
@@ -15,7 +15,8 @@ struct ListItem
                check,
                toggle,
                radio,
-               icon
+               icon,
+               slider
        };
 
        ListItem(std::string title,
@@ -23,6 +24,7 @@ struct ListItem
                std::function<void(ListItem *item)> onItemSelection = {},
                WidgetType type = WidgetType::none,
                std::function<void(ListItem *item)> onWidgetSelection = {},
+               std::function<void(ListItem *item)> onWidgetChanged = {},
                bool state = false,
                std::string iconPath = {});
 
@@ -31,9 +33,12 @@ struct ListItem
        const std::function<void(ListItem *item)> onItemSelection_;
        const WidgetType widgetType_ = WidgetType::none;
        const std::function<void(ListItem *item)> onWidgetSelection_;
+       const std::function<void(ListItem *item)> onWidgetChanged_;
        ObservableProperty<bool> widgetState_ = false;
        const std::string iconPath_;
        ObservableProperty<bool> enabled_ = true;
+       double value_;
+       std::pair<double, double> range_;
 };
 
 #endif
\ No newline at end of file
index 4778a34a487aef0794a6fa5f621c4e6e074c07c2..7f206ef4ed09409e4aad692b344356787eaf149e 100644 (file)
@@ -14,6 +14,7 @@ MainPagePresenter::MainPagePresenter()
                [this](auto item) { Singleton<AppContext>::instance().push(std::make_unique<ScreenReaderPresenter>()); },
                ListItem::WidgetType::none,
                std::function<void(ListItem * item)>{},
+               std::function<void(ListItem * item)>{},
                model_.state_.value()));
        groups_.back().items_.push_back(std::make_unique<ListItem>(
                "IDS_ACCS_UNIVERSAL_SWITCH",
index e78ec83a738e973f9eafa59bb73c572d1daeba82..d17f4fa790b5b5cfa8d7257f8b776dc8809a7d48 100644 (file)
@@ -1,4 +1,5 @@
 #include "ScreenReaderPresenter.hpp"
+#include "ScreenReaderSettingsPresenter.hpp"
 
 #include "TextToSpeech.hpp"
 
@@ -15,6 +16,7 @@ ScreenReaderPresenter::ScreenReaderPresenter()
                },
                ListItem::WidgetType::toggle,
                std::function<void(ListItem * item)>{},
+               std::function<void(ListItem * item)>{},
                model_.state_.value()));
        items.push_back(std::make_unique<ListItem>(
                std::string{},
@@ -22,9 +24,7 @@ ScreenReaderPresenter::ScreenReaderPresenter()
        items.push_back(std::make_unique<ListItem>(
                "IDS_ST_OPT_SETTINGS",
                std::string{},
-               [this](auto item) {
-                       this->screenReaderSettingsPage_ = std::make_unique<ScreenReaderSettingsPage>();
-               }));
+               [this](auto item) { Singleton<AppContext>::instance().push(std::make_unique<ScreenReaderSettingsPresenter>()); }));
        model_.state_.attach([this](auto state) {
                auto item = groups_[0].items_[0].get();
                item->widgetState_ = state;
@@ -34,4 +34,4 @@ ScreenReaderPresenter::ScreenReaderPresenter()
                        Singleton<TextToSpeech>::instance().play(buf.str());
                }
        });
-}
\ No newline at end of file
+}
diff --git a/src/presenter/ScreenReaderSettingsPresenter.cpp b/src/presenter/ScreenReaderSettingsPresenter.cpp
new file mode 100644 (file)
index 0000000..1c958a6
--- /dev/null
@@ -0,0 +1,91 @@
+#include "ScreenReaderSettingsPresenter.hpp"
+
+#include "AppContext.hpp"
+#include "StatusBarInformationPresenter.hpp"
+#include "TextToSpeechPresenter.hpp"
+#include "utils.hpp"
+
+ScreenReaderSettingsPresenter::ScreenReaderSettingsPresenter()
+       : ListPresenter("IDS_ST_OPT_SETTINGS")
+{
+       groups_.emplace_back("");
+
+       auto &items = groups_.back().items_;
+       items.push_back(std::make_unique<ListItem>(
+               "IDS_ST_BODY_SPEECH_RATE",
+               std::to_string(utils::rescale(model_.speechRate_.value(), {model_.speechRateMin_, model_.speechRateMax_})),
+               [this](auto item) { Singleton<AppContext>::instance().push(std::make_unique<TextToSpeechPresenter>()); } //TODO: add TextToSpeechPresenter
+               ));
+
+       items.push_back(std::make_unique<ListItem>(
+               "IDS_ACCS_OPT_KEYBOARD_FEEDBACK_TTS",
+               "IDS_ACCS_OPT_ALWAYS_READ_OUT_KEYBOARD_INPUT_TTS",
+               [this](auto item) { this->model_.keyboardFeedback_ = item->widgetState_.value(); },
+               ListItem::WidgetType::toggle,
+               std::function<void(ListItem * item)>{},
+               std::function<void(ListItem * item)>{},
+               model_.keyboardFeedback_.value()));
+
+       items.push_back(std::make_unique<ListItem>(
+               "IDS_ACCS_MBODY_READ_OUT_USAGE_HINTS_ABB",
+               std::string{},
+               [this](auto item) { this->model_.readUsageHints_ = item->widgetState_.value(); },
+               ListItem::WidgetType::toggle,
+               std::function<void(ListItem * item)>{},
+               std::function<void(ListItem * item)>{},
+               model_.readUsageHints_.value()));
+
+       items.push_back(std::make_unique<ListItem>(
+               "IDS_ACCS_MBODY_VIBRATION_FEEDBACK",
+               std::string{},
+               [this](auto item) { this->model_.vibrationFeedback_ = item->widgetState_.value(); },
+               ListItem::WidgetType::toggle,
+               std::function<void(ListItem * item)>{},
+               std::function<void(ListItem * item)>{},
+               model_.vibrationFeedback_.value()));
+
+       items.push_back(std::make_unique<ListItem>(
+               "IDS_ACCS_MBODY_SOUND_FEEDBACK",
+               std::string{},
+               [this](auto item) { this->model_.soundFeedback_ = item->widgetState_.value(); },
+               ListItem::WidgetType::toggle,
+               std::function<void(ListItem * item)>{},
+               std::function<void(ListItem * item)>{},
+               model_.soundFeedback_.value()));
+
+       items.push_back(std::make_unique<ListItem>(
+               "IDS_ACCS_TMBODY_STATUS_BAR_INFORMATION",
+               std::string{},
+               [this](auto item) { Singleton<AppContext>::instance().push(std::make_unique<StatusBarInformationPresenter>()); } //TODO: add StatusBarInformationPresenter
+               ));
+
+       items.push_back(std::make_unique<ListItem>(
+               std::string{},
+               "IDS_ACCS_SBODY_SELECT_WHICH_INFORMATION_FROM_INDICATORS_SHOWN_ON_THE_STATUS_BAR_WILL_BE_READ_OUT_WHEN_YOU_TRIPLE_"
+               "TAP_THE_SCREEN_WITH_TWO_FINGERS_MSG"));
+
+       model_.speechRate_.attach([this](auto value) {
+               auto item = groups_[0].items_[0].get();
+               item->description_ = std::to_string(utils::rescale(value, {this->model_.speechRateMin_, this->model_.speechRateMax_}));
+       });
+
+       model_.keyboardFeedback_.attach([this](auto state) {
+               auto item = groups_[0].items_[1].get();
+               item->widgetState_ = state;
+       });
+
+       model_.readUsageHints_.attach([this](auto state) {
+               auto item = groups_[0].items_[2].get();
+               item->widgetState_ = state;
+       });
+
+       model_.vibrationFeedback_.attach([this](auto state) {
+               auto item = groups_[0].items_[3].get();
+               item->widgetState_ = state;
+       });
+
+       model_.soundFeedback_.attach([this](auto state) {
+               auto item = groups_[0].items_[4].get();
+               item->widgetState_ = state;
+       });
+}
diff --git a/src/presenter/ScreenReaderSettingsPresenter.hpp b/src/presenter/ScreenReaderSettingsPresenter.hpp
new file mode 100644 (file)
index 0000000..fb13203
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef SCREEN_READER_SETTINGS_PRESENTER_HPP
+#define SCREEN_READER_SETTINGS_PRESENTER_HPP
+
+#include "ListPresenter.hpp"
+#include "ScreenReaderSettingsModel.hpp"
+
+class ScreenReaderSettingsPresenter : public ListPresenter
+{
+       public:
+       ScreenReaderSettingsPresenter();
+
+       private:
+       ScreenReaderSettingsModel model_;
+};
+
+#endif
diff --git a/src/presenter/StatusBarInformationPresenter.cpp b/src/presenter/StatusBarInformationPresenter.cpp
new file mode 100644 (file)
index 0000000..f112e64
--- /dev/null
@@ -0,0 +1,100 @@
+#include "StatusBarInformationPresenter.hpp"
+
+StatusBarInformationPresenter::StatusBarInformationPresenter()
+:ListPresenter("IDS_ACCS_TMBODY_STATUS_BAR_INFORMATION")
+{
+       groups_.emplace_back("");
+
+       auto &items = groups_.back().items_;
+       items.push_back(std::make_unique<ListItem>(
+               "IDS_ST_HEADER_TIME",
+               std::string{},
+               [this](auto item) { this->model_.timeEnabled_ = item->widgetState_.value(); },
+               ListItem::WidgetType::toggle,
+               std::function<void(ListItem * item)>{},
+               std::function<void(ListItem * item)>{},
+               model_.timeEnabled_.value()
+       ));
+
+       items.push_back(std::make_unique<ListItem>(
+               "IDS_ST_BODY_DATE",
+               std::string{},
+               [this](auto item) { this->model_.dateEnabled_ = item->widgetState_.value(); },
+               ListItem::WidgetType::toggle,
+               std::function<void(ListItem * item)>{},
+               std::function<void(ListItem * item)>{},
+               model_.dateEnabled_.value()
+       ));
+
+
+       items.push_back(std::make_unique<ListItem>(
+               "IDS_ST_BODY_BATTERY",
+               std::string{},
+               [this](auto item) { this->model_.batteryEnabled_ = item->widgetState_.value(); },
+               ListItem::WidgetType::toggle,
+               std::function<void(ListItem * item)>{},
+               std::function<void(ListItem * item)>{},
+               model_.batteryEnabled_.value()
+       ));
+
+       items.push_back(std::make_unique<ListItem>(
+               "IDS_ST_BODY_SIGNAL_STRENGTH",
+               std::string{},
+               [this](auto item) { this->model_.signalStrenghtEnabled_ = item->widgetState_.value(); },
+               ListItem::WidgetType::toggle,
+               std::function<void(ListItem * item)>{},
+               std::function<void(ListItem * item)>{},
+               model_.signalStrenghtEnabled_.value()
+       ));
+
+       items.push_back(std::make_unique<ListItem>(
+               "IDS_ST_BODY_BLUETOOTH",
+               std::string{},
+               [this](auto item) { this->model_.bluetoothEnabled_ = item->widgetState_.value(); },
+               ListItem::WidgetType::toggle,
+               std::function<void(ListItem * item)>{},
+               std::function<void(ListItem * item)>{},
+               model_.bluetoothEnabled_.value()
+       ));
+
+       items.push_back(std::make_unique<ListItem>(
+               "IDS_ST_BODY_MISSED_EVENTS",
+               std::string{},
+               [this](auto item) { this->model_.missedEventsEnabled_ = item->widgetState_.value(); },
+               ListItem::WidgetType::toggle,
+               std::function<void(ListItem * item)>{},
+               std::function<void(ListItem * item)>{},
+               model_.missedEventsEnabled_.value()
+       ));
+
+
+       model_.timeEnabled_.attach([this](auto state) {
+               auto item = groups_[0].items_[0].get();
+               item->widgetState_ = state;
+       });
+
+       model_.dateEnabled_.attach([this](auto state) {
+               auto item = groups_[0].items_[1].get();
+               item->widgetState_ = state;
+       });
+
+       model_.batteryEnabled_.attach([this](auto state) {
+               auto item = groups_[0].items_[2].get();
+               item->widgetState_ = state;
+       });
+
+       model_.signalStrenghtEnabled_.attach([this](auto state) {
+               auto item = groups_[0].items_[3].get();
+               item->widgetState_ = state;
+       });
+
+       model_.bluetoothEnabled_.attach([this](auto state) {
+               auto item = groups_[0].items_[4].get();
+               item->widgetState_ = state;
+       });
+
+       model_.missedEventsEnabled_.attach([this](auto state) {
+               auto item = groups_[0].items_[5].get();
+               item->widgetState_ = state;
+       });
+}
diff --git a/src/presenter/StatusBarInformationPresenter.hpp b/src/presenter/StatusBarInformationPresenter.hpp
new file mode 100644 (file)
index 0000000..cbc3ea1
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef STATUS_BAR_INFORMATION_PRESENTER_HPP
+#define STATUS_BAR_INFORMATION_PRESENTER_HPP
+
+#include "ListPresenter.hpp"
+#include "StatusBarInformationModel.hpp"
+
+class StatusBarInformationPresenter : public ListPresenter
+{
+       public:
+       StatusBarInformationPresenter();
+
+       private:
+       StatusBarInformationModel model_;
+
+};
+
+#endif
diff --git a/src/presenter/TextToSpeechPresenter.cpp b/src/presenter/TextToSpeechPresenter.cpp
new file mode 100644 (file)
index 0000000..d13ff4e
--- /dev/null
@@ -0,0 +1,29 @@
+#include "TextToSpeechPresenter.hpp"
+
+#include "utils.hpp"
+
+TextToSpeechPresenter::TextToSpeechPresenter()
+       : ListPresenter("IDS_ST_BODY_SPEECH_RATE")
+{
+       groups_.emplace_back("");
+
+       auto &items = groups_.back().items_;
+       auto speechRateItem = std::make_unique<ListItem>(
+               std::string{},
+               std::string{},
+               std::function<void(ListItem * item)>{},
+               ListItem::WidgetType::slider,
+               std::function<void(ListItem * item)>{},
+               [this](auto item) {
+                       this->model_.speechRate_ = utils::rescale(static_cast<size_t>(item->value_), {0, 100}, {this->model_.speechRateMin_, this->model_.speechRateMax_});
+               });
+       speechRateItem->value_ = utils::rescale(model_.speechRate_.value(), {this->model_.speechRateMin_, this->model_.speechRateMax_});
+       speechRateItem->range_ = {0, 100};
+
+       items.push_back(std::move(speechRateItem));
+
+       model_.speechRate_.attach([this](auto value) {
+               auto &item = groups_[0].items_[0];
+               item->value_ = utils::rescale(value, {this->model_.speechRateMin_, this->model_.speechRateMax_});
+       });
+}
diff --git a/src/presenter/TextToSpeechPresenter.hpp b/src/presenter/TextToSpeechPresenter.hpp
new file mode 100644 (file)
index 0000000..d805dbb
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef TEXT_TO_SPEECH_PRESENTER_HPP
+#define TEXT_TO_SPEECH_PRESENTER_HPP
+
+#include "ListPresenter.hpp"
+#include "TextToSpeechModel.hpp"
+
+class TextToSpeechPresenter : public ListPresenter
+{
+       public:
+       TextToSpeechPresenter();
+
+       private:
+       TextToSpeechModel model_;
+
+};
+
+#endif
index 4ceefc5019c1c7897befa129091259bd2e5085e6..0087da6b13c24da6564dcf1b2b9f604138b8bdef 100644 (file)
@@ -138,4 +138,4 @@ void TextToSpeech::onSpeedChange(int speed, void *user_data)
        for (auto it : self->speedChangedCallbacks_)
                if (it)
                        it(speed);
-}
\ No newline at end of file
+}
index 1b4b577138bdf1b3dce703ec8026b2d8bae13827..9f6a59a36d409b94b7929d847cc1860fca938401 100644 (file)
@@ -4,12 +4,16 @@
 #include "Check.hpp"
 #include "Genlist.hpp"
 #include "Icon.hpp"
+#include "Label.hpp"
+#include "Layout.hpp"
 #include "Radio.hpp"
+#include "Slider.hpp"
+
+#include <app.h>
 
 GenlistItem::GenlistItem(std::string style, TranslatedString text, TranslatedString desc, Type type)
        : style_(std::move(style)), text_(std::move(text)), description_(std::move(desc)), type_(type)
-{
-}
+{}
 
 GenlistItem::GenlistItem(
        std::string style,
@@ -18,8 +22,7 @@ GenlistItem::GenlistItem(
        std::function<void(GenlistItem *)> onItemSelection,
        Type type)
        : style_(std::move(style)), text_(std::move(text)), description_(std::move(desc)), onItemSelection_(std::move(onItemSelection)), type_(type)
-{
-}
+{}
 
 GenlistItem::GenlistItem(std::string style,
        TranslatedString text,
@@ -27,8 +30,7 @@ GenlistItem::GenlistItem(std::string style,
        std::function<void(GenlistItem *)> onItemSelection,
        WidgetType type)
        : style_(std::move(style)), text_(std::move(text)), description_(std::move(desc)), onItemSelection_(std::move(onItemSelection)), widgetType_(type)
-{
-}
+{}
 
 GenlistItem::GenlistItem(std::string style,
        TranslatedString text,
@@ -37,18 +39,23 @@ GenlistItem::GenlistItem(std::string style,
        std::string iconPath,
        WidgetType type)
        : style_(std::move(style)), text_(std::move(text)), description_(std::move(desc)), onItemSelection_(std::move(onItemSelection)), iconPath_(std::move(iconPath)), widgetType_(type)
-{
-}
+{}
 
 GenlistItem::GenlistItem(std::string style,
        TranslatedString text,
        TranslatedString desc,
        std::function<void(GenlistItem *)> onItemSelection,
        std::function<void(GenlistItem *)> onContentSelection,
+       std::function<void(GenlistItem *)> onContentValueChanged,
        WidgetType type)
-       : style_(std::move(style)), text_(std::move(text)), description_(std::move(desc)), onItemSelection_(std::move(onItemSelection)), onContentSelection_(std::move(onContentSelection)), widgetType_(type)
-{
-}
+       : style_(std::move(style)),
+         text_(std::move(text)),
+         description_(std::move(desc)),
+         onItemSelection_(std::move(onItemSelection)),
+         onContentSelection_(std::move(onContentSelection)),
+         onContentValueChanged_(std::move(onContentValueChanged)),
+         widgetType_(type)
+{}
 
 void GenlistItem::setText(const TranslatedString &text)
 {
@@ -104,6 +111,21 @@ GenlistItem *GenlistItem::prev()
        return fromRawItem(raw);
 }
 
+double GenlistItem::getValue()
+{
+       return value_;
+}
+
+void GenlistItem::setValue(double val)
+{
+       value_ = val;
+}
+
+void GenlistItem::setRange(std::pair<double, double> range)
+{
+       range_ = std::move(range);
+}
+
 void GenlistItem::setId(size_t id)
 {
        id_ = id;
@@ -153,6 +175,9 @@ Elm_Genlist_Item_Type GenlistItem::getItemType()
 char *GenlistItem::textRealizator(void *data, Evas_Object *obj, const char *part)
 {
        auto self = static_cast<GenlistItem *>(data);
+       if (self->widgetType_ == WidgetType::slider)
+               return nullptr;
+
        using namespace std::string_literals;
 
        if (part == "elm.text"s && !self->text_.empty())
@@ -180,6 +205,9 @@ Evas_Object *GenlistItem::contentRealizator(void *data, Evas_Object *obj, const
        case WidgetType::radio:
                return self->realizeRadio(part);
 
+       case WidgetType::slider:
+               return self->realizeSlider(part);
+
        default:
                break;
        }
@@ -266,6 +294,31 @@ Evas_Object *GenlistItem::realizeRadio(const std::string &part)
        return radio->getObject();
 }
 
+Evas_Object *GenlistItem::realizeSlider(const std::string &part)
+{
+       auto layout = Widget::make<Layout>(genlist_, "edje/genlist.edj", "gl_custom_item");
+       auto label = Widget::make<Label>(genlist_, text_);
+       layout->setPartContent("elm.text", label);
+
+       auto slider = Widget::make<Slider>(layout);
+       slider->showIndicator(true);
+       slider->setWeightHint(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       slider->setAlignHint(EVAS_HINT_FILL, EVAS_HINT_FILL);
+       slider->setIndicatorFormat("%1.0f");
+       slider->setRange(range_.first, range_.second);
+       slider->setValue(value_);
+       layout->setPartContent("elm.swallow.content", slider);
+
+       slider->setEvasSmartCallback("delay,changed", [=]() {
+               value_ = slider->getValue();
+               if (onContentValueChanged_) {
+                       onContentValueChanged_(this);
+               }
+       });
+
+       return layout->getObject();
+}
+
 void GenlistItem::onItemSelection(void *data, Evas_Object *obj, void *event_info)
 {
        auto self = static_cast<GenlistItem *>(data);
@@ -278,4 +331,4 @@ void GenlistItem::onItemSelection(void *data, Evas_Object *obj, void *event_info
        if (self->onItemSelection_)
                self->onItemSelection_(self);
        elm_genlist_item_selected_set(self->objItem_, EINA_FALSE);
-}
\ No newline at end of file
+}
index 52fba97228f9cb4f7b94b7128579eeb67afe7ba1..129c330f67acc673243f7734707e719f219c3e74 100644 (file)
@@ -26,7 +26,8 @@ class GenlistItem
                check,
                toggle,
                radio,
-               icon
+               icon,
+               slider
        };
 
        GenlistItem(std::string style, TranslatedString text, TranslatedString desc = {}, Type type = Type::group);
@@ -50,7 +51,8 @@ class GenlistItem
                TranslatedString text,
                TranslatedString desc,
                std::function<void(GenlistItem *)> onItemSelection,
-               std::function<void(GenlistItem *)> onWidgetSelection,
+               std::function<void(GenlistItem *)> onContentSelection,
+               std::function<void(GenlistItem *)> onContentValueChanged,
                WidgetType type);
 
        void setText(const TranslatedString &text);
@@ -62,6 +64,9 @@ class GenlistItem
        void enable();
        GenlistItem *next();
        GenlistItem *prev();
+       double getValue();
+       void setValue(double val);
+       void setRange(std::pair<double, double> range);
 
        // TODO: current implementation does not take advantage from radio groups.
        //              When legacy solution for adding genlist items is completely removed
@@ -78,6 +83,7 @@ class GenlistItem
        Evas_Object *realizeCheck(const std::string &part);
        Evas_Object *realizeIcon(const std::string &part);
        Evas_Object *realizeRadio(const std::string &part);
+       Evas_Object *realizeSlider(const std::string &part);
 
        static char *textRealizator(void *data, Evas_Object *obj, const char *part);
        static Evas_Object *contentRealizator(void *data, Evas_Object *obj, const char *part);
@@ -88,6 +94,7 @@ class GenlistItem
        TranslatedString description_;
        std::function<void(GenlistItem *)> onItemSelection_;
        std::function<void(GenlistItem *)> onContentSelection_;
+       std::function<void(GenlistItem *)> onContentValueChanged_;
        Genlist *genlist_ = nullptr;
        Eina_Bool state_ = EINA_FALSE;
        std::string iconPath_;
@@ -96,6 +103,8 @@ class GenlistItem
        Type type_ = Type::regular;
        WidgetType widgetType_ = WidgetType::none;
        size_t id_ = 0;
+       double value_ = 0.0;
+       std::pair<double, double> range_;
 };
 
-#endif
\ No newline at end of file
+#endif
index 642a87193ba02789dc0222341239d4dd3bb6549b..6de3a2bb81d34829d70ab703f3ef3beef161b90f 100644 (file)
@@ -19,8 +19,6 @@
 
 #include "Elementary.h"
 
-#include <memory>
-
 using SettingCallback = void (*)(void *, Evas_Object *, void *);
 
 namespace utils
@@ -43,6 +41,22 @@ namespace utils
                                elm_genlist_item_class_free(it);
                }
        };
+
+       struct Range
+       {
+               size_t begin;
+               size_t end;
+       };
+
+       inline size_t rescale(size_t value, Range source, Range target = {0, 100})
+       {
+               auto denominator = source.end - source.begin;
+               auto rescaledValue = target.begin;
+               if (denominator != 0)
+                       rescaledValue += (value - source.begin) * target.end / denominator;
+
+               return rescaledValue;
+       }
 } // namespace utils
 
 #endif
index d78fa2c476c1c0c7c9e123a31644ce7e8a6c6779..8742c44ec143164f5704d0e6b5491f4125f873e6 100644 (file)
@@ -37,6 +37,16 @@ void ListView::addItemsToGenlist()
                        search->second->onWidgetSelection_(search->second);
        };
 
+       auto wrappedOnWidgetChanged = [this](GenlistItem *item) {
+               auto search = itemsMapping_.find(item);
+               ASSERT(search != itemsMapping_.end(), "Item not mapped");
+               search->second->widgetState_ = item->getState();
+               search->second->value_ = item->getValue();
+               if (search->second->onWidgetChanged_) {
+                       search->second->onWidgetChanged_(search->second);
+               }
+       };
+
        for (const auto &g : listPresenter_->getListGroups()) {
                GenlistItem *groupItem = nullptr;
                if (!g.name_.empty())
@@ -45,17 +55,23 @@ void ListView::addItemsToGenlist()
                for (const auto &it : g.items_) {
                        auto type = translateType(it->widgetType_);
                        auto style = it->description_.value().empty() ? "type1" : "multiline";
+                       if (it->widgetType_ == ListItem::WidgetType::slider)
+                               style = "full";
                        auto genlistItem = genlist_->appendItem({style,
                                                                                                                it->title_.value(),
                                                                                                                it->description_.value(),
                                                                                                                it->onItemSelection_ ? wrappedOnItemSelection : std::function<void(GenlistItem *)>{},
                                                                                                                it->onWidgetSelection_ ? wrappedOnWidgetSelection : std::function<void(GenlistItem *)>{},
+                                                                                                               it->onWidgetChanged_ ? wrappedOnWidgetChanged : std::function<void(GenlistItem *)>{},
                                                                                                                type},
                                groupItem);
 
                        if (!it->enabled_.value())
                                genlistItem->disable();
 
+                       genlistItem->setValue(it->value_);
+                       genlistItem->setRange(std::move(it->range_));
+
                        itemsMapping_.emplace(genlistItem, it.get());
                        it->title_.attach([this, gi = genlistItem](auto val) { gi->setText(val); });
                        it->description_.attach([this, gi = genlistItem](auto val) { gi->setDescription(val); });
@@ -88,6 +104,9 @@ GenlistItem::WidgetType ListView::translateType(ListItem::WidgetType t)
 
        case ListItem::WidgetType::icon:
                return GenlistItem::WidgetType::icon;
+
+       case ListItem::WidgetType::slider:
+               return GenlistItem::WidgetType::slider;
        }
        ERROR("Invalid type");
        return {};