OSDN Git Service

fix build system ofmoflib1 and saisei1
[moflib/moflib.git] / moflib-1.0 / src / mof / PlainWidgetView.cpp
1 #include "mof/PlainWidgetView.hpp"
2 #include "mof/GraphicsDevice.hpp"
3 #include "mof/Sprite.hpp"
4 #include "mof/mofAnimations.hpp"
5 #include "mof/Font.hpp"
6
7
8 struct mof::PlainWidgetView::Impl{
9     mof::Animation<mof::Matrix2D>::Handler transform;
10     mof::Animation<bool>::Handler visible;
11     mof::FrameNumber frame;
12     mof::Rectangle<int> bounds;
13     mof::Sprite* pCaption;
14     
15
16     Impl()
17         :  frame(0) , 
18         bounds(mof::Rectangle<int>(0 , 0 , 0 , 0)) , pCaption(NULL)
19     {
20     }
21
22     ~Impl(){
23         delete pCaption;
24     }
25 };
26
27
28 mof::PlainWidgetView::PlainWidgetView
29 (
30     mof::Color begin , mof::Color end
31 )
32 : m_pImpl( new Impl( ) )
33 {
34
35     
36     //m_pImpl->pFrame = new mof::Frame(m_pImpl->pGraphicsDevice , pTexture);
37     m_pImpl->transform = mof::makeConstantHandler(mof::Matrix2D::createIdentity());
38     {
39         //visible\82Ì\90Ý\92è
40         m_pImpl->visible = mof::makeConstantHandler(false);
41     }
42
43     //m_pImpl->pCaption = mof::Sprite::createTextSprite(pGraphicsDevice ,  mof::Font(mof::Font::MS_P_GOTHIC , 25) , title );
44 }
45         
46 mof::PlainWidgetView::~PlainWidgetView(){
47
48 }
49
50
51
52 void mof::PlainWidgetView::setBounds(const mof::Rectangle<int>& bounds){
53     m_pImpl->bounds = bounds;
54 }
55
56 mof::Rectangle<int> mof::PlainWidgetView::getBounds() const{
57     return m_pImpl->transform->getValue(m_pImpl->frame).toBoundingBox();
58 }
59
60
61
62 void mof::PlainWidgetView::focus(){
63
64 }
65         
66 void mof::PlainWidgetView::blur(){
67
68 }
69
70
71 void mof::PlainWidgetView::show(){
72     const int width = m_pImpl->bounds.endX - m_pImpl->bounds.beginX;
73     const int height = m_pImpl->bounds.endY - m_pImpl->bounds.beginY;
74
75     mof::Animation<mof::Matrix2D>::Handler list[] = {
76         mof::Animation<mof::Matrix2D>::Handler(mof::makeConstantHandler(mof::Matrix2D::createScaling(mof::Vector2D(width , height)))) ,
77         mof::Animation<mof::Matrix2D>::Handler(mof::makeConstantHandler(
78             mof::Matrix2D::createTranslation(mof::Vector2D(m_pImpl->bounds.beginX , m_pImpl->bounds.beginY))
79             )) 
80     };
81     m_pImpl->transform = mof::Animation<mof::Matrix2D>::Handler(new mof::CascadingAnimation<mof::Matrix2D>(list[0] , list[1]));
82     
83     {
84         //visible\82Ì\90Ý\92è
85         m_pImpl->visible = mof::makeConstantHandler(true);
86     }
87     m_pImpl->frame = 0;
88
89 }
90         
91 void mof::PlainWidgetView::close(){
92     const int width = m_pImpl->bounds.endX - m_pImpl->bounds.beginX;
93     const int height = m_pImpl->bounds.endY - m_pImpl->bounds.beginY;
94
95     mof::Animation<mof::Matrix2D>::Handler list[] = {
96         mof::Animation<mof::Matrix2D>::Handler(mof::makeConstantHandler(mof::Matrix2D::createScaling(mof::Vector2D(width , height)))) ,
97         mof::Animation<mof::Matrix2D>::Handler(mof::makeConstantHandler(
98             mof::Matrix2D::createTranslation(mof::Vector2D(m_pImpl->bounds.beginX , m_pImpl->bounds.beginY))
99             )) 
100     };
101     m_pImpl->transform = mof::Animation<mof::Matrix2D>::Handler(new mof::CascadingAnimation<mof::Matrix2D>(list[0] , list[1]));
102     
103     {
104         //visible\82Ì\90Ý\92è
105         mof::KeyFrameAnimation<bool>::KeyFrame keyFrames[] = {
106             mof::makeKeyFrame(0 , true) ,
107             mof::makeKeyFrame(20 , false) 
108         };
109         m_pImpl->visible = mof::Animation<bool>::Handler(
110             new mof::KeyFrameAnimation<bool>(keyFrames[0] , keyFrames[1] , &mof::stepInterpolate<bool> )
111             );
112     }
113     m_pImpl->frame = 0;
114 }
115
116
117
118 void mof::PlainWidgetView::update(){
119     m_pImpl->frame++;
120     //m_pImpl->pCaption->update();
121     
122 }
123         
124 void mof::PlainWidgetView::draw(){
125     if(m_pImpl->visible->getValue(m_pImpl->frame)){
126         //m_pImpl->pCaption->draw();
127     }
128 }