diff --git a/cinderblock.xml b/cinderblock.xml index 25591ca..71f6be1 100644 --- a/cinderblock.xml +++ b/cinderblock.xml @@ -18,6 +18,9 @@ src/debug/*.h src/debug/*.cpp + + src/utils/*.h + src/utils/*.cpp src diff --git a/samples/ViewAnimationsSample/include/Resources.h b/samples/ViewAnimationsSample/include/Resources.h new file mode 100644 index 0000000..d0e5c9f --- /dev/null +++ b/samples/ViewAnimationsSample/include/Resources.h @@ -0,0 +1,7 @@ +#pragma once +#include "cinder/CinderResources.h" + +//#define RES_MY_RES CINDER_RESOURCE( ../resources/, image_name.png, 128, IMAGE ) + + + diff --git a/samples/ViewAnimationsSample/resources/cinder_app_icon.ico b/samples/ViewAnimationsSample/resources/cinder_app_icon.ico new file mode 100644 index 0000000..b35fb85 Binary files /dev/null and b/samples/ViewAnimationsSample/resources/cinder_app_icon.ico differ diff --git a/samples/ViewAnimationsSample/src/ViewAnimationsSampleApp.cpp b/samples/ViewAnimationsSample/src/ViewAnimationsSampleApp.cpp new file mode 100644 index 0000000..adbb053 --- /dev/null +++ b/samples/ViewAnimationsSample/src/ViewAnimationsSampleApp.cpp @@ -0,0 +1,63 @@ +#include "cinder/app/App.h" +#include "cinder/app/RendererGl.h" +#include "cinder/gl/gl.h" +#include "BaseApp.h" +#include "SettingsManager.h" +#include "utils/ViewAnimations.h" + +using namespace ci; +using namespace ci::app; +using namespace std; +using namespace bluecadet::views; +using namespace bluecadet::utils; + +class ViewAnimationsSampleApp : public BaseApp { + public: + void setup() override; + void mouseDown( MouseEvent event ) override; + void mouseUp(MouseEvent event) override; + void update() override; + void draw() override; + static void prepareSettings(ci::app::App::Settings* settings); + + BaseViewRef testView; +}; + +void ViewAnimationsSampleApp::setup() +{ + BaseApp::setup(); + testView = BaseViewRef(new BaseView()); + testView->setSize(vec2(10, 10)); + testView->setPosition(vec2(5, 5)); + testView->setBackgroundColor(Color(1, 0, 0)); + mRootView->addChild(testView); +} + +void ViewAnimationsSampleApp::prepareSettings(ci::app::App::Settings* settings) { + BaseApp::prepareSettings(settings); + SettingsManager::getInstance()->mDebugFullscreen = false; + SettingsManager::getInstance()->mDebugWindowSize = vec2(200, 200); +} + +void ViewAnimationsSampleApp::mouseDown( MouseEvent event ) +{ + //ViewAnimations::fadeOut(testView, 0.5f); + testView->getTimeline()->apply(&testView->getAlpha(), 0.0f, 2.0f, EaseInExpo()); +} + +void ViewAnimationsSampleApp::mouseUp(MouseEvent event) +{ + ViewAnimations::fadeIn(testView, 0.5f); +} + +void ViewAnimationsSampleApp::update() +{ + BaseApp::update(); +} + +void ViewAnimationsSampleApp::draw() +{ + BaseApp::draw(); +} + +CINDER_APP( ViewAnimationsSampleApp, RendererGl ) diff --git a/samples/ViewAnimationsSample/vc2013/Resources.rc b/samples/ViewAnimationsSample/vc2013/Resources.rc new file mode 100644 index 0000000..282469b --- /dev/null +++ b/samples/ViewAnimationsSample/vc2013/Resources.rc @@ -0,0 +1,3 @@ +#include "../include/Resources.h" + +1 ICON "..\\resources\\cinder_app_icon.ico" diff --git a/samples/ViewAnimationsSample/vc2013/ViewAnimationsSample.sln b/samples/ViewAnimationsSample/vc2013/ViewAnimationsSample.sln new file mode 100644 index 0000000..66634c2 --- /dev/null +++ b/samples/ViewAnimationsSample/vc2013/ViewAnimationsSample.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ViewAnimationsSample", "ViewAnimationsSample.vcxproj", "{C4E27AC9-684D-40D2-A1AA-691A9949BAF9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C4E27AC9-684D-40D2-A1AA-691A9949BAF9}.Debug|x64.ActiveCfg = Debug|x64 + {C4E27AC9-684D-40D2-A1AA-691A9949BAF9}.Debug|x64.Build.0 = Debug|x64 + {C4E27AC9-684D-40D2-A1AA-691A9949BAF9}.Release|x64.ActiveCfg = Release|x64 + {C4E27AC9-684D-40D2-A1AA-691A9949BAF9}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/samples/ViewAnimationsSample/vc2013/ViewAnimationsSample.vcxproj b/samples/ViewAnimationsSample/vc2013/ViewAnimationsSample.vcxproj new file mode 100644 index 0000000..f0251e5 --- /dev/null +++ b/samples/ViewAnimationsSample/vc2013/ViewAnimationsSample.vcxproj @@ -0,0 +1,159 @@ + + + + Debug + x64 + + + Release + x64 + + + + {C4E27AC9-684D-40D2-A1AA-691A9949BAF9} + ViewAnimationsSample + Win32Proj + + + + Application + false + v120 + Unicode + true + + + Application + true + v120 + Unicode + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + true + false + + + + Disabled + ..\include;"..\..\..\..\..\include";..\..\..\..\Cinder-BluecadetText\src;..\..\..\..\Cinder-BluecadetTouch\src;..\..\..\..\Cinder-BluecadetUtils\src;..\..\..\src;..\..\..\..\OSC\src;..\..\..\..\TUIO\src + WIN32;_WIN32_WINNT=0x0601;_WINDOWS;NOMINMAX;_DEBUG;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + Level3 + ProgramDatabase + true + + + "..\..\..\..\..\include";..\include + + + cinder-$(PlatformToolset)_d.lib;OpenGL32.lib;%(AdditionalDependencies) + "..\..\..\..\..\lib\msw\$(PlatformTarget)" + true + Windows + false + + LIBCMT;LIBCPMT + + + + + ..\include;"..\..\..\..\..\include";..\..\..\..\Cinder-BluecadetText\src;..\..\..\..\Cinder-BluecadetTouch\src;..\..\..\..\Cinder-BluecadetUtils\src;..\..\..\src;..\..\..\..\OSC\src;..\..\..\..\TUIO\src + WIN32;_WIN32_WINNT=0x0601;_WINDOWS;NOMINMAX;NDEBUG;%(PreprocessorDefinitions) + MultiThreaded + + Level3 + ProgramDatabase + true + + + true + + + "..\..\..\..\..\include";..\include + + + cinder-$(PlatformToolset).lib;OpenGL32.lib;%(AdditionalDependencies) + "..\..\..\..\..\lib\msw\$(PlatformTarget)" + false + true + Windows + true + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/ViewAnimationsSample/vc2013/ViewAnimationsSample.vcxproj.filters b/samples/ViewAnimationsSample/vc2013/ViewAnimationsSample.vcxproj.filters new file mode 100644 index 0000000..a9b42e7 --- /dev/null +++ b/samples/ViewAnimationsSample/vc2013/ViewAnimationsSample.vcxproj.filters @@ -0,0 +1,229 @@ + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + {D37EAD5B-8C32-449E-B7AD-CE13726F44B4} + + + {00E985B6-B58D-4B3B-B63A-81A60F340846} + + + {F470D199-CD3D-472C-AF2B-34A29BA3CD2B} + + + {C7D0847E-52E0-44C5-946C-13E98345CB6D} + + + {69D1067F-0ABF-4AF9-8F81-40CAC0F123BA} + + + {D1FD2650-888A-45AC-989B-DE9918A42E34} + + + {5FCD7B82-F465-4219-96C3-797844F88293} + + + {4D0CF86A-58C3-4306-AB1A-316105C9AC07} + + + {44FBEF01-7D91-4EC3-8163-8274DCD2E89D} + + + {AB43C5F3-DE90-4266-9C7B-D6E3219414B9} + + + {919EA609-F7F1-4B6C-8942-54CBBB38DAF0} + + + {9030EC0A-6B6B-4222-A2FB-9AE26E946108} + + + {E39B6AF9-BD86-4ACD-9E02-171BAB2ADBBA} + + + {3AA6667F-06D6-4194-985C-B45191432385} + + + {4EF151AC-6030-4745-9615-468003479BFD} + + + {EEB8EF8E-1CD7-4703-A447-943BB94EC95C} + + + + + Source Files + + + Source Files + + + Header Files + + + Blocks\BluecadetText\src + + + Blocks\BluecadetText\src + + + Blocks\BluecadetText\src + + + Blocks\BluecadetText\src + + + Blocks\BluecadetText\src + + + Blocks\BluecadetText\src + + + Blocks\BluecadetText\src + + + Blocks\BluecadetText\src + + + Blocks\BluecadetText\src + + + Blocks\BluecadetTouch\src + + + Blocks\BluecadetTouch\src + + + Blocks\BluecadetTouch\src + + + Blocks\BluecadetTouch\src\drivers + + + Blocks\BluecadetTouch\src\drivers + + + Blocks\BluecadetTouch\src\drivers + + + Blocks\BluecadetTouch\src\drivers + + + Blocks\BluecadetTouch\src\drivers + + + Blocks\BluecadetTouch\src\drivers + + + Blocks\BluecadetTouch\src\drivers + + + Blocks\BluecadetTouch\src\drivers + + + Blocks\BluecadetUtils\src + + + Blocks\BluecadetUtils\src + + + Blocks\BluecadetUtils\src + + + Blocks\BluecadetUtils\src + + + Blocks\BluecadetViews\src + + + Blocks\BluecadetViews\src + + + Blocks\BluecadetViews\src + + + Blocks\BluecadetViews\src + + + Blocks\BluecadetViews\src + + + Blocks\BluecadetViews\src + + + Blocks\BluecadetViews\src + + + Blocks\BluecadetViews\src + + + Blocks\BluecadetViews\src + + + Blocks\BluecadetViews\src + + + Blocks\BluecadetViews\src + + + Blocks\BluecadetViews\src + + + Blocks\BluecadetViews\src + + + Blocks\BluecadetViews\src + + + Blocks\BluecadetViews\src + + + Blocks\BluecadetViews\src + + + Blocks\BluecadetViews\src\debug + + + Blocks\BluecadetViews\src\debug + + + Blocks\BluecadetViews\src\utils + + + Blocks\BluecadetViews\src\utils + + + Blocks\OSC\src + + + Blocks\OSC\src + + + Blocks\TUIO\src + + + Blocks\TUIO\src + + + + + Header Files + + + + + Resource Files + + + diff --git a/src/utils/ViewAnimations.cpp b/src/utils/ViewAnimations.cpp new file mode 100644 index 0000000..e2a7e91 --- /dev/null +++ b/src/utils/ViewAnimations.cpp @@ -0,0 +1,41 @@ +#include "ViewAnimations.h" + +using namespace ci; +using namespace ci::app; +using namespace std; + +namespace bluecadet { + namespace views { + + ViewAnimations::ViewAnimations() + { + } + + ViewAnimations::~ViewAnimations() { + } + + ci::Tween::Options ViewAnimations::fadeIn(BaseViewRef view, const float duration, const float delay, ci::EaseFn ease) + { + return view->getTimeline()->apply(&view->getAlpha(), 1.0f, duration, ease); + } + + ci::Tween::Options ViewAnimations::fadeOut(BaseViewRef view, const float duration, const float delay, ci::EaseFn ease) + { + return view->getTimeline()->apply(&view->getAlpha(), 0.0f, duration, ease); + } + + ci::Tween::Options ViewAnimations::fadeTo(BaseViewRef view, const float toVal, const float duration, const float delay, ci::EaseFn ease) + { + return view->getTimeline()->apply(&view->getAlpha(), toVal, duration, ease); + } + + ci::Tween::Options ViewAnimations::fade(BaseViewRef view, const float fromVal, const float toVal, const float duration, const float delay, ci::EaseFn ease) + { + return view->getTimeline()->apply(&view->getAlpha(), fromVal, toVal, duration, ease); + } + + // fadeIn(baseView, toValue = 1, duration = 1.0, delay = 1.0, easing) + + + } +} diff --git a/src/utils/ViewAnimations.h b/src/utils/ViewAnimations.h new file mode 100644 index 0000000..b56bd7f --- /dev/null +++ b/src/utils/ViewAnimations.h @@ -0,0 +1,27 @@ +#pragma once +#include "cinder/app/App.h" +#include "cinder/app/RendererGl.h" +#include "cinder/gl/gl.h" + +#include "BaseView.h" + +namespace bluecadet { + namespace views { + + typedef std::shared_ptr ViewAnimationsRef; + + class ViewAnimations { + + public: + ViewAnimations(); + virtual ~ViewAnimations(); + + static ci::Tween::Options fadeIn(BaseViewRef view, const float duration, const float delay = 0.0f, ci::EaseFn ease = ci::easeNone); + static ci::Tween::Options fadeOut(BaseViewRef view, const float duration, const float delay = 0.0f, ci::EaseFn ease = ci::easeNone); + static ci::Tween::Options fadeTo(BaseViewRef view, const float toVal, const float duration, const float delay = 0.0f, ci::EaseFn ease = ci::easeNone); + static ci::Tween::Options fade(BaseViewRef view, const float fromVal, const float toVal, const float duration, const float delay = 0.0f, ci::EaseFn ease = ci::easeNone); + + }; + + } +} \ No newline at end of file