LumaFrame.cpp
Go to the documentation of this file.
1 #include "LumaFrame.hpp"
2 
3 namespace iv
4 {
5 
7  iv::ProtectedSlot( inst ),
8  cm( inst, this, "LumaFrame" ),
9  attr_frame( &this->cm, iv::ResourcePath() ),
10  attr_frameWidth( &this->cm, 0.0f ),
11  attr_open( &this->cm, true ),
12  child( &this->cm, this, nullptr ),
13  anim( inst )
14 {
15  this->cm.inherits( this->iv::ProtectedSlot::cm );
16  this->cm.owns( this->anim.cm );
17 
18 //----------- visuals ---------------------
19  auto outer_prefsize = this->root.
20  createChild< iv::Prefsize >();
21 
22  /*
23  auto outer_prefsize = this->root.
24  createChild< iv::Border >()
25  ->borderLeft( 20 )
26  ->borderRight( 20 )
27  ->borderTop( 75 )
28  ->borderBottom( 75 )
29  ->createChild< iv::Align >()
30  ->dontExpand( true )
31  ->innerAnchor( iv::float3( 0.5f, 0.5f, 0.0f ) )
32  ->createChild< iv::Prefsize >()
33  ->prefsizeX( 400 );
34  */
35 
36  auto outer_slot = outer_prefsize->
37  createChild< iv::Slot >();
38 
39  this->border = outer_slot->createChild< iv::Border >();
40 
41  this->scroller = border->createChild< iv::LumaScroller >();
42 
43  this->img_frame = outer_slot->createChild< iv::Prefsize >()
44  ->prefsize( iv::float3( 0, 0, 0 ) )
45  ->createChild< iv::Image >()
46  ->resizeStage( iv::FlatShader::ResizeStage::Frame )
47  ->translucent( true );
48 
49 
50 //----------- animation -------------------
51  constexpr float OpenCloseTime_s = 0.3f;
52 
53  // source
54  iv::AnimNode< bool > * in_open = this->anim.Attribute_SourceNode( &this->attr_open, true )
55  ->label( "in_open" );
56 
57  // internal
58  iv::AnimNode< iv::float3 > * s_prefsize_scale = this->anim.Node< iv::float3 >( iv::float3( 0, 0, 0 ) )
59  ->label( "s_prefsize_scale" );
60 
61  // destination
62  iv::AnimNode< bool > * out_enabled = this->anim.Attribute_DestinationNode( &this->iv::ProtectedSlot::attr_enabled, false )
63  ->label( "out_enabled" )
64  ->Speed_inf();
65 
66  iv::AnimNode< iv::float3 > * out_prefsize_scale = this->anim.Attribute_DestinationNode( &outer_prefsize->attr_prefsizeScale, iv::float3( 1, 1, 1 ) )
67  ->label( "out_prefsize_scale" )
68  ->Speed( 1.0f / OpenCloseTime_s );
69 
70  // connectors
71  this->anim.Make_TimeTransform_Connector( iv::TimeTransform( iv::QuickstepTransform() ), s_prefsize_scale, out_prefsize_scale );
72 
73  this->connector = this->anim.Make_Lambda_Connector()
74  ->AddParent( in_open )
75  ->AddChild( out_enabled )
76  ->AddChild( s_prefsize_scale );
77 
78  this->connector->Retargeting(
79  [ in_open, s_prefsize_scale, out_enabled ]( bool warping )
80  {
81  out_enabled->Target( true );
82 
83  if( in_open->Target() )
84  s_prefsize_scale->Target( iv::float3( 1, 1, 1 ) );
85  else
86  s_prefsize_scale->Target( iv::float3( 1, 0.0001, 1 ) );
87  }
88  );
89 }
90 
92 {
93  this->scroller->child.Modify( &this->cm, this->child.Get() );
94 }
95 
97 {
98  if( this->attr_frame.clear_dirty() )
99  {
100  this->img_frame->filename( this->attr_frame.Get() );
101  }
102 
103  if( this->attr_frameWidth.clear_dirty() )
104  {
105  float width = this->attr_frameWidth.Get();
106  this->border->borderLeft( width );
107  this->border->borderRight( width );
108  this->border->borderTop( width );
109  this->border->borderBottom( width );
110  }
111 
112  this->ProtectedSlot::first_pass_impl( er );
113 }
114 
116 {
117  this->attr_frame.Set( val );
118  return this;
119 }
120 
122 {
123  this->attr_frameWidth.Set( val );
124  return this;
125 }
126 
128 {
129  this->attr_open.Set( val );
130  return this;
131 }
132 
133 }