From: SeonhyungLee Date: Wed, 28 Aug 2013 13:19:22 +0000 (+0300) Subject: ui-core lib for window authoring tool X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fbaca4298fc84423f6e0dadc5e6437a2f592bddf;p=framework%2Fosp%2Fuifw.git ui-core lib for window authoring tool Change-Id: I1cdfdf52f0b0e9afb0c7f17593a7d0b1404e89ad --- diff --git a/src/ui-core/example/Linux/TestApplication.cpp b/src/ui-core/example/Linux/TestApplication.cpp index 29c62a8..7330051 100644 --- a/src/ui-core/example/Linux/TestApplication.cpp +++ b/src/ui-core/example/Linux/TestApplication.cpp @@ -10,6 +10,7 @@ int main(void) if (i == 1000) { IterateMainLoop(); + UpdateScreen(1.0f); } } diff --git a/src/ui-core/example/Win32/CMakeLists.txt b/src/ui-core/example/Win32/CMakeLists.txt index 6a47606..753e893 100644 --- a/src/ui-core/example/Win32/CMakeLists.txt +++ b/src/ui-core/example/Win32/CMakeLists.txt @@ -9,6 +9,8 @@ SET(${this_target}_SOURCE_FILES ) SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../libs) + ADD_EXECUTABLE(${this_target} ${${this_target}_SOURCE_FILES}) +ADD_DEPENDENCIES(${this_target} ui-core) -TARGET_LINK_LIBRARIES(${this_target} "-lui-core") +TARGET_LINK_LIBRARIES(${this_target} "-llibui-core") diff --git a/src/ui-core/example/Win32/TestApplication.cpp b/src/ui-core/example/Win32/TestApplication.cpp index fc1da44..db92afd 100644 --- a/src/ui-core/example/Win32/TestApplication.cpp +++ b/src/ui-core/example/Win32/TestApplication.cpp @@ -8,19 +8,27 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { - case WM_CLOSE: - InitLibrary((int)hwnd, 400, 400); - CreateVisualElement(0, 0, 200, 200); - UpdateScreen(1.0f); - DestroyWindow(hwnd); - break; + case WM_LBUTTONDOWN: + InitLibrary((int)hwnd, 400, 400); + CreateVisualElement(0, 0, 200, 200); + break; + + case WM_RBUTTONDOWN: + UpdateScreen(1.0f); + break; - case WM_DESTROY: - PostQuitMessage(0); + case WM_CLOSE: + DestroyWindow(hwnd); break; - default: - return DefWindowProc(hwnd, msg, wParam, lParam); + + case WM_DESTROY: + PostQuitMessage(0); + break; + + default: + return DefWindowProc(hwnd, msg, wParam, lParam); } + return 0; } diff --git a/src/ui-core/inc/UcInterface.h b/src/ui-core/inc/UcInterface.h index 5a1d278..908c04e 100644 --- a/src/ui-core/inc/UcInterface.h +++ b/src/ui-core/inc/UcInterface.h @@ -1,15 +1,21 @@ -#ifdef _WIN32 -#include "jni.h" -#include "jni_md.h" +#ifndef _UC_INTERFACE_H_ +#define _UC_INTERFACE_H_ + +// for win32, linux simulator +#define UCEXPORT __declspec(dllexport) -JNIEXPORT void JNICALL InitLibrary(int windowHandle, int width, int height); -JNIEXPORT void JNICALL CreateVisualElement(int x, int y, int width, int height); -JNIEXPORT void JNICALL ResizeWindow(int width, int height); -JNIEXPORT void JNICALL UpdateScreen(float delayedTime); -#else +#ifdef _WIN32 +extern "C" UCEXPORT void InitLibrary(int windowHandle, int width, int height); +extern "C" UCEXPORT void CreateVisualElement(int x, int y, int width, int height); +extern "C" UCEXPORT void ResizeWindow(int width, int height); +extern "C" UCEXPORT void UpdateScreen(float delayedTime); +extern "C" UCEXPORT void IterateMainLoop(void); +#elif LINUX void InitLibrary(int windowHandle, int width, int height); void CreateVisualElement(int x, int y, int width, int height); void ResizeWindow(int width, int height); void UpdateScreen(float delayedTime); void IterateMainLoop(void); #endif + +#endif // _UC_INTERFACE_H_ diff --git a/src/ui-core/inc/org_tizen_tools_areditor_sceneeditor_editor3d_NativeSceneEditor.h b/src/ui-core/inc/org_tizen_tools_areditor_sceneeditor_editor3d_NativeSceneEditor.h new file mode 100755 index 0000000..172dbbe --- /dev/null +++ b/src/ui-core/inc/org_tizen_tools_areditor_sceneeditor_editor3d_NativeSceneEditor.h @@ -0,0 +1,39 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_tizen_tools_areditor_sceneeditor_editor3d_NativeSceneEditor */ + +#ifndef _Included_org_tizen_tools_areditor_sceneeditor_editor3d_NativeSceneEditor +#define _Included_org_tizen_tools_areditor_sceneeditor_editor3d_NativeSceneEditor +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Class: org_tizen_tools_areditor_sceneeditor_editor3d_NativeSceneEditor + * Method: init + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_org_tizen_tools_areditor_sceneeditor_editor3d_NativeSceneEditor_init + (JNIEnv *, jobject, jint, jint, jint); + +/* + * Class: org_tizen_tools_areditor_sceneeditor_editor3d_NativeSceneEditor + * Method: resize + * Signature: (II)V + */ +JNIEXPORT void JNICALL Java_org_tizen_tools_areditor_sceneeditor_editor3d_NativeSceneEditor_resize + (JNIEnv *, jobject, jint, jint); + +/* + * Class: org_tizen_tools_areditor_sceneeditor_editor3d_NativeSceneEditor + * Method: repaint + * Signature: (F)V + */ +JNIEXPORT void JNICALL Java_org_tizen_tools_areditor_sceneeditor_editor3d_NativeSceneEditor_repaint + (JNIEnv *, jobject, jfloat); + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/ui-core/src/CMakeLists.txt b/src/ui-core/src/CMakeLists.txt index 1cf5220..2f63c91 100755 --- a/src/ui-core/src/CMakeLists.txt +++ b/src/ui-core/src/CMakeLists.txt @@ -155,6 +155,7 @@ ELSEIF(_WIN32) ADD_DEFINITIONS("-DVE_WIN32_GL -DBUILD_UI_CORE") LIST(APPEND ${this_target}_SOURCE_FILES + org_tizen_tools_areditor_sceneeditor_editor3d_NativesceneEditor.cpp ${UIFW_DIRECTORY}/src/ui/animations/platform/FUiAnim_Win32Window.cpp ) @@ -171,10 +172,12 @@ TARGET_LINK_LIBRARIES(${this_target} "-lrt" ) TARGET_LINK_LIBRARIES(${this_target} "-lX11" ) TARGET_LINK_LIBRARIES(${this_target} "-lXrender" ) TARGET_LINK_LIBRARIES(${this_target} "-ldl" ) -#TARGET_LINK_LIBRARIES(${this_target} "-lglib-2.0" ) TARGET_LINK_LIBRARIES(${this_target} "-lEGL" ) ELSEIF(_WIN32) + +SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--kill-at") + TARGET_LINK_LIBRARIES(${this_target} "-llibGLESv2" ) TARGET_LINK_LIBRARIES(${this_target} "-llibEGL" ) ENDIF(LINUX) diff --git a/src/ui-core/src/UcInterface.cpp b/src/ui-core/src/UcInterface.cpp index 614e25c..1cf3361 100644 --- a/src/ui-core/src/UcInterface.cpp +++ b/src/ui-core/src/UcInterface.cpp @@ -19,12 +19,9 @@ using namespace Tizen::Graphics; using namespace Tizen::Ui::Animations; -#ifdef LINUX _NativeLayer* pNativeLayer = null; -#elif _WIN32 -_GlLayer* pLayer = null; -#endif -DisplayContext* pDisplayContext = null; +DisplayContext* pContext = null; +VisualElement* pVisualElement = null; void InitLibrary(int windowHandle, int width, int height) { @@ -33,63 +30,54 @@ void InitLibrary(int windowHandle, int width, int height) #ifdef LINUX pNativeLayer = _NativeLayer::CreateInstanceN(); - pNativeLayer->SetShowState(true); - pDisplayContext = _DisplayContextImpl::CreatePublicInstance(*pNativeLayer); #elif _WIN32 _Win32Window* pWindow = new _Win32Window(windowHandle); + pNativeLayer = new _GlLayer(); + ((_GlLayer*)pNativeLayer)->ConstructForNativeWindow(*pWindow); +#endif - pLayer = new _GlLayer(); - pLayer->ConstructForNativeWindow(*pWindow); - pLayer->SetShowState(true); + pNativeLayer->SetShowState(true); - pDisplayContext = _DisplayContextImpl::CreatePublicInstance(*pLayer); -#endif + pContext = _DisplayContextImpl::CreatePublicInstance(*pNativeLayer); } void CreateVisualElement(int x, int y, int width, int height) { -#ifdef LINUX _RootVisualElement* pRoot = pNativeLayer->GetRootVisualElement(); -#elif _WIN32 - _RootVisualElement* pRoot = pLayer->GetRootVisualElement(); -#endif - VisualElement* pElement = new VisualElement(); - pElement->Construct(); - pElement->SetShowState(true); - pElement->SetBounds(FloatRectangle(x, y, width, height)); - pRoot->AttachChild(pElement); + pVisualElement = new VisualElement(); + pVisualElement->Construct(); + pVisualElement->SetShowState(true); + pVisualElement->SetBounds(FloatRectangle(x, y, width, height)); + pRoot->AttachChild(pVisualElement); //VisualElementSurface* pSurface = pElement->GetSurfaceN(); VisualElementSurface* pSurface = new VisualElementSurface(); - pSurface->Construct(*pDisplayContext, FloatDimension(100, 100)); + pSurface->Construct(*pContext, FloatDimension(100, 100)); BufferInfo bufferInfo; pSurface->GetBufferInfo(bufferInfo); -// memset(bufferInfo.pPixels, 0x7, bufferInfo.width * bufferInfo.height * 4); - - pElement->SetSurface(pSurface); + memset(bufferInfo.pPixels, 0xFF, bufferInfo.width * bufferInfo.height * 4); - pElement->Flush(); + pVisualElement->SetSurface(pSurface); } void ResizeWindow(int width, int height) { - //pNativeLayer->SetBounds(width, height); + pNativeLayer->SetBounds(FloatRectangle(0, 0, width, height)); } void UpdateScreen(float delayedTime) { -#ifdef _WIN32 - pLayer->Flush(); -#endif + pVisualElement->Flush(); + pNativeLayer->Flush(); } -void IterateMainLoop() +void IterateMainLoop(void) { #ifdef LINUX _Looper* pLooper = _Looper::GetInstance(); diff --git a/src/ui-core/src/org_tizen_tools_areditor_sceneeditor_editor3d_NativeSceneEditor.cpp b/src/ui-core/src/org_tizen_tools_areditor_sceneeditor_editor3d_NativeSceneEditor.cpp new file mode 100755 index 0000000..d7c9970 --- /dev/null +++ b/src/ui-core/src/org_tizen_tools_areditor_sceneeditor_editor3d_NativeSceneEditor.cpp @@ -0,0 +1,154 @@ +// jniSceneEditor.cpp : Defines the entry point for the console application. +// + +#include "FUiAnim_DisplayManager.h" +#include "FUiAnim_AnimationManager.h" +#include "FUiAnim_RootVisualElement.h" +#include "FUiAnimVisualElement.h" +#include "FUiAnimVisualElementSurface.h" +#include "FUiAnim_NativeLayer.h" +#include "FGrpFloatRectangle.h" +#include "FGrpBufferInfo.h" +#include "FUiAnimDisplayContext.h" +#include "FUiAnim_DisplayContextImpl.h" +#include "FUiAnim_NativeWindow.h" +#include "FUiAnim_Win32Window.h" +#include "FUiAnim_GlLayer.h" + +#include "org_tizen_tools_areditor_sceneeditor_editor3d_NativeSceneEditor.h" +#include + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; + +_NativeLayer* pNativeLayer = null; +DisplayContext* pContext = null; +VisualElement* pVisualElement = null; + +JNIEXPORT void JNICALL Java_org_tizen_tools_areditor_sceneeditor_editor3d_NativeSceneEditor_init + (JNIEnv *, jobject, jint handle, jint width, jint height){ + + #if 0 + //------------------------------ + // Please, insert your code here + //------------------------------ + + /*CreateContext ( (HWND)handle, width, height ); + // get the device context (DC) + gg_hDC = GetDC( (HWND)handle ); + //OnInit + ResourceManager* resourceManager = ResourceManager::GetInstance(); + __pScene = new Scene("Scene"); + + __pRenderSystem = new Tizen::Ui::Renderer::RenderSystem(); + __pRenderSystem->Create(); + __pRenderSystem->SetBackgroundColor(1.0f, 0.2f, 0.2f, 0.2f); + __pRenderSystem->InitViewport(0, 0, width, height, 45.0f, 0.1f, 1000.0f); + __pRenderSystem->UpdateScreen(); + + __pRenderSystem->GetCamera()->Perspective(45.0f, (float)width / height, 0.1f, 1000.0f); + __pRenderSystem->GetCamera()->LookAt(Vector3(0, 0, 100), Vector3(0, 0, 0), Vector3(0, 1, 0)); + + __pScene->Update(); + + FileSystem::ShaderPath = "Shaders/"; + FileSystem::MaterialPath = "Materials/"; + FileSystem::TexturePath = "Textures/"; + + + std::string ModelFileName1 = "ColladaModels/ColorCube.dae";//"../../../Demos/ColladaModels/ColorCube.dae"; + std::string ModelFileName2 = "ColladaModels/scorpion_.DAE";//"../../../Demos/ColladaModels/scorpion_.DAE"; + std::string ModelFileName3 = "ColladaModels/lizard_animation_1.DAE"; + std::string ModelFileName4 = "ColladaModels/astroBoy_walk_Maya.dae"; + + __pGrid.SetLines ( 5.0f, 10.0f, 50.0f ); + __pGrid.Create ( __pRenderSystem ); + GizmoManager::Setting(__pScene,__pRenderSystem); + + glEnable(GL_DEPTH_TEST);*/ +#endif + // + // Please remind that this code is only for testing... + // + + // Initialize + _AnimationManager::CreateInstance(); + _DisplayManager::CreateInstance(); + + _Win32Window* pWindow = new _Win32Window(handle); + + pNativeLayer = new _GlLayer(); + ((_GlLayer*)pNativeLayer)->ConstructForNativeWindow(*pWindow); + + pNativeLayer->SetShowState(true); + pContext = _DisplayContextImpl::CreatePublicInstance(*pNativeLayer); + + // Create a Visual Element + _RootVisualElement* pRoot = pNativeLayer->GetRootVisualElement(); + if (pRoot) + { + pVisualElement = new VisualElement(); + pVisualElement->Construct(); + pVisualElement->SetShowState(true); + pVisualElement->SetBounds(FloatRectangle(0, 0, 100, 100)); + pRoot->AttachChild(pVisualElement); + + VisualElementSurface* pSurface = new VisualElementSurface(); + pSurface->Construct(*pContext, FloatDimension(100, 100)); + + BufferInfo bufferInfo; + pSurface->GetBufferInfo(bufferInfo); + + // Set Pixels + memset(bufferInfo.pPixels, 0xFF, bufferInfo.width * bufferInfo.height * 4); + + pVisualElement->SetSurface(pSurface); + //pElement->Flush(); + } +} + +JNIEXPORT void JNICALL Java_org_tizen_tools_areditor_sceneeditor_editor3d_NativeSceneEditor_resize + (JNIEnv *, jobject, jint width, jint height){ + + //------------------------------ + // Please, insert your code here + //------------------------------ + + /*__pRenderSystem->InitViewport ( 0, 0, width, height); + __pRenderSystem->GetCamera()->Perspective(45.0f, (float)width / height, 0.1f, 1000.0f);*/ +} + +JNIEXPORT void JNICALL Java_org_tizen_tools_areditor_sceneeditor_editor3d_NativeSceneEditor_repaint + (JNIEnv *, jobject, jfloat dt){ + + //------------------------------ + // Please, insert your code here + //------------------------------ + + //////////////////////////////Update//////////////////////////////////////////////////// + /*float fElapsedTime = dt; + __pRenderSystem->SetProjectionMatrix(__pRenderSystem->GetCamera()->GetProjection()); + __pScene->Update(); + + Matrix4 mat; + mat.Identity(); + __pGrid.WorldMatrix = mat; + __pGrid.Update( fElapsedTime ); + + GizmoManager::Update(0,0); + + ///////////////////// Draw ////////////////////////////////////////////////////////////////////// + __pRenderSystem->Clear(ClearFlag::COLOR | ClearFlag::ZBUFFER | ClearFlag::STENCIL); + + __pScene->FindVisible(__pRenderSystem, __pScene->GetRootNodeScene()); + + __pRenderSystem->BeginRender(); + __pRenderSystem->RenderStages(); + __pRenderSystem->EndRender(); + + SwapBuffers(gg_hDC); + */ + pVisualElement->Flush(); + pNativeLayer->Flush(); +} + diff --git a/src/ui/animations/platform/FUiAnim_Win32Window.cpp b/src/ui/animations/platform/FUiAnim_Win32Window.cpp index f9f623d..e54b645 100644 --- a/src/ui/animations/platform/FUiAnim_Win32Window.cpp +++ b/src/ui/animations/platform/FUiAnim_Win32Window.cpp @@ -34,7 +34,7 @@ _Win32Window::~_Win32Window() Handle _Win32Window::OnConstructing() { - + return null; } void