nux-1.14.0
|
00001 #include "Nux/Nux.h" 00002 #include "Nux/TimelineEasings.h" 00003 #include "Nux/VLayout.h" 00004 #include "Nux/HLayout.h" 00005 #include "Nux/WindowThread.h" 00006 #include "Nux/Button.h" 00007 #include "Nux/ColorPreview.h" 00008 #include "Nux/TextureArea.h" 00009 #include "Nux/PaintLayer.h" 00010 00011 class TimelineTestClass 00012 { 00013 public: 00014 nux::Timeline *timeline_1; 00015 nux::Timeline *timeline_2; 00016 nux::TextureArea *texture_area; 00017 nux::TextureArea *texture_area_2; 00018 00019 void OnNewFrame (unsigned long msecs) 00020 { 00021 nux::Color color = nux::Color ((float)timeline_1->GetProgress (), 0.5, 0.6, 1.0); 00022 nux::ColorLayer *colorlayer = new nux::ColorLayer(color); 00023 texture_area->SetPaintLayer (colorlayer); 00024 } 00025 00026 void OnNewFrame2 (unsigned long msecs) 00027 { 00028 nux::Color color = nux::Color (0.6, (float)timeline_2->GetProgress (), 0.5, 1.0); 00029 nux::ColorLayer *colorlayer = new nux::ColorLayer(color); 00030 texture_area_2->SetPaintLayer (colorlayer); 00031 } 00032 00033 void Init (nux::Layout *layout) 00034 { 00035 texture_area = new nux::TextureArea (); 00036 00037 layout->AddView(texture_area, 1, nux::eCenter, nux::eFull); 00038 00039 texture_area_2 = new nux::TextureArea (); 00040 layout->AddView (texture_area_2, 1, nux::eCenter, nux::eFull); 00041 00042 timeline_1 = new nux::TimelineEaseInOutQuad (1000, "Timeline_1", NUX_TRACKER_LOCATION); 00043 timeline_1->Looping = true; 00044 timeline_1->NewFrame.connect (sigc::mem_fun (this, &TimelineTestClass::OnNewFrame)); 00045 00046 timeline_2 = new nux::TimelineEaseOutQuad (2000, "Timeline_2", NUX_TRACKER_LOCATION); 00047 //timeline_2->Looping = true; 00048 timeline_2->NewFrame.connect (sigc::mem_fun (this, &TimelineTestClass::OnNewFrame2)); 00049 } 00050 00051 }; 00052 00053 void ThreadWidgetInit(nux::NThread* thread, void* InitData) 00054 { 00055 TimelineTestClass *self = (TimelineTestClass*) InitData; 00056 nux::VLayout* MainVLayout = new nux::VLayout("", NUX_TRACKER_LOCATION); 00057 00058 self->Init (MainVLayout); 00059 MainVLayout->SetContentDistribution(nux::eStackCenter); 00060 00061 nux::GetWindowThread ()->SetLayout(MainVLayout); 00062 nux::ColorLayer background(nux::Color(0xFF4D4D4D)); 00063 static_cast<nux::WindowThread*>(thread)->SetWindowBackgroundPaintLayer(&background); 00064 } 00065 00066 00067 int main(int argc, char **argv) 00068 { 00069 TimelineTestClass *test_class = new TimelineTestClass (); 00070 nux::NuxInitialize(0); 00071 nux::WindowThread* wt = nux::CreateGUIThread(TEXT("Timeline Test"), 400, 300, 0, ThreadWidgetInit, test_class); 00072 00073 wt->Run(NULL); 00074 00075 delete wt; 00076 return 0; 00077 }