00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "Teddy/PhysicalComponents/Dock.h"
00026 #include "Teddy/PhysicalComponents/Style.h"
00027 #include "Teddy/SysSupport/Messages.h"
00028 using namespace Teddy::SysSupport;
00029
00030
00031 #if defined( _MSC_VER )
00032 # include <limits>
00033 #else
00034 extern "C" {
00035 #include <limits.h>
00036 }
00037 #endif
00038
00039
00040 namespace Teddy {
00041 namespace PhysicalComponents {
00042
00043
00045 Dock::Dock( std::string name, const int axis )
00046 :
00047 Area ( name )
00048
00049
00050 {
00051 axis_sum = axis;
00052 axis_max = 1 - axis;
00053 event_ordering = separate_self;
00054 dmsg( M_WML, " %s->axis_sum = %d, axis_max = %d", this->getName().c_str(), axis_sum, axis_max );
00055 }
00056
00057
00058 Dock::~Dock(){
00059 }
00060
00061
00062 void Dock::beginSize( const Vector2 &ref ){
00063 dmsg( M_WML, "%s->Dock::beginSize( %f x %f )", this->getName().c_str(), ref[0], ref[1] );
00064 dmsg( M_WML, " %s->axis_sum = %d, axis_max = %d", this->getName().c_str(), axis_sum, axis_max );
00065 size = style->padding;
00066 }
00067
00068
00069 void Dock::callSize( Area *a ){
00070 dmsg( M_WML, "%s->Dock::callSize( %s ) = %...", this->getName().c_str(), a->getName().c_str() );
00071 Vector2 sub_size = a->doSize( size );
00072 dmsg( M_WML, " %s->Dock::callSize( %s ) = %f x %f", this->getName().c_str(), a->getName().c_str(), sub_size[0], sub_size[1] );
00073 size[axis_sum] += sub_size[axis_sum] + style->padding[axis_sum];
00074 size[axis_max] = MAX( size[axis_max], sub_size[axis_max] );
00075 dmsg( M_WML, " %s->size = %f x %f", this->getName().c_str(), a->getName().c_str(), size[0], size[1] );
00076 }
00077
00078
00079 void Dock::endSize(){
00080 size[axis_max] += 2 * style->padding[axis_max];
00081
00082 dmsg( M_WML, "%s->Dock::endSize( %f x %f )", this->getName().c_str(), size[0], size[1] );
00083 }
00084
00085
00086 void Dock::beginPlace( const Rect &ref ){
00087 dmsg( M_WML, "%s->Dock::beginPlace()", getName().c_str() );
00088 rect.min = ref.min + offset_pixels + ref.getSize() * offset_free_size_relative + size * offset_self_size_relative;
00089 rect.max = rect.min + size;
00090
00091 if( isEnabled(Area::USE_CLIP_TO_REFERENCE) ){
00092 rect.intersect( ref );
00093 }
00094
00095 in_rect = rect.shrink( style->padding );
00096
00097 cursor_start = rect.min + style->padding;
00098 cursor_end = rect.max - style->padding;
00099 }
00100
00101
00102 void Dock::callPlace( Area *a ){
00103 dmsg( M_WML, "%s->Dock::callPlace( %s )", this->getName().c_str(), a->getName().c_str() );
00104 dmsg( M_WML, " cursor_start = %f, %f", cursor_start[0], cursor_start[1] );
00105 Vector2 sub_size = a->doPlace( Rect(cursor_start,cursor_end) );
00106 cursor_start[axis_sum] += sub_size[axis_sum] + style->padding[axis_sum];
00107 dmsg( M_WML, " cursor_start = %f, %f", cursor_start[0], cursor_start[1] );
00108 }
00109
00110
00111 };
00112 };
00113