#include "setting-debug.h"
#include "Check.hpp"
#include "Genlist.hpp"
+#include "Icon.hpp"
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)
: style_(std::move(style)), text_(std::move(text)), description_(std::move(desc)), onSelection_(std::move(onSelection)), widgetType_(type)
{}
+GenlistItem::GenlistItem(std::string style, TranslatedString text, TranslatedString desc, std::function<void(GenlistItem *)> onSelection, std::string iconPath, WidgetType type)
+ : style_(std::move(style)), text_(std::move(text)), description_(std::move(desc)), onSelection_(std::move(onSelection)), iconPath_(std::move(iconPath)), widgetType_(type)
+{}
+
void GenlistItem::setText(const TranslatedString &text)
{
text_ = text;
case WidgetType::check:
return self->realizeCheck(part);
+ case WidgetType::icon:
+ return self->realizeIcon(part);
+
default:
break;
}
return check->getObject();
}
+Evas_Object *GenlistItem::realizeIcon(const std::string &part)
+{
+ if (part != "elm.swallow.icon") return nullptr;
+
+ auto icon = Widget::make<Icon>(genlist_);
+ icon->setColor(15, 41, 73, 255);
+ icon->setImageFile(iconPath_);
+ icon->setAspectHint(EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+
+ return icon->getObject();
+}
+
void GenlistItem::onItemSelection(void *data, Evas_Object *obj, void *event_info)
{
SETTING_TRACE_ERROR(".");
GenlistItem(std::string style, TranslatedString text, TranslatedString desc = {}, Type type = Type::group);
GenlistItem(std::string style, TranslatedString text, TranslatedString desc, std::function<void(GenlistItem *)> onSelection, Type type = Type::regular);
GenlistItem(std::string style, TranslatedString text, TranslatedString desc, std::function<void(GenlistItem *)> onSelection, WidgetType type);
+ GenlistItem(std::string style, TranslatedString text, TranslatedString desc, std::function<void(GenlistItem *)> onSelection, std::string iconPath, WidgetType type = WidgetType::icon);
void setText(const TranslatedString &text);
void setDescription(const TranslatedString &desc);
Elm_Genlist_Item_Type getItemType();
Evas_Object *realizeToggle(const std::string &part);
Evas_Object *realizeCheck(const std::string &part);
+ Evas_Object *realizeIcon(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);
std::function<void(GenlistItem *)> onSelection_;
Genlist *genlist_ = nullptr;
Eina_Bool state_ = EINA_FALSE;
+ std::string iconPath_;
Elm_Object_Item *objItem_ = nullptr;
Type type_ = Type::regular;
uniqueObj_.reset(elm_icon_add(parent->getObject()));
show();
}
+
+void Icon::setImageFile(std::string path)
+{
+ elm_image_file_set(uniqueObj_.get(), path.c_str(), nullptr);
+}
\ No newline at end of file
public:
Icon(Widget *parent);
+ void setImageFile(std::string path);
+
};
#endif
{
switches_->clear();
createSwitchesGroup();
- createAddButton();
+ switches_->appendItem({"type1", "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_SWITCHES_ADD_SWITCH", {},
+ [this](auto item)
+ {
+ addSwitchPage_ = std::make_unique<AddSwitchPage>(context_);
+ addSwitchPage_->attachCallbackOnSwitchAttach(addSwitchCb, this);
+ }, ACCESSIBILITY_UNIVERSAL_SWITCH_PLUS_ICON
+ });
removeSwitchesPageBtn_->disable(context_->config.configuration_items.size() == 0);
}
-void SwitchesPage::createAddButton()
-{
- GenGroupItemData *item = createGendialGroupItem(switches_->getObject(), &itc_1text_1icon_3,
- addSwitchClickedCb, this,
- SwallowType::ICON_IMAGE, 0,
- "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_SWITCHES_ADD_SWITCH",
- {},
- NULL);
-
- if (item) {
- item->l_swallow_path = ACCESSIBILITY_UNIVERSAL_SWITCH_PLUS_ICON;
- item->userdata = context_;
- }
-}
-
void SwitchesPage::createSwitchesGroup()
{
for (auto &it : context_->config.configuration_items) {
}
}
-void SwitchesPage::addSwitchClickedCb(void *data, Evas_Object *obj, void *event_info)
-{
- elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
- retm_if(data == NULL, "Data argument is NULL");
- auto self = static_cast<SwitchesPage *>(data);
-
- self->addSwitchPage_ = std::make_unique<AddSwitchPage>(self->context_);
- self->addSwitchPage_->attachCallbackOnSwitchAttach(addSwitchCb, self);
-}
-
void SwitchesPage::switchClickCb(void *data, Evas_Object *obj, void *event_info)
{
Elm_Object_Item *item = (Elm_Object_Item *)event_info;
private:
void updateSwitchesList();
- void createAddButton();
void createSwitchesGroup();
- static void addSwitchClickedCb(void *data, Evas_Object *obj, void *event_info);
static void switchClickCb(void *data, Evas_Object *obj, void *event_info);
static void switchUpdatedCb(void *data, const std::string &switch_id, const std::string &switch_action, const std::string &switch_name);
static void switchRemovedCb(void *data, const std::string &switch_id, const std::string &switch_action, const std::string &switch_name);
evas_object_size_hint_max_set(uniqueObj_.get(), v, h);
}
+void Widget::setAspectHint(Evas_Aspect_Control aspect, Evas_Coord w, Evas_Coord h)
+{
+ evas_object_size_hint_aspect_set(uniqueObj_.get(), aspect, w, h);
+}
+
Rectangle Widget::getGeometry()
{
int x, y, w, h;
void setAlignHint(double x, double y);
void setMinSizeHint(Evas_Coord v, Evas_Coord h);
void setMaxSizeHint(Evas_Coord v, Evas_Coord h);
+ void setAspectHint(Evas_Aspect_Control aspect, Evas_Coord w, Evas_Coord h);
Rectangle getGeometry();
void setPosition(Point anchor);
void setEvasSmartCallback(const std::string &eventName, std::function<void()> callback);