1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
/*
* Copyright 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://floralicense.org/license/
*
* 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.
*/
#include "presenters/Page.h"
#include "common.h"
namespace callui { namespace { namespace impl {
constexpr SmartEvent TOP_PAGE_CHANGED {"ucl,top,page,changed"};
}}}
namespace callui {
using namespace ucl;
Page::Page(IRefCountObj &rc, const NaviframeSRef &navi,
const ExitRequestHandler &onExitRequest) :
GuiPresenter(rc),
m_navi(navi),
m_onExitRequest(onExitRequest)
{
UCL_ASSERT(navi, "navi is NULL!");
UCL_ASSERT(onExitRequest, "onExitRequest is NULL!");
deactivateBy(m_navi.get());
}
Page::~Page()
{
}
Result Page::preparePart2()
{
if (!m_item) {
UCL_LOG_RETURN(ucl::RES_FAIL, "m_item is NULL");
}
Evas_Object *content = m_item.getContent();
if (!content) {
LOG_RETURN(RES_FAIL, "content is NULL");
}
m_navi->addEventHandler(NAVI_TRANSITION_STARTED,
WEAK_DELEGATE(Page::onTransitionStarted, asWeak(*this)));
m_navi->addEventHandler(NAVI_TRANSITION_FINISHED,
WEAK_DELEGATE(Page::onTransitionFinished, asWeak(*this)));
m_navi->addEventHandler(impl::TOP_PAGE_CHANGED,
WEAK_DELEGATE(Page::onTopPageChanged, asWeak(*this)));
eext_object_event_callback_add(content, EEXT_CALLBACK_BACK,
CALLBACK_A(Page::onHWBackKey), this);
m_item.setData(this);
m_item.setDelCallback(CALLBACK_A(Page::onItemDel));
m_selfRef = asShared(*this);
if (!m_navi->isInTransition() && isAtTop()) {
dispatchTopPageChanged();
}
return RES_OK;
}
void Page::dispatchTopPageChanged()
{
if (!m_navi->isInTransition()) {
m_navi->callEvent(impl::TOP_PAGE_CHANGED, nullptr);
} else {
WLOG("Forcig Transition Finished!");
m_navi->setInTransition(false);
}
}
void Page::onItemDel(Evas_Object *obj, void *eventInfo)
{
m_item = nullptr;
m_selfRef.reset();
}
void Page::exit()
{
if (isAtTop() && !isAtBottom() && !m_navi->isInTransition()) {
m_navi->pop();
m_item = nullptr;
} else {
exitNoTransition();
}
}
void Page::exitNoTransition()
{
if (isAtTop()) {
m_item.del();
dispatchTopPageChanged();
} else if (m_item) {
m_item.del();
}
}
void Page::popTo()
{
if (m_item && !isAtTop()) {
m_item.popTo();
}
}
void Page::deleteTo()
{
if (m_item && !isAtTop()) {
while (!isAtTop()) {
m_navi->getTopItem().del();
}
dispatchTopPageChanged();
}
}
void Page::promote()
{
if (m_item && !isAtTop()) {
m_item.promote();
}
}
NaviItem Page::getItem()
{
return m_item;
}
void Page::requestExit()
{
if (m_onExitRequest) {
m_onExitRequest(*this);
} else {
WLOG("m_onExitRequest is NULL");
exit();
}
}
void Page::updateActiveState()
{
if (isAtTop()) {
activateBy(m_navi.get());
} else {
deactivateBy(m_navi.get());
}
}
void Page::onTransitionStarted(Widget &widget, void *eventInfo)
{
deactivateBy(m_navi.get());
}
void Page::onTransitionFinished(Widget &widget, void *eventInfo)
{
updateActiveState();
}
void Page::onTopPageChanged(Widget &widget, void *eventInfo)
{
updateActiveState();
}
void Page::onHWBackKey(Evas_Object *obj, void *eventInfo)
{
if (isActive()) {
onBackKey();
}
}
void Page::onBackKey()
{
requestExit();
}
}
|