MoreOptionsPresenter::MoreOptionsPresenter(RefCountObjBase &rc,
const MoreOptionsCSRef &options) :
Presenter(rc),
- m_options(options)
+ m_options(options),
+ m_timer(nullptr),
+ m_newOpenedState(false)
{
}
MoreOptionsPresenter::~MoreOptionsPresenter()
{
+ stopTimer();
if (m_widget) {
sendActivateBy(*m_widget, this);
}
return RES_OK;
}
+ bool MoreOptionsPresenter::resetTimer(const double timeout)
+ {
+ stopTimer();
+
+ m_timer = ecore_timer_add(timeout, CALLBACK_A(
+ MoreOptionsPresenter::onTimer), this);
+ if (!m_timer) {
+ LOG_RETURN_VALUE(RES_FAIL, false, "ecore_timer_add() failed!");
+ }
+
+ return true;
+ }
+
+ void MoreOptionsPresenter::stopTimer()
+ {
+ if (m_timer) {
+ ecore_timer_del(m_timer);
+ m_timer = nullptr;
+ }
+ }
+
+ Eina_Bool MoreOptionsPresenter::onTimer()
+ {
+ m_timer = nullptr;
+
+ setOpened(m_newOpenedState);
+
+ return ECORE_CALLBACK_CANCEL;
+ }
+
void MoreOptionsPresenter::onOpened(Widget &widget, void *eventInfo)
{
+ stopTimer();
const auto keepAliver = asShared(*this);
sendDeactivateBy(*m_widget, this);
activateBy(m_widget.get());
void MoreOptionsPresenter::onClosed(Widget &widget, void *eventInfo)
{
+ stopTimer();
const auto keepAliver = asShared(*this);
deactivateBy(m_widget.get());
sendActivateBy(*m_widget, this);
void MoreOptionsPresenter::setOpened(const bool isOpened)
{
+ stopTimer();
eext_more_option_opened_set(*m_widget, toEina(isOpened));
}
{
return eext_more_option_opened_get(*m_widget);
}
+
+ void MoreOptionsPresenter::setOpenedDelayed(
+ const bool isOpened, const double timeout)
+ {
+ if (!resetTimer(timeout)) {
+ setOpened(isOpened);
+ } else {
+ m_newOpenedState = isOpened;
+ }
+ }
}
namespace gallery { namespace { namespace impl {
+ constexpr auto NAVIFRAME_TRANSITION_TIME_SEC = 0.3;
+
constexpr auto BRING_IN_SCROLL_FRICTION = 0.5;
constexpr auto PAGE_SCROLL_IN_FRICTION = 0.5;
void ThumbnailPage::onMoreOptionClicked(MoreOptionsPresenter &sender,
const MoreOption &option)
{
- sender.setOpened(false);
-
switch (option.id) {
case impl::MORE_OPTION_ID_DELETE:
+ sender.setOpenedDelayed(false, impl::NAVIFRAME_TRANSITION_TIME_SEC);
m_page = PreviewPage::Builder().
setNaviframe(asShared(getNaviframe())).
setAlbum(m_album).
build(DELEGATE(ThumbnailPage::onPageExitRequest, this));
break;
default:
+ sender.setOpened(false);
WLOG("Unknown option id: %d;", option.id);
break;
}
// Other //
constexpr auto HCOMB_SCROLL_LIMIT = 1000;
+
+ bool getImageSize(const Widget &image, int &w, int &h)
+ {
+ int tmpW = 0;
+ int tmpH = 0;
+
+ evas_object_image_size_get(image, &tmpW, &tmpH);
+
+ if ((tmpW <= 0) || (tmpH <= 0)) {
+ return false;
+ }
+
+ w = tmpW;
+ h = tmpH;
+
+ return true;
+ }
}}}
namespace gallery {
RefCountAware(&rc),
m_imageGrid(imageGrid),
m_btn(elm_button_add(parent)),
- m_image(elm_image_add(m_btn)),
+ m_image(evas_object_image_filled_add(m_btn.getEvas())),
m_realizeIndex(-1),
m_imageLoadSize(0),
m_wasUpdated(false),
+ m_isImageEmpty(false),
m_isClicksBlocked(false),
m_isSelected(false)
{
m_btn.setStyle(impl::ITEM_BTN_STYLE);
show(m_btn);
- elm_image_preload_disabled_set(m_image, EINA_FALSE);
- elm_image_aspect_fixed_set(m_image, EINA_TRUE);
- elm_image_fill_outside_set(m_image, EINA_TRUE);
m_btn.setContent(m_image);
show(m_image);
+ m_image.addEventHandler(WidgetEvent::IMAGE_PRELOADED,
+ WEAK_DELEGATE(Item::onImagePreloaded, asWeak(*this)));
+
m_btn.addEventHandler(BTN_CLICKED, WEAK_DELEGATE(
Item::onClicked, asWeak(*this)));
void setImageLoadSize(const int value)
{
m_imageLoadSize = value;
- elm_image_prescale_set(m_image, m_imageLoadSize);
+ evas_object_image_load_size_set(m_image,
+ m_imageLoadSize, m_imageLoadSize);
}
bool isRealized() const
if (isEmpty(params.imagePath)) {
if (!m_wasUpdated || (params.flags & UF_LOSE_IMAGE)) {
makeTransparent(m_image);
+ m_isImageEmpty = true;
}
return;
}
- elm_image_file_set(m_image, params.imagePath.c_str(), NULL);
+ makeTransparent(m_image);
+ m_isImageEmpty = false;
+
+ evas_object_image_file_set(m_image,
+ params.imagePath.c_str(), NULL);
+
+ evas_object_image_preload(m_image, EINA_FALSE);
+ }
+
+ void onImagePreloaded(Widget &widget, void *eventInfo)
+ {
+ if (m_isImageEmpty) {
+ return;
+ }
+
+ int w = 1;
+ int h = 1;
+ if (!impl::getImageSize(m_image, w, h)) {
+ WLOG("Invalid image size!");
+ }
+ m_image.setARHint(WidgetARHint::NEITHER, w, h);
makeWhite(m_image);
}
evas_object_image_file_set(*m_bgImage,
params.bgImagePath.c_str(), NULL);
- int w = 0;
- int h = 0;
- elm_image_object_size_get(m_image, &w, &h);
- if ((w == 0) || (h == 0)) {
+ int w = 1;
+ int h = 1;
+ if (!impl::getImageSize(m_image, w, h) &&
+ !impl::getImageSize(*m_bgImage, w, h)) {
WLOG("Invalid image size!");
- evas_object_image_size_get(*m_bgImage, &w, &h);
- if ((w == 0) || (h == 0)) {
- WLOG("Invalid image size!");
- w = 1;
- h = 1;
- }
}
m_bgImage->setARHint(WidgetARHint::NEITHER, w, h);
makeWhite(*m_bgImage);
}
- void onClicked(Widget &wifget, void *eventInfo)
+ void onClicked(Widget &widget, void *eventInfo)
{
if (isRealized()) {
m_imageGrid.handleItemEvent(m_realizeIndex,
int m_realizeIndex;
int m_imageLoadSize;
bool m_wasUpdated;
+ bool m_isImageEmpty;
bool m_isClicksBlocked;
bool m_isSelected;
};
int ImageGrid::calcScrollOffset()
{
- int scrollerX = 0;
- int scrollerY = 0;
- getPosition(*m_scroller, &scrollerX, &scrollerY);
-
- int boxX = 0;
- int boxY = 0;
- getPosition(m_box, &boxX, &boxY);
-
- int scrollOffset = (m_info.isHorizontal ?
- (scrollerX - boxX) : (scrollerY - boxY));
- if (scrollOffset < 0) {
- scrollOffset = 0;
- }
+ int scrollOffsetX = 0;
+ int scrollOffsetY = 0;
+ elm_scroller_region_get(*m_scroller, &scrollOffsetX, &scrollOffsetY,
+ nullptr, nullptr);
- return scrollOffset;
+ return (m_info.isHorizontal ? scrollOffsetX : scrollOffsetY);
}
bool ImageGrid::updateScrollOffset()