forked from organicmaps/organicmaps
[Tizen] After review. Added touch event.
This commit is contained in:
parent
6537100ba3
commit
cc6c86433e
12 changed files with 159 additions and 134 deletions
|
@ -4,36 +4,27 @@
|
|||
#include "../../../std/shared_ptr.hpp"
|
||||
|
||||
class Framework;
|
||||
|
||||
|
||||
namespace Tizen
|
||||
{
|
||||
namespace Ui
|
||||
{
|
||||
namespace Controls
|
||||
namespace Tizen{namespace Ui{namespace Controls
|
||||
{
|
||||
class Form;
|
||||
}
|
||||
}
|
||||
}
|
||||
}}}
|
||||
|
||||
namespace tizen
|
||||
{
|
||||
class RenderContext;
|
||||
class VideoTimer1;
|
||||
|
||||
class Framework: public noncopyable
|
||||
{
|
||||
public:
|
||||
Framework(Tizen::Ui::Controls::Form * form);
|
||||
virtual ~Framework();
|
||||
::Framework * GetInstance();
|
||||
|
||||
static ::Framework * GetInstance();
|
||||
void Draw();
|
||||
|
||||
private:
|
||||
static ::Framework * m_Instance;
|
||||
|
||||
VideoTimer1 * m_VideoTimer;
|
||||
|
||||
shared_ptr<RenderContext> m_context;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
#ifndef _MAPS_WITH_ME_APP_H_
|
||||
#define _MAPS_WITH_ME_APP_H_
|
||||
|
||||
#pragma once
|
||||
#include <FApp.h>
|
||||
#include <FBase.h>
|
||||
#include <FSystem.h>
|
||||
|
@ -15,49 +13,47 @@ class Framework;
|
|||
// The MapsWithMeApp class must inherit from the UiApp class,
|
||||
// which provides the basic features necessary to define a UI application.
|
||||
|
||||
class MapsWithMeApp
|
||||
: public Tizen::App::UiApp
|
||||
, public Tizen::System::IScreenEventListener
|
||||
class MapsWithMeApp : public Tizen::App::UiApp
|
||||
, public Tizen::System::IScreenEventListener
|
||||
{
|
||||
public:
|
||||
// The platform calls this method to create the application instance.
|
||||
static Tizen::App::UiApp* CreateInstance(void);
|
||||
MapsWithMeApp(void);
|
||||
virtual ~MapsWithMeApp(void);
|
||||
result Draw();
|
||||
// The platform calls this method to create the application instance.
|
||||
static Tizen::App::UiApp* CreateInstance(void);
|
||||
MapsWithMeApp(void);
|
||||
virtual ~MapsWithMeApp(void);
|
||||
result Draw();
|
||||
|
||||
private:
|
||||
// Called when the UI application is initializing.
|
||||
virtual bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry);
|
||||
// Called when the UI application is initializing.
|
||||
virtual bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry);
|
||||
|
||||
// Called when the UI application initialization is finished.
|
||||
virtual bool OnAppInitialized(void);
|
||||
// Called when the UI application initialization is finished.
|
||||
virtual bool OnAppInitialized(void);
|
||||
|
||||
// Called when the END key is pressed to terminate the UI application (if the device has the END key).
|
||||
virtual bool OnAppWillTerminate(void);
|
||||
// Called when the END key is pressed to terminate the UI application (if the device has the END key).
|
||||
virtual bool OnAppWillTerminate(void);
|
||||
|
||||
// Called when the UI application is terminating.
|
||||
virtual bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false);
|
||||
// Called when the UI application is terminating.
|
||||
virtual bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false);
|
||||
|
||||
// Called when the UI application's frame moves to the foreground.
|
||||
virtual void OnForeground(void);
|
||||
// Called when the UI application's frame moves to the foreground.
|
||||
virtual void OnForeground(void);
|
||||
|
||||
// Called when the UI application's frame is moved from the foreground to the background.
|
||||
virtual void OnBackground(void);
|
||||
// Called when the UI application's frame is moved from the foreground to the background.
|
||||
virtual void OnBackground(void);
|
||||
|
||||
// Called when system memory is no longer sufficient to run the UI application. Clean up unnecessary resources to release memory, or terminate the application.
|
||||
virtual void OnLowMemory(void);
|
||||
// Called when system memory is no longer sufficient to run the UI application. Clean up unnecessary resources to release memory, or terminate the application.
|
||||
virtual void OnLowMemory(void);
|
||||
|
||||
// Called when the battery level changes.
|
||||
virtual void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel);
|
||||
// Called when the battery level changes.
|
||||
virtual void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel);
|
||||
|
||||
// Called when the screen switches on.
|
||||
virtual void OnScreenOn(void);
|
||||
// Called when the screen switches on.
|
||||
virtual void OnScreenOn(void);
|
||||
|
||||
// Called when the screen switches off.
|
||||
virtual void OnScreenOff(void);
|
||||
// Called when the screen switches off.
|
||||
virtual void OnScreenOff(void);
|
||||
private:
|
||||
tizen::Framework * m_pFramework;
|
||||
tizen::Framework * m_pFramework;
|
||||
};
|
||||
|
||||
#endif // _MAPS_WITH_ME_APP_H_
|
||||
|
|
|
@ -1,18 +1,36 @@
|
|||
#pragma once
|
||||
|
||||
#include <FUi.h>
|
||||
#include <FUiITouchEventListener.h>
|
||||
|
||||
class MapsWithMeApp;
|
||||
|
||||
class MapsWithMeForm
|
||||
: public Tizen::Ui::Controls::Form
|
||||
{
|
||||
public:
|
||||
, public Tizen::Ui::ITouchEventListener
|
||||
{
|
||||
public:
|
||||
MapsWithMeForm(MapsWithMeApp* pApp);
|
||||
virtual ~MapsWithMeForm(void);
|
||||
|
||||
virtual result OnDraw(void);
|
||||
|
||||
private:
|
||||
MapsWithMeApp* __pApp;
|
||||
};
|
||||
// virtual void OnTouchCanceled (const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo)
|
||||
virtual void OnTouchFocusIn (const Tizen::Ui::Control &source,
|
||||
const Tizen::Graphics::Point ¤tPosition,
|
||||
const Tizen::Ui::TouchEventInfo &touchInfo);
|
||||
virtual void OnTouchFocusOut (const Tizen::Ui::Control &source,
|
||||
const Tizen::Graphics::Point ¤tPosition,
|
||||
const Tizen::Ui::TouchEventInfo &touchInfo);
|
||||
virtual void OnTouchMoved (const Tizen::Ui::Control &source,
|
||||
const Tizen::Graphics::Point ¤tPosition,
|
||||
const Tizen::Ui::TouchEventInfo &touchInfo);
|
||||
virtual void OnTouchPressed (const Tizen::Ui::Control &source,
|
||||
const Tizen::Graphics::Point ¤tPosition,
|
||||
const Tizen::Ui::TouchEventInfo &touchInfo);
|
||||
virtual void OnTouchReleased (const Tizen::Ui::Control &source,
|
||||
const Tizen::Graphics::Point ¤tPosition,
|
||||
const Tizen::Ui::TouchEventInfo &touchInfo);
|
||||
private:
|
||||
MapsWithMeApp* m_pApp;
|
||||
};
|
||||
|
|
|
@ -1,27 +1,24 @@
|
|||
#ifndef _MAPS_WITH_ME_FRAME_H_
|
||||
#define _MAPS_WITH_ME_FRAME_H_
|
||||
#pragma once
|
||||
|
||||
#include <FBase.h>
|
||||
#include <FUi.h>
|
||||
#include <FApp.h>
|
||||
|
||||
class MapsWithMeFrame
|
||||
: public Tizen::Ui::Controls::Frame
|
||||
, public Tizen::Ui::IPropagatedKeyEventListener
|
||||
class MapsWithMeFrame : public Tizen::Ui::Controls::Frame
|
||||
, public Tizen::Ui::IPropagatedKeyEventListener
|
||||
{
|
||||
public:
|
||||
MapsWithMeFrame(void);
|
||||
virtual ~MapsWithMeFrame(void);
|
||||
MapsWithMeFrame(void);
|
||||
virtual ~MapsWithMeFrame(void);
|
||||
|
||||
private:
|
||||
virtual result OnInitializing(void);
|
||||
virtual result OnTerminating(void);
|
||||
// key events for back-key
|
||||
virtual bool OnKeyPressed(Tizen::Ui::Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo) { return false; };
|
||||
virtual bool OnKeyReleased(Tizen::Ui::Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo);
|
||||
virtual bool OnPreviewKeyPressed(Tizen::Ui::Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo) { return false; };
|
||||
virtual bool OnPreviewKeyReleased(Tizen::Ui::Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo) { return false; };
|
||||
virtual bool TranslateKeyEventInfo(Tizen::Ui::Control& source, Tizen::Ui::KeyEventInfo& keyEventInfo) { return false; };
|
||||
virtual result OnInitializing(void);
|
||||
virtual result OnTerminating(void);
|
||||
// key events for back-key
|
||||
virtual bool OnKeyPressed(Tizen::Ui::Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo) { return false; };
|
||||
virtual bool OnKeyReleased(Tizen::Ui::Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo);
|
||||
virtual bool OnPreviewKeyPressed(Tizen::Ui::Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo) { return false; };
|
||||
virtual bool OnPreviewKeyReleased(Tizen::Ui::Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo) { return false; };
|
||||
virtual bool TranslateKeyEventInfo(Tizen::Ui::Control& source, Tizen::Ui::KeyEventInfo& keyEventInfo) { return false; };
|
||||
};
|
||||
|
||||
#endif //_MAPS_WITH_ME_FRAME_H_
|
||||
|
|
|
@ -1,16 +1,6 @@
|
|||
#pragma once
|
||||
#include "../../../graphics/opengl/gl_render_context.hpp"
|
||||
|
||||
namespace Tizen
|
||||
{
|
||||
namespace Ui
|
||||
{
|
||||
namespace Controls
|
||||
{
|
||||
class Form;
|
||||
}
|
||||
}
|
||||
}
|
||||
#include <FUi.h>
|
||||
|
||||
namespace tizen
|
||||
{
|
||||
|
@ -21,9 +11,7 @@ public:
|
|||
virtual ~RenderContext();
|
||||
|
||||
bool Init(::Tizen::Ui::Controls::Form * form);
|
||||
|
||||
void SwapBuffers();
|
||||
|
||||
virtual void makeCurrent();
|
||||
virtual RenderContext * createShared();
|
||||
private:
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <FBase.h>
|
||||
#include "../../../map/framework.hpp"
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace tizen
|
||||
{
|
||||
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
#include "Framework.hpp"
|
||||
#include "RenderContext.hpp"
|
||||
#include "VideoTimer.hpp"
|
||||
|
||||
#include <FBase.h>
|
||||
#include <FUi.h>
|
||||
|
||||
#include "../../../map/framework.hpp"
|
||||
#include "../../../map/render_policy.hpp"
|
||||
|
||||
#include "../../../graphics/defines.hpp"
|
||||
#include "../../../graphics/data_formats.hpp"
|
||||
|
||||
#include "../../../std/bind.hpp"
|
||||
#include "../../../platform/platform.hpp"
|
||||
|
||||
#include "RenderContext.hpp"
|
||||
#include "VideoTimer.hpp"
|
||||
#include "../../../std/bind.hpp"
|
||||
|
||||
namespace tizen
|
||||
{
|
||||
|
|
|
@ -1,28 +1,19 @@
|
|||
#include <new>
|
||||
#include "MapsWithMeApp.h"
|
||||
#include "MapsWithMeFrame.h"
|
||||
#include "MapsWithMeForm.hpp"
|
||||
#include "../../../base/logging.hpp"
|
||||
#include "Framework.hpp"
|
||||
#include "../../../base/logging.hpp"
|
||||
#include <FUi.h>
|
||||
|
||||
using namespace Tizen::App;
|
||||
using namespace Tizen::System;
|
||||
|
||||
MapsWithMeApp::MapsWithMeApp(void)
|
||||
{
|
||||
}
|
||||
MapsWithMeApp::MapsWithMeApp(void) {}
|
||||
|
||||
MapsWithMeApp::~MapsWithMeApp(void)
|
||||
{
|
||||
}
|
||||
MapsWithMeApp::~MapsWithMeApp(void) {}
|
||||
|
||||
UiApp*
|
||||
MapsWithMeApp::CreateInstance(void)
|
||||
{
|
||||
// Create the application instance through the constructor.
|
||||
return new (std::nothrow) MapsWithMeApp();
|
||||
}
|
||||
MapsWithMeApp::CreateInstance(void) {return new (std::nothrow) MapsWithMeApp();}
|
||||
|
||||
bool
|
||||
MapsWithMeApp::OnAppInitializing(AppRegistry& appRegistry)
|
||||
|
@ -48,6 +39,7 @@ MapsWithMeApp::OnAppInitializing(AppRegistry& appRegistry)
|
|||
TryReturn(pForm != null, false, "The memory is insufficient.");
|
||||
pForm->Construct(Tizen::Ui::Controls::FORM_STYLE_NORMAL);
|
||||
pMapsWithMeFrame->AddControl(pForm);
|
||||
pForm->AddTouchEventListener(*pForm);
|
||||
|
||||
m_pFramework = new tizen::Framework(pForm);
|
||||
|
||||
|
@ -61,10 +53,7 @@ result MapsWithMeApp::Draw()
|
|||
}
|
||||
|
||||
bool
|
||||
MapsWithMeApp::OnAppInitialized(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
MapsWithMeApp::OnAppInitialized(void) {return true;}
|
||||
|
||||
bool
|
||||
MapsWithMeApp::OnAppWillTerminate(void)
|
||||
|
@ -120,5 +109,4 @@ MapsWithMeApp::OnScreenOff(void)
|
|||
// Only perform quick operations in this event handler. Any lengthy operations can be risky;
|
||||
// for example, invoking a long asynchronous method within this event handler can cause problems
|
||||
// because the device can enter the sleep mode before the callback is invoked.
|
||||
|
||||
}
|
||||
|
|
|
@ -15,22 +15,21 @@ extern "C"
|
|||
//
|
||||
// The framework calls this method as the entry method of the Tizen application.
|
||||
//
|
||||
_EXPORT_ int
|
||||
OspMain(int argc, char* pArgv[])
|
||||
_EXPORT_ int OspMain(int argc, char* pArgv[])
|
||||
{
|
||||
AppLog("Application started.");
|
||||
ArrayList args(SingleObjectDeleter);
|
||||
args.Construct();
|
||||
for (int i = 0; i < argc; i++)
|
||||
{
|
||||
args.Add(new (std::nothrow) String(pArgv[i]));
|
||||
}
|
||||
AppLog("Application started.");
|
||||
ArrayList args(SingleObjectDeleter);
|
||||
args.Construct();
|
||||
for (int i = 0; i < argc; i++)
|
||||
{
|
||||
args.Add(new (std::nothrow) String(pArgv[i]));
|
||||
}
|
||||
|
||||
result r = Tizen::App::UiApp::Execute(MapsWithMeApp::CreateInstance, &args);
|
||||
TryLog(r == E_SUCCESS, "[%s] Application execution failed.", GetErrorMessage(r));
|
||||
AppLog("Application finished.");
|
||||
result r = Tizen::App::UiApp::Execute(MapsWithMeApp::CreateInstance, &args);
|
||||
TryLog(r == E_SUCCESS, "[%s] Application execution failed.", GetErrorMessage(r));
|
||||
AppLog("Application finished.");
|
||||
|
||||
return static_cast< int >(r);
|
||||
return static_cast< int >(r);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
#include "MapsWithMeForm.hpp"
|
||||
#include "MapsWithMeApp.h"
|
||||
#include "Framework.hpp"
|
||||
#include "../../../map/framework.hpp"
|
||||
|
||||
MapsWithMeForm::MapsWithMeForm(MapsWithMeApp* pApp)
|
||||
: __pApp(pApp)
|
||||
: m_pApp(pApp)
|
||||
{
|
||||
SetMultipointTouchEnabled(true);
|
||||
}
|
||||
|
||||
MapsWithMeForm::~MapsWithMeForm(void)
|
||||
|
@ -12,5 +15,45 @@ MapsWithMeForm::~MapsWithMeForm(void)
|
|||
|
||||
result MapsWithMeForm::OnDraw(void)
|
||||
{
|
||||
return __pApp->Draw();
|
||||
return m_pApp->Draw();
|
||||
}
|
||||
|
||||
void MapsWithMeForm::OnTouchPressed(const Tizen::Ui::Control& source,
|
||||
const Tizen::Graphics::Point& currentPosition,
|
||||
const Tizen::Ui::TouchEventInfo& touchInfo)
|
||||
{
|
||||
LOG(LINFO, ("OnTouchPressed"));
|
||||
::Framework * pFramework = tizen::Framework::GetInstance();
|
||||
pFramework->StartDrag(DragEvent(currentPosition.x, currentPosition.y));
|
||||
}
|
||||
|
||||
void MapsWithMeForm::OnTouchMoved(const Tizen::Ui::Control& source,
|
||||
const Tizen::Graphics::Point& currentPosition,
|
||||
const Tizen::Ui::TouchEventInfo& touchInfo)
|
||||
{
|
||||
::Framework * pFramework = tizen::Framework::GetInstance();
|
||||
pFramework->DoDrag(DragEvent(currentPosition.x, currentPosition.y));
|
||||
}
|
||||
|
||||
void MapsWithMeForm::OnTouchReleased(const Tizen::Ui::Control& source,
|
||||
const Tizen::Graphics::Point& currentPosition,
|
||||
const Tizen::Ui::TouchEventInfo& touchInfo)
|
||||
{
|
||||
::Framework * pFramework = tizen::Framework::GetInstance();
|
||||
pFramework->StopDrag(DragEvent(currentPosition.x, currentPosition.y));
|
||||
}
|
||||
|
||||
void MapsWithMeForm::OnTouchFocusIn(const Tizen::Ui::Control& source,
|
||||
const Tizen::Graphics::Point& currentPosition,
|
||||
const Tizen::Ui::TouchEventInfo& touchInfo)
|
||||
{
|
||||
}
|
||||
|
||||
void MapsWithMeForm::OnTouchFocusOut(const Tizen::Ui::Control& source,
|
||||
const Tizen::Graphics::Point& currentPosition,
|
||||
const Tizen::Ui::TouchEventInfo& touchInfo)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -14,34 +14,34 @@ MapsWithMeFrame::~MapsWithMeFrame(void)
|
|||
result
|
||||
MapsWithMeFrame::OnInitializing(void)
|
||||
{
|
||||
result r = E_SUCCESS;
|
||||
result r = E_SUCCESS;
|
||||
|
||||
// TODO: Add your frame initialization code here.
|
||||
// TODO: Add your frame initialization code here.
|
||||
|
||||
SetPropagatedKeyEventListener(this);
|
||||
return r;
|
||||
SetPropagatedKeyEventListener(this);
|
||||
return r;
|
||||
}
|
||||
|
||||
result
|
||||
MapsWithMeFrame::OnTerminating(void)
|
||||
{
|
||||
result r = E_SUCCESS;
|
||||
result r = E_SUCCESS;
|
||||
|
||||
// TODO: Add your frame termination code here.
|
||||
return r;
|
||||
// TODO: Add your frame termination code here.
|
||||
return r;
|
||||
}
|
||||
|
||||
bool
|
||||
MapsWithMeFrame::OnKeyReleased(Tizen::Ui::Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo)
|
||||
{
|
||||
KeyCode keyCode = keyEventInfo.GetKeyCode();
|
||||
KeyCode keyCode = keyEventInfo.GetKeyCode();
|
||||
|
||||
if (keyCode == KEY_BACK)
|
||||
{
|
||||
UiApp* pApp = UiApp::GetInstance();
|
||||
AppAssert(pApp);
|
||||
pApp->Terminate();
|
||||
}
|
||||
if (keyCode == KEY_BACK)
|
||||
{
|
||||
UiApp* pApp = UiApp::GetInstance();
|
||||
AppAssert(pApp);
|
||||
pApp->Terminate();
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -105,10 +105,12 @@ void RenderContext::SwapBuffers()
|
|||
void RenderContext::makeCurrent()
|
||||
{
|
||||
EGLBoolean b_res = eglMakeCurrent(m_display, m_surface, m_surface, m_context);
|
||||
|
||||
if (b_res == EGL_FALSE)
|
||||
{
|
||||
/// todo throw eglGetError();
|
||||
}
|
||||
eglSwapInterval(m_display, 1);
|
||||
}
|
||||
|
||||
RenderContext * RenderContext::createShared()
|
||||
|
|
Loading…
Add table
Reference in a new issue