#include "Window.hpp"
#include "Quickpanel.hpp"
-#include <map>
+#include <unordered_map>
#include <stack>
enum class RepetitionPolicy : bool {
std::string getName() const override;
};
+class MenuImplementation : public Menu
+{
+public:
+ MenuImplementation(std::vector<std::shared_ptr<MenuItem>> menuItems,
+ Alignment alignment = Alignment::CENTER, NavigateToSuperMenu navigateToSuperMenu = NavigateToSuperMenu::ALLOW);
+ const std::vector<std::shared_ptr<MenuItem>> &getMenuItems() override;
+ Alignment getAlignment() override;
+ NavigateToSuperMenu getNavigateToSuperMenu() override;
+
+private:
+ std::vector<std::shared_ptr<MenuItem>> menuItems;
+ Alignment alignment;
+ NavigateToSuperMenu navigateToSuperMenu;
+};
+
class MenuBuilderImplementation : public MenuBuilder
{
public:
MenuBuilderImplementation();
- std::vector<std::shared_ptr<MenuItem>> build(std::string) override;
+ std::shared_ptr<Menu> build(std::string) override;
private:
- void addToMap(const std::string &, const std::vector<std::shared_ptr<MenuItem>> &);
+ void addToMap(const std::string &, const std::shared_ptr<Menu> &);
- std::multimap<std::string, std::shared_ptr<MenuItem>> map;
+ std::unordered_map<std::string, std::shared_ptr<Menu>> map;
};
MenuItemImplementation::MenuItemImplementation(std::vector<std::string> names, std::string iconPath, std::string activityType,
return gettext(names[window->getQuickpanel()->isVisible() ? 1 : 0].c_str());
}
+MenuImplementation::MenuImplementation(std::vector<std::shared_ptr<MenuItem>> menuItems, Alignment alignment, NavigateToSuperMenu navigateToSuperMenu)
+ : menuItems(std::move(menuItems)), alignment(alignment), navigateToSuperMenu(navigateToSuperMenu) {}
+
+const std::vector<std::shared_ptr<MenuItem>> &MenuImplementation::getMenuItems()
+{
+ return menuItems;
+}
+
+Alignment MenuImplementation::getAlignment()
+{
+ return alignment;
+}
+
+NavigateToSuperMenu MenuImplementation::getNavigateToSuperMenu()
+{
+ return navigateToSuperMenu;
+}
+
MenuBuilderImplementation::MenuBuilderImplementation()
{
const std::string defaultImg = ICONS_DIR "/tizen.png";
auto emptyItem = std::make_shared<MenuItemImplementation>();
- addToMap("IDS_MENU_MAIN_NORMAL", {
- tap, gestures, actions, settings,
- recentApps, homeScreen, back, buttonsAndKeys
- });
- addToMap("IDS_MENU_MAIN_HOME_APPS", {
- tap, leftPage, rightPage, emptyItem,
- gestures, actions, settings, recentApps,
- homeScreen, back, buttonsAndKeys
- });
- addToMap("IDS_MENU_MAIN_SLIDER", {
- increase, decrease, emptyItem, emptyItem,
- tap, gestures, actions, settings,
- recentApps, homeScreen, back, buttonsAndKeys
- });
- addToMap("IDS_MENU_MAIN_EDITABLE_TEXT", {
- tap, editText, emptyItem, emptyItem,
- gestures, actions, settings, recentApps,
- homeScreen, back, buttonsAndKeys
- });
- addToMap("IDS_MENU_MAIN_SIP", {
- tap, touchHold
- });
- addToMap("IDS_MENU_MAIN_INCOMING_CALL", {
- tap, accept, reject, emptyItem,
- gestures, actions, settings, recentApps,
- homeScreen, back, buttonsAndKeys
- });
- addToMap("IDS_MENU_MAIN_DURING_CALL", {
- tap, endCall, emptyItem, emptyItem,
- gestures, actions, settings, recentApps,
- homeScreen, back, buttonsAndKeys
- });
- addToMap("IDS_MENU_GESTURES", {
- swipeUp, swipeDown, swipeLeft, swipeRight,
- autoScroll, touchHold, drag, touchHoldThenDrag
- });
- addToMap("IDS_MENU_ACTIONS", {
- zoomIn, zoomOut, ScreenRotation, soundVibrationMute,
- lock, openCloseNotifications, captureScreenshot
- });
- addToMap("IDS_MENU_ROTATE_SCREEN", {
- rotateLeft, rotateToPortrait, rotateRight
- });
- addToMap("IDS_MENU_SETTINGS_AUTO_SCAN_OFF", {
- scanMethod, scanVerticalDirection, turnOnOffVoice, turnOnOffSound,
- moreSettings
- });
- addToMap("IDS_MENU_SETTINGS_AUTO_SCAN_ON", {
- speedUpScaning, slowDownScaning, scanMethod, scanVerticalDirection,
- turnOnOffVoice, turnOnOffSound, moreSettings
- });
- addToMap("IDS_MENU_BUTTONS_KEYS", {
- ringtoneVolIncrease, ringtoneVolDecrease, mediaVolumeIncrease, mediaVolumeDecrease,
- tapHomeButtonx2, tapHomeButtonx3, viewPowerKeyMenu
- });
- addToMap("IDS_MENU_BUTTONS_KEYS_WIFI", {
- notiVolumeIncrease, notiVolumeDecrease, mediaVolumeIncrease, mediaVolumeDecrease,
- tapHomeButtonx2, tapHomeButtonx3, viewPowerKeyMenu
- });
- addToMap("IDS_MENU_EDIT_TEXT", {
- textEditionMode, selectAll, previous, next,
- copy, paste, cut, granularitySettings
- });
- addToMap("IDS_MENU_AUTO_SCROLL_OFF", {
- turnOnOffAutoScroll, scrollUp, scrollDown, scrollTop
- });
- addToMap("IDS_MENU_AUTO_SCROLL_ON", {
- turnOnOffAutoScroll, speedUpAutoScroll, slowDownAutoScroll
- });
- addToMap("IDS_MENU_GRANULARITY", {
- character, word, line, paragraph
- });
+ addToMap("IDS_MENU_MAIN_NORMAL", std::make_shared<MenuImplementation>(MenuImplementation {
+ {
+ tap, gestures, actions, settings,
+ recentApps, homeScreen, back, buttonsAndKeys
+ }
+ }));
+ addToMap("IDS_MENU_MAIN_HOME_APPS", std::make_shared<MenuImplementation>(MenuImplementation {
+ {
+ tap, leftPage, rightPage, emptyItem,
+ gestures, actions, settings, recentApps,
+ homeScreen, back, buttonsAndKeys
+ }
+ }));
+ addToMap("IDS_MENU_MAIN_SLIDER", std::make_shared<MenuImplementation>(MenuImplementation {
+ {
+ increase, decrease, emptyItem, emptyItem,
+ tap, gestures, actions, settings,
+ recentApps, homeScreen, back, buttonsAndKeys
+ }
+ }));
+ addToMap("IDS_MENU_MAIN_EDITABLE_TEXT", std::make_shared<MenuImplementation>(MenuImplementation {
+ {
+ tap, editText, emptyItem, emptyItem,
+ gestures, actions, settings, recentApps,
+ homeScreen, back, buttonsAndKeys
+ }
+ }));
+ addToMap("IDS_MENU_MAIN_SIP", std::make_shared<MenuImplementation>(MenuImplementation {
+ {tap, touchHold}
+ }));
+ addToMap("IDS_MENU_MAIN_INCOMING_CALL", std::make_shared<MenuImplementation>(MenuImplementation {
+ {
+ tap, accept, reject, emptyItem,
+ gestures, actions, settings, recentApps,
+ homeScreen, back, buttonsAndKeys
+ }
+ }));
+ addToMap("IDS_MENU_MAIN_DURING_CALL", std::make_shared<MenuImplementation>(MenuImplementation {
+ {
+ tap, endCall, emptyItem, emptyItem,
+ gestures, actions, settings, recentApps,
+ homeScreen, back, buttonsAndKeys
+ }
+ }));
+ addToMap("IDS_MENU_GESTURES", std::make_shared<MenuImplementation>(MenuImplementation {
+ {
+ swipeUp, swipeDown, swipeLeft, swipeRight,
+ autoScroll, touchHold, drag, touchHoldThenDrag
+ }
+ }));
+ addToMap("IDS_MENU_ACTIONS", std::make_shared<MenuImplementation>(MenuImplementation {
+ {
+ zoomIn, zoomOut, ScreenRotation, soundVibrationMute,
+ lock, openCloseNotifications, captureScreenshot
+ }
+ }));
+ addToMap("IDS_MENU_ROTATE_SCREEN", std::make_shared<MenuImplementation>(MenuImplementation {
+ {rotateLeft, rotateToPortrait, rotateRight}
+ }));
+ addToMap("IDS_MENU_SETTINGS_AUTO_SCAN_OFF", std::make_shared<MenuImplementation>(MenuImplementation {
+ {
+ scanMethod, scanVerticalDirection, turnOnOffVoice, turnOnOffSound,
+ moreSettings
+ }
+ }));
+ addToMap("IDS_MENU_SETTINGS_AUTO_SCAN_ON", std::make_shared<MenuImplementation>(MenuImplementation {
+ {
+ speedUpScaning, slowDownScaning, scanMethod, scanVerticalDirection,
+ turnOnOffVoice, turnOnOffSound, moreSettings
+ }
+ }));
+ addToMap("IDS_MENU_BUTTONS_KEYS", std::make_shared<MenuImplementation>(MenuImplementation {
+ {
+ ringtoneVolIncrease, ringtoneVolDecrease, mediaVolumeIncrease, mediaVolumeDecrease,
+ tapHomeButtonx2, tapHomeButtonx3, viewPowerKeyMenu
+ }
+ }));
+ addToMap("IDS_MENU_BUTTONS_KEYS_WIFI", std::make_shared<MenuImplementation>(MenuImplementation {
+ {
+ notiVolumeIncrease, notiVolumeDecrease, mediaVolumeIncrease, mediaVolumeDecrease,
+ tapHomeButtonx2, tapHomeButtonx3, viewPowerKeyMenu
+ }
+ }));
+ addToMap("IDS_MENU_EDIT_TEXT", std::make_shared<MenuImplementation>(MenuImplementation {
+ {
+ textEditionMode, selectAll, previous, next,
+ copy, paste, cut, granularitySettings
+ }
+ }));
+ addToMap("IDS_MENU_AUTO_SCROLL_OFF", std::make_shared<MenuImplementation>(MenuImplementation {
+ {turnOnOffAutoScroll, scrollUp, scrollDown, scrollTop},
+ Alignment::BOTTOM, NavigateToSuperMenu::DENY
+ }));
+ addToMap("IDS_MENU_AUTO_SCROLL_ON", std::make_shared<MenuImplementation>(MenuImplementation {
+ {turnOnOffAutoScroll, speedUpAutoScroll, slowDownAutoScroll},
+ Alignment::BOTTOM, NavigateToSuperMenu::DENY
+ }));
+ addToMap("IDS_MENU_GRANULARITY", std::make_shared<MenuImplementation>(MenuImplementation {
+ {character, word, line, paragraph}
+ }));
}
-std::vector<std::shared_ptr<MenuItem>> MenuBuilderImplementation::build(std::string menuLabel)
+std::shared_ptr<Menu> MenuBuilderImplementation::build(std::string menuLabel)
{
-
if (menuLabel.find("IDS_MENU_MAIN") != std::string::npos &&
!Singleton<VConfInterface>::instance().get(VCONF_KEY_SHOW_CONTEXTUAL_MENU, false))
menuLabel = "IDS_MENU_MAIN_NORMAL";
- std::vector<std::shared_ptr<MenuItem>> foundMenuItems;
- auto keyRange = map.equal_range(menuLabel);
- for (auto ii = keyRange.first; ii != keyRange.second; ++ii) {
- if (ii->second->isDisplayed())
- foundMenuItems.push_back(ii->second);
- }
-
- return foundMenuItems;
+ return map.find(menuLabel)->second;
}
-void MenuBuilderImplementation::addToMap(const std::string &menuLabel, const std::vector<std::shared_ptr<MenuItem>> &menuItems)
+void MenuBuilderImplementation::addToMap(const std::string &menuLabel, const std::shared_ptr<Menu> &menu)
{
- for (auto &menuItem : menuItems)
- map.emplace(menuLabel, std::move(menuItem));
+ map.emplace(menuLabel, std::move(menu));
}
template<>
bool isRealUIElementSlider();
bool hasRealUIElementEditableTextIface();
std::string getCompleteLabelOfButtonsKeysMenu();
- int addItemsToMenu(Evas_Object *, const std::string &);
+ void addItemsToMenu(Evas_Object *);
void gengridItemSelected(Elm_Gengrid_Item *);
static void popupDismissedCb(void *, Evas_Object *, void *);
std::vector<std::string> nestedMenusLabels;
VConfInterface::CallbackHandle callbackHandle;
std::vector<GengridItemData> gengridItemsData;
+ std::shared_ptr<Menu> menu;
std::shared_ptr<UIElement> realUiElement;
Optional<bool> realUiElementIsSlider;
Optional<bool> realUiElementHasEditableText;
}
popup.reset(elm_popup_add(Singleton<UniversalSwitch>::instance().getMainWindow()->getHandler()));
- elm_popup_orient_set(popup.get(), ELM_POPUP_ORIENT_CENTER);
+ evas_object_size_hint_weight_set(popup.get(), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_smart_callback_add(popup.get(), "dismissed", popupDismissedCb, this);
+ menu = Singleton<MenuBuilder>::instance().build(getCompleteLabelOfMenu());
+ if (menu->getAlignment() == Alignment::BOTTOM) {
+ elm_popup_orient_set(popup.get(), ELM_POPUP_ORIENT_BOTTOM);
+ elm_popup_align_set(popup.get(), ELM_NOTIFY_ALIGN_FILL, EVAS_HINT_EXPAND);
+ } else {
+ elm_popup_orient_set(popup.get(), ELM_POPUP_ORIENT_CENTER);
+ }
+
elm_theme_extension_add(NULL, UNIVERSAL_SWITCH_EDJ);
elm_object_style_set(popup.get(), "universalSwitchTransparent");
+
elm_atspi_accessible_attribute_append(popup.get(), "ScanningMethod", "RowScanner");
elm_atspi_accessible_attribute_append(popup.get(), "EscapeFrameEnabled", "true");
createMenuContent();
- evas_object_size_hint_weight_set(popup.get(), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_smart_callback_add(popup.get(), "dismissed", popupDismissedCb, this);
dbusClient = std::make_unique<DBus::DBusClient>(dbusLocators::accessibilityEMod::BUS,
dbusLocators::accessibilityEMod::OBJ_PATH, dbusLocators::accessibilityEMod::INTERFACE, DBus::ConnectionType::SYSTEM);
popup.reset();
}
+ menu.reset();
+
timer.reset();
if (dbusClient) {
elm_object_content_set(popup.get(), content);
elm_object_part_content_set(content, "elm.swallow.content", gengrid);
- if (nestedMenusLabels.size() > 1)
+ if (nestedMenusLabels.size() > 1 && menu->getNavigateToSuperMenu() == NavigateToSuperMenu::ALLOW)
addBackButton(content);
auto screenWidth = 0;
int itemHeight = itemWidth * GENGRID_ITEM_HEIGHT_WIDTH_PROPORTION;
elm_gengrid_item_size_set(gengrid, itemWidth, itemHeight);
- auto completeLabelOfMenu = getCompleteLabelOfMenu();
- addItemsToMenu(gengrid, completeLabelOfMenu);
+ addItemsToMenu(gengrid);
evas_object_size_hint_min_set(gengrid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_weight_set(gengrid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
return "IDS_MENU_BUTTONS_KEYS_WIFI";
}
-int SelectActivity::addItemsToMenu(Evas_Object *gengrid, const std::string &completeLabelOfMenu)
+void SelectActivity::addItemsToMenu(Evas_Object *gengrid)
{
Elm_Gengrid_Item_Class *gic = elm_gengrid_item_class_new();
gic->item_style = "default";
gic->func.text_get = gengridItemLabelGetCb;
gic->func.content_get = gengridItemContentGetCb;
- auto menuItems = Singleton<MenuBuilder>::instance().build(completeLabelOfMenu);
- auto numberOfItems = menuItems.size();
- for (auto &menuItem : menuItems) {
+ for (auto &menuItem : menu->getMenuItems()) {
+ if (!menuItem->isDisplayed())
+ continue;
+
menuItem->attach(std::dynamic_pointer_cast<SelectActivity>(shared_from_this()), std::make_shared<ConditionAll<MenuItem>>());
auto object = elm_gengrid_item_append(gengrid, gic, menuItem.get(), gengridItemSelectedCb, this);
if (object && menuItem->getName().empty())
}
elm_gengrid_item_class_free(gic);
-
- return numberOfItems;
}
void SelectActivity::gengridItemSelected(Elm_Gengrid_Item *item)