OSDN Git Service

9fff1efae71c4880851f75c2685b5e4778293f27
[moflib/moflib.git] / moflib-1.0 / moflib / moflib / mof / widget / VerticalClipping.cpp
1 #pragma once
2 #include <mof/widget/VerticalClipping.hpp>
3 #include <mof/ConsoleIO.hpp>
4
5  
6 namespace mof
7 {
8 namespace widget
9 {
10 //{{{ constructor
11         VerticalClipping::VerticalClipping
12         (
13                 const mof::Manipulator<mof::Vector2D>::Handler& parentSize, 
14                 float initialChildSize, 
15                 float border
16         )
17                 : parentSize_(parentSize), initialChildSize_(initialChildSize), border_(border), initialParentSize_(parentSize->value(0).y)
18         {
19         }
20 //}}}
21 //{{{ destructor
22         VerticalClipping::~VerticalClipping() {}
23 //}}}
24 //{{{ value
25         mof::Vector2D VerticalClipping::value(mof::FrameNumber fn) const
26         {
27                 float currentParentSize = parentSize_->value(fn).y;
28                 float d = border_ + (currentParentSize - initialParentSize_);
29                 if (d > 0) return mof::Vector2D(0.0f, initialChildSize_);
30                 return initialChildSize_ + d < 0 ? mof::Vector2D(0, 0) : mof::Vector2D(0.0f, initialChildSize_ + d);
31         }
32 //}}}
33 }// namespace widget
34 }// namespace mof