2016-03-04 23:03:47 +00:00
# include "specter/RootView.hpp"
# include "specter/ViewResources.hpp"
# include "specter/Space.hpp"
# include "specter/Menu.hpp"
2015-11-21 01:14:49 +00:00
2016-03-04 23:03:47 +00:00
namespace specter
2015-11-21 23:45:02 +00:00
{
2016-03-04 23:03:47 +00:00
static logvisor : : Module Log ( " specter::RootView " ) ;
2015-11-21 01:14:49 +00:00
2015-12-06 01:24:51 +00:00
RootView : : RootView ( IViewManager & viewMan , ViewResources & res , boo : : IWindow * window )
2016-03-30 19:15:32 +00:00
: View ( res ) , m_window ( window ) , m_viewMan ( viewMan ) , m_viewRes ( & res ) , m_events ( * this )
2015-11-21 23:45:02 +00:00
{
2015-12-01 00:35:45 +00:00
window - > setCallback ( & m_events ) ;
2015-11-26 07:35:43 +00:00
boo : : SWindowRect rect = window - > getWindowFrame ( ) ;
2016-03-30 19:15:32 +00:00
commitResources ( res , [ & ] ( boo : : IGraphicsDataFactory : : Context & ctx ) - > bool
{
buildResources ( ctx , res ) ;
m_splitMenuSystem . emplace ( * this , ctx ) ;
m_renderTex = ctx . newRenderTexture ( rect . size [ 0 ] , rect . size [ 1 ] , true , false ) ;
return true ;
} ) ;
2015-12-01 00:35:45 +00:00
resized ( rect , rect ) ;
2015-11-26 23:03:56 +00:00
}
2016-03-30 19:15:32 +00:00
RootView : : SplitMenuSystem : : SplitMenuSystem ( RootView & rv , boo : : IGraphicsDataFactory : : Context & ctx )
2016-01-31 01:07:52 +00:00
: m_rv ( rv ) , m_text ( rv . m_viewMan . translateOr ( " boundary_action " , " Boundary Action " ) ) ,
m_splitActionNode ( * this ) , m_joinActionNode ( * this )
{
2016-07-27 02:18:17 +00:00
m_viewVertBlockBuf = ctx . newDynamicBuffer ( boo : : BufferUse : : Uniform , sizeof ( View : : ViewBlock ) , 1 ) ;
2016-03-30 19:15:32 +00:00
m_vertsBinding . initSolid ( ctx , * rv . m_viewRes , 32 , m_viewVertBlockBuf ) ;
2016-01-31 01:07:52 +00:00
2016-03-04 23:03:47 +00:00
zeus : : CColor col = { 0.0 , 0.0 , 0.0 , 0.5 } ;
2016-01-31 01:07:52 +00:00
for ( int i = 0 ; i < 32 ; + + i )
m_verts [ i ] . m_color = col ;
m_verts [ 0 ] . m_pos . assign ( 0.0 , 0.25 , 0 ) ;
m_verts [ 1 ] . m_pos . assign ( 0.0 , 0.0 , 0 ) ;
m_verts [ 2 ] . m_pos . assign ( 0.375 , 0.25 , 0 ) ;
m_verts [ 3 ] . m_pos . assign ( 0.375 , 0.0 , 0 ) ;
m_verts [ 4 ] . m_pos = m_verts [ 3 ] . m_pos ;
m_verts [ 5 ] . m_pos . assign ( 0.0 , 1.0 , 0 ) ;
m_verts [ 6 ] . m_pos = m_verts [ 5 ] . m_pos ;
m_verts [ 7 ] . m_pos = m_verts [ 0 ] . m_pos ;
m_verts [ 8 ] . m_pos . assign ( 0.5 , 1.0 , 0 ) ;
m_verts [ 9 ] . m_pos . assign ( 0.25 , 0.25 , 0 ) ;
m_verts [ 10 ] . m_pos . assign ( 0.5 , 0.5 , 0 ) ;
m_verts [ 11 ] . m_pos = m_verts [ 10 ] . m_pos ;
m_verts [ 12 ] . m_pos = m_verts [ 8 ] . m_pos ;
m_verts [ 13 ] . m_pos = m_verts [ 12 ] . m_pos ;
m_verts [ 14 ] . m_pos = m_verts [ 11 ] . m_pos ;
m_verts [ 15 ] . m_pos . assign ( 1.0 , 1.0 , 0 ) ;
m_verts [ 16 ] . m_pos . assign ( 1.0 , 0.25 , 0 ) ;
m_verts [ 17 ] . m_pos = m_verts [ 16 ] . m_pos ;
m_verts [ 18 ] . m_pos = m_verts [ 14 ] . m_pos ;
m_verts [ 19 ] . m_pos = m_verts [ 18 ] . m_pos ;
m_verts [ 20 ] . m_pos . assign ( 0.75 , 0.25 , 0 ) ;
m_verts [ 21 ] . m_pos = m_verts [ 17 ] . m_pos ;
m_verts [ 22 ] . m_pos = m_verts [ 21 ] . m_pos ;
m_verts [ 23 ] . m_pos . assign ( 0.625 , 0.25 , 0 ) ;
m_verts [ 24 ] . m_pos = m_verts [ 23 ] . m_pos ;
m_verts [ 25 ] . m_pos . assign ( 0.625 , 0.0 , 0 ) ;
m_verts [ 26 ] . m_pos = m_verts [ 22 ] . m_pos ;
m_verts [ 27 ] . m_pos . assign ( 1.0 , 0.0 , 0 ) ;
m_verts [ 28 ] . m_pos . assign ( - 1.0 , 1.0 , 0 ) ;
m_verts [ 29 ] . m_pos . assign ( - 1.0 , - 1.0 , 0 ) ;
m_verts [ 30 ] . m_pos . assign ( 1.0 , 1.0 , 0 ) ;
m_verts [ 31 ] . m_pos . assign ( 1.0 , - 1.0 , 0 ) ;
m_vertsBinding . load ( m_verts , sizeof ( m_verts ) ) ;
}
RootView : : SplitMenuSystem : : SplitActionNode : : SplitActionNode ( SplitMenuSystem & smn )
: m_smn ( smn ) , m_text ( smn . m_rv . m_viewMan . translateOr ( " split " , " Split " ) ) { }
RootView : : SplitMenuSystem : : JoinActionNode : : JoinActionNode ( SplitMenuSystem & smn )
: m_smn ( smn ) , m_text ( smn . m_rv . m_viewMan . translateOr ( " join " , " Join " ) ) { }
void RootView : : SplitMenuSystem : : setArrowVerts ( const boo : : SWindowRect & rect , SplitView : : ArrowDir dir )
{
const boo : : SWindowRect & root = m_rv . subRect ( ) ;
if ( dir = = SplitView : : ArrowDir : : Left | | dir = = SplitView : : ArrowDir : : Right )
{
m_viewBlock . m_mv [ 0 ] [ 1 ] = 2.0f * rect . size [ 1 ] / float ( root . size [ 1 ] ) ;
m_viewBlock . m_mv [ 0 ] [ 0 ] = 0.0f ;
m_viewBlock . m_mv [ 1 ] [ 0 ] = 2.0f * ( dir = = SplitView : : ArrowDir : : Left ? - rect . size [ 0 ] : rect . size [ 0 ] ) /
float ( root . size [ 0 ] ) ;
m_viewBlock . m_mv [ 1 ] [ 1 ] = 0.0f ;
m_viewBlock . m_mv [ 3 ] [ 0 ] = 2.0f * ( rect . location [ 0 ] + ( dir = = SplitView : : ArrowDir : : Left ? rect . size [ 0 ] : 0 ) ) /
float ( root . size [ 0 ] ) - 1.0f ;
m_viewBlock . m_mv [ 3 ] [ 1 ] = 2.0f * rect . location [ 1 ] / float ( root . size [ 1 ] ) - 1.0f ;
}
else
{
m_viewBlock . m_mv [ 0 ] [ 0 ] = 2.0f * rect . size [ 0 ] / float ( root . size [ 0 ] ) ;
m_viewBlock . m_mv [ 0 ] [ 1 ] = 0.0f ;
m_viewBlock . m_mv [ 1 ] [ 1 ] = 2.0f * ( dir = = SplitView : : ArrowDir : : Down ? - rect . size [ 1 ] : rect . size [ 1 ] ) /
float ( root . size [ 1 ] ) ;
m_viewBlock . m_mv [ 1 ] [ 0 ] = 0.0f ;
m_viewBlock . m_mv [ 3 ] [ 0 ] = 2.0f * rect . location [ 0 ] / float ( root . size [ 0 ] ) - 1.0f ;
m_viewBlock . m_mv [ 3 ] [ 1 ] = 2.0f * ( rect . location [ 1 ] + ( dir = = SplitView : : ArrowDir : : Down ? rect . size [ 1 ] : 0 ) ) /
float ( root . size [ 1 ] ) - 1.0f ;
}
m_viewVertBlockBuf - > load ( & m_viewBlock , sizeof ( m_viewBlock ) ) ;
}
void RootView : : SplitMenuSystem : : setLineVerts ( const boo : : SWindowRect & rect , float split , SplitView : : Axis axis )
{
const boo : : SWindowRect & root = m_rv . subRect ( ) ;
if ( axis = = SplitView : : Axis : : Horizontal )
{
m_viewBlock . m_mv [ 0 ] [ 0 ] = rect . size [ 0 ] / float ( root . size [ 0 ] ) ;
m_viewBlock . m_mv [ 0 ] [ 1 ] = 0.0f ;
m_viewBlock . m_mv [ 1 ] [ 1 ] = 2.0f / float ( root . size [ 1 ] ) ;
m_viewBlock . m_mv [ 1 ] [ 0 ] = 0.0f ;
m_viewBlock . m_mv [ 3 ] [ 0 ] = 2.0f * ( rect . location [ 0 ] + rect . size [ 0 ] / 2.0f ) / float ( root . size [ 0 ] ) - 1.0f ;
m_viewBlock . m_mv [ 3 ] [ 1 ] = ( rect . location [ 1 ] + split * rect . size [ 1 ] ) * m_viewBlock . m_mv [ 1 ] [ 1 ] - 1.0f ;
}
else
{
m_viewBlock . m_mv [ 0 ] [ 0 ] = 2.0f / float ( root . size [ 0 ] ) ;
m_viewBlock . m_mv [ 0 ] [ 1 ] = 0.0f ;
m_viewBlock . m_mv [ 1 ] [ 1 ] = rect . size [ 1 ] / float ( root . size [ 1 ] ) ;
m_viewBlock . m_mv [ 1 ] [ 0 ] = 0.0f ;
m_viewBlock . m_mv [ 3 ] [ 0 ] = ( rect . location [ 0 ] + split * rect . size [ 0 ] ) * m_viewBlock . m_mv [ 0 ] [ 0 ] - 1.0f ;
m_viewBlock . m_mv [ 3 ] [ 1 ] = 2.0f * ( rect . location [ 1 ] + rect . size [ 1 ] / 2.0f ) / float ( root . size [ 1 ] ) - 1.0f ;
}
m_viewVertBlockBuf - > load ( & m_viewBlock , sizeof ( m_viewBlock ) ) ;
}
2015-11-26 23:03:56 +00:00
void RootView : : destroyed ( )
{
m_destroyed = true ;
2015-11-21 23:45:02 +00:00
}
2015-11-27 22:20:22 +00:00
void RootView : : resized ( const boo : : SWindowRect & root , const boo : : SWindowRect & )
2015-11-26 23:03:56 +00:00
{
m_rootRect = root ;
2015-11-26 07:35:43 +00:00
m_rootRect . location [ 0 ] = 0 ;
m_rootRect . location [ 1 ] = 0 ;
2015-11-26 23:03:56 +00:00
View : : resized ( m_rootRect , m_rootRect ) ;
2016-01-04 23:58:38 +00:00
for ( View * v : m_views )
v - > resized ( m_rootRect , m_rootRect ) ;
2015-12-07 00:52:07 +00:00
if ( m_tooltip )
m_tooltip - > resized ( m_rootRect , m_rootRect ) ;
2016-01-29 04:30:04 +00:00
if ( m_rightClickMenu . m_view )
{
float wr = root . size [ 0 ] / float ( m_rightClickMenuRootAndLoc . size [ 0 ] ) ;
float hr = root . size [ 1 ] / float ( m_rightClickMenuRootAndLoc . size [ 1 ] ) ;
m_rightClickMenuRootAndLoc . size [ 0 ] = root . size [ 0 ] ;
m_rightClickMenuRootAndLoc . size [ 1 ] = root . size [ 1 ] ;
m_rightClickMenuRootAndLoc . location [ 0 ] * = wr ;
m_rightClickMenuRootAndLoc . location [ 1 ] * = hr ;
m_rightClickMenu . m_view - > resized ( root , m_rightClickMenuRootAndLoc ) ;
}
2016-03-30 19:15:32 +00:00
m_splitMenuSystem - > resized ( ) ;
2015-12-21 00:42:18 +00:00
m_resizeRTDirty = true ;
2015-11-21 23:45:02 +00:00
}
2016-01-31 01:07:52 +00:00
void RootView : : SplitMenuSystem : : resized ( )
{
if ( m_phase = = Phase : : InteractiveJoin )
{
boo : : SWindowRect rect ;
SplitView : : ArrowDir arrow ;
m_splitView - > getJoinArrowHover ( m_interactiveSlot , rect , arrow ) ;
setArrowVerts ( rect , arrow ) ;
}
else if ( m_phase = = Phase : : InteractiveSplit )
{
boo : : SWindowRect rect ;
SplitView : : Axis axis ;
m_splitView - > getSplitLineHover ( m_interactiveSlot , rect , axis ) ;
setLineVerts ( rect , m_interactiveSplit , axis ) ;
}
}
2015-11-21 23:45:02 +00:00
void RootView : : mouseDown ( const boo : : SWindowCoord & coord , boo : : EMouseButton button , boo : : EModifierKey mods )
{
2016-03-30 19:15:32 +00:00
if ( m_splitMenuSystem - > m_phase ! = SplitMenuSystem : : Phase : : Inactive )
2016-01-31 01:07:52 +00:00
{
2016-03-30 19:15:32 +00:00
m_splitMenuSystem - > mouseDown ( coord , button , mods ) ;
2016-01-31 01:07:52 +00:00
return ;
}
2016-01-28 23:55:19 +00:00
if ( m_rightClickMenu . m_view )
{
if ( ! m_rightClickMenu . mouseDown ( coord , button , mods ) )
m_rightClickMenu . m_view . reset ( ) ;
return ;
}
2016-01-15 23:32:14 +00:00
if ( m_activeMenuButton )
{
ViewChild < std : : unique_ptr < View > > & mv = m_activeMenuButton - > getMenu ( ) ;
if ( ! mv . mouseDown ( coord , button , mods ) )
m_activeMenuButton - > closeMenu ( coord ) ;
return ;
}
2016-01-12 00:44:54 +00:00
if ( m_hoverSplitDragView )
{
2016-01-29 04:30:04 +00:00
if ( button = = boo : : EMouseButton : : Primary )
{
m_activeSplitDragView = true ;
m_hoverSplitDragView - > startDragSplit ( coord ) ;
}
else if ( button = = boo : : EMouseButton : : Secondary )
{
2016-03-30 19:15:32 +00:00
m_splitMenuSystem - > m_splitView = m_hoverSplitDragView ;
adoptRightClickMenu ( std : : make_unique < specter : : Menu > ( * m_viewRes , * this , & * m_splitMenuSystem ) , coord ) ;
2016-01-29 04:30:04 +00:00
}
2016-01-12 00:44:54 +00:00
return ;
}
2015-12-20 21:59:23 +00:00
if ( m_activeTextView & & ! m_activeTextView - > subRect ( ) . coordInRect ( coord ) )
setActiveTextView ( nullptr ) ;
2016-01-04 23:58:38 +00:00
for ( View * v : m_views )
v - > mouseDown ( coord , button , mods ) ;
2015-11-21 23:45:02 +00:00
}
2016-01-31 01:07:52 +00:00
void RootView : : SplitMenuSystem : : mouseDown ( const boo : : SWindowCoord & coord , boo : : EMouseButton button , boo : : EModifierKey mods )
{
2016-02-01 01:12:30 +00:00
if ( m_phase = = Phase : : InteractiveJoin )
{
int origDummy ;
SplitView * selSplit ;
boo : : SWindowRect rect ;
SplitView : : ArrowDir arrow ;
if ( m_splitView - > testJoinArrowHover ( coord , origDummy , selSplit , m_interactiveSlot , rect , arrow ) )
{
setArrowVerts ( rect , arrow ) ;
m_interactiveDown = true ;
}
}
else if ( m_phase = = Phase : : InteractiveSplit )
{
boo : : SWindowRect rect ;
SplitView : : Axis axis ;
if ( m_splitView - > testSplitLineHover ( coord , m_interactiveSlot , rect , m_interactiveSplit , axis ) )
{
setLineVerts ( rect , m_interactiveSplit , axis ) ;
m_interactiveDown = true ;
}
}
2016-01-31 01:07:52 +00:00
}
2015-11-21 23:45:02 +00:00
void RootView : : mouseUp ( const boo : : SWindowCoord & coord , boo : : EMouseButton button , boo : : EModifierKey mods )
{
2016-03-30 19:15:32 +00:00
if ( m_splitMenuSystem - > m_phase ! = SplitMenuSystem : : Phase : : Inactive )
2016-01-31 01:07:52 +00:00
{
2016-03-30 19:15:32 +00:00
m_splitMenuSystem - > mouseUp ( coord , button , mods ) ;
2016-01-31 01:07:52 +00:00
return ;
}
2016-01-28 23:55:19 +00:00
if ( m_rightClickMenu . m_view )
{
m_rightClickMenu . mouseUp ( coord , button , mods ) ;
return ;
}
2016-01-15 23:32:14 +00:00
if ( m_activeMenuButton )
{
ViewChild < std : : unique_ptr < View > > & mv = m_activeMenuButton - > getMenu ( ) ;
mv . mouseUp ( coord , button , mods ) ;
return ;
}
2016-01-12 00:44:54 +00:00
if ( m_activeSplitDragView & & button = = boo : : EMouseButton : : Primary )
{
m_activeSplitDragView = false ;
m_hoverSplitDragView - > endDragSplit ( ) ;
m_spaceCornerHover = false ;
m_hSplitHover = false ;
m_vSplitHover = false ;
_updateCursor ( ) ;
}
2016-01-04 23:58:38 +00:00
for ( View * v : m_views )
v - > mouseUp ( coord , button , mods ) ;
2015-11-21 23:45:02 +00:00
}
2016-01-31 01:07:52 +00:00
void RootView : : SplitMenuSystem : : mouseUp ( const boo : : SWindowCoord & coord , boo : : EMouseButton button , boo : : EModifierKey mods )
{
2016-02-01 01:12:30 +00:00
if ( m_phase = = Phase : : InteractiveJoin )
{
int origSlot ;
SplitView * selSplit ;
boo : : SWindowRect rect ;
SplitView : : ArrowDir arrow ;
if ( m_splitView - > testJoinArrowHover ( coord , origSlot , selSplit , m_interactiveSlot , rect , arrow ) )
{
setArrowVerts ( rect , arrow ) ;
if ( m_interactiveDown )
{
m_interactiveDown = false ;
m_phase = Phase : : Inactive ;
m_splitView - > m_controller - > joinViews ( m_splitView , origSlot , selSplit , m_interactiveSlot ) ;
}
}
}
else if ( m_phase = = Phase : : InteractiveSplit )
{
boo : : SWindowRect rect ;
SplitView : : Axis axis ;
if ( m_splitView - > testSplitLineHover ( coord , m_interactiveSlot , rect , m_interactiveSplit , axis ) )
{
setLineVerts ( rect , m_interactiveSplit , axis ) ;
if ( m_interactiveDown )
{
m_interactiveDown = false ;
m_phase = Phase : : Inactive ;
Space * space = dynamic_cast < Space * > ( m_splitView - > m_views [ m_interactiveSlot ] . m_view ) ;
if ( space & & space - > m_controller . spaceSplitAllowed ( ) )
{
ISplitSpaceController * ss = space - > m_controller . spaceSplit ( axis , 0 ) ;
ss - > splitView ( ) - > setSplit ( m_interactiveSplit ) ;
}
}
}
}
2016-01-31 01:07:52 +00:00
}
2016-01-12 00:44:54 +00:00
SplitView * RootView : : recursiveTestSplitHover ( SplitView * sv , const boo : : SWindowCoord & coord ) const
{
if ( sv - > testSplitHover ( coord ) )
return sv ;
for ( int i = 0 ; i < 2 ; + + i )
{
SplitView * child = dynamic_cast < SplitView * > ( sv - > m_views [ i ] . m_view ) ;
if ( child )
{
SplitView * res = recursiveTestSplitHover ( child , coord ) ;
if ( res )
return res ;
}
}
return nullptr ;
}
2015-11-21 23:45:02 +00:00
void RootView : : mouseMove ( const boo : : SWindowCoord & coord )
{
2016-03-30 19:15:32 +00:00
if ( m_splitMenuSystem - > m_phase ! = SplitMenuSystem : : Phase : : Inactive )
2016-01-31 01:07:52 +00:00
{
2016-03-30 19:15:32 +00:00
m_splitMenuSystem - > mouseMove ( coord ) ;
2016-01-31 01:07:52 +00:00
return ;
}
2016-01-28 23:55:19 +00:00
if ( m_rightClickMenu . m_view )
{
2016-01-29 04:30:04 +00:00
m_hSplitHover = false ;
m_vSplitHover = false ;
_updateCursor ( ) ;
2016-01-28 23:55:19 +00:00
m_rightClickMenu . mouseMove ( coord ) ;
return ;
}
2016-01-15 23:32:14 +00:00
if ( m_activeMenuButton )
{
2016-01-29 04:30:04 +00:00
m_hSplitHover = false ;
m_vSplitHover = false ;
_updateCursor ( ) ;
2016-01-15 23:32:14 +00:00
ViewChild < std : : unique_ptr < View > > & mv = m_activeMenuButton - > getMenu ( ) ;
mv . mouseMove ( coord ) ;
return ;
}
2016-01-12 00:44:54 +00:00
if ( m_activeSplitDragView )
{
m_hoverSplitDragView - > moveDragSplit ( coord ) ;
m_spaceCornerHover = false ;
if ( m_hoverSplitDragView - > axis ( ) = = SplitView : : Axis : : Horizontal )
setHorizontalSplitHover ( true ) ;
else
setVerticalSplitHover ( true ) ;
return ;
}
m_hoverSplitDragView = nullptr ;
if ( ! m_spaceCornerHover )
{
for ( View * v : m_views )
{
SplitView * sv = dynamic_cast < SplitView * > ( v ) ;
if ( sv )
sv = recursiveTestSplitHover ( sv , coord ) ;
if ( sv )
{
m_hoverSplitDragView = sv ;
break ;
}
else
{
m_hSplitHover = false ;
m_vSplitHover = false ;
_updateCursor ( ) ;
}
}
}
2015-12-20 21:59:23 +00:00
if ( m_activeDragView )
m_activeDragView - > mouseMove ( coord ) ;
2016-01-04 23:58:38 +00:00
else
{
for ( View * v : m_views )
v - > mouseMove ( coord ) ;
}
2015-12-07 00:52:07 +00:00
2016-02-01 01:12:30 +00:00
if ( m_hoverSplitDragView )
{
if ( m_hoverSplitDragView - > axis ( ) = = SplitView : : Axis : : Horizontal )
setHorizontalSplitHover ( true ) ;
else
setVerticalSplitHover ( true ) ;
}
2015-12-07 00:52:07 +00:00
boo : : SWindowRect ttrect = m_rootRect ;
ttrect . location [ 0 ] = coord . pixel [ 0 ] ;
ttrect . location [ 1 ] = coord . pixel [ 1 ] ;
if ( m_tooltip )
{
if ( coord . pixel [ 0 ] + m_tooltip - > nominalWidth ( ) > m_rootRect . size [ 0 ] )
ttrect . location [ 0 ] - = m_tooltip - > nominalWidth ( ) ;
if ( coord . pixel [ 1 ] + m_tooltip - > nominalHeight ( ) > m_rootRect . size [ 1 ] )
ttrect . location [ 1 ] - = m_tooltip - > nominalHeight ( ) ;
m_tooltip - > resized ( m_rootRect , ttrect ) ;
}
2015-11-21 23:45:02 +00:00
}
2016-01-31 01:07:52 +00:00
void RootView : : SplitMenuSystem : : mouseMove ( const boo : : SWindowCoord & coord )
{
if ( m_phase = = Phase : : InteractiveJoin )
{
2016-02-01 01:12:30 +00:00
int origDummy ;
SplitView * selSplit ;
2016-01-31 01:07:52 +00:00
boo : : SWindowRect rect ;
SplitView : : ArrowDir arrow ;
2016-02-01 01:12:30 +00:00
if ( m_splitView - > testJoinArrowHover ( coord , origDummy , selSplit , m_interactiveSlot , rect , arrow ) )
2016-01-31 01:07:52 +00:00
setArrowVerts ( rect , arrow ) ;
}
else if ( m_phase = = Phase : : InteractiveSplit )
{
boo : : SWindowRect rect ;
SplitView : : Axis axis ;
if ( m_splitView - > testSplitLineHover ( coord , m_interactiveSlot , rect , m_interactiveSplit , axis ) )
setLineVerts ( rect , m_interactiveSplit , axis ) ;
}
}
2015-11-21 23:45:02 +00:00
void RootView : : mouseEnter ( const boo : : SWindowCoord & coord )
{
2016-01-04 23:58:38 +00:00
for ( View * v : m_views )
v - > mouseEnter ( coord ) ;
2015-11-21 23:45:02 +00:00
}
void RootView : : mouseLeave ( const boo : : SWindowCoord & coord )
{
2016-03-30 19:15:32 +00:00
if ( m_splitMenuSystem - > m_phase ! = SplitMenuSystem : : Phase : : Inactive )
2016-01-31 01:07:52 +00:00
{
2016-03-30 19:15:32 +00:00
m_splitMenuSystem - > mouseLeave ( coord ) ;
2016-01-31 01:07:52 +00:00
return ;
}
2016-01-28 23:55:19 +00:00
if ( m_rightClickMenu . m_view )
{
m_rightClickMenu . mouseLeave ( coord ) ;
return ;
}
2016-01-15 23:32:14 +00:00
if ( m_activeMenuButton )
{
ViewChild < std : : unique_ptr < View > > & mv = m_activeMenuButton - > getMenu ( ) ;
mv . mouseLeave ( coord ) ;
return ;
}
2016-01-04 23:58:38 +00:00
for ( View * v : m_views )
v - > mouseLeave ( coord ) ;
2015-11-21 23:45:02 +00:00
}
2016-01-31 01:07:52 +00:00
void RootView : : SplitMenuSystem : : mouseLeave ( const boo : : SWindowCoord & coord )
{
}
2015-11-21 23:45:02 +00:00
void RootView : : scroll ( const boo : : SWindowCoord & coord , const boo : : SScrollDelta & scroll )
{
2016-01-15 23:32:14 +00:00
if ( m_activeMenuButton )
{
ViewChild < std : : unique_ptr < View > > & mv = m_activeMenuButton - > getMenu ( ) ;
mv . scroll ( coord , scroll ) ;
return ;
}
2016-01-04 23:58:38 +00:00
for ( View * v : m_views )
v - > scroll ( coord , scroll ) ;
2015-11-21 23:45:02 +00:00
}
void RootView : : touchDown ( const boo : : STouchCoord & coord , uintptr_t tid )
{
2016-01-04 23:58:38 +00:00
for ( View * v : m_views )
v - > touchDown ( coord , tid ) ;
2015-11-21 23:45:02 +00:00
}
void RootView : : touchUp ( const boo : : STouchCoord & coord , uintptr_t tid )
{
2016-01-04 23:58:38 +00:00
for ( View * v : m_views )
v - > touchUp ( coord , tid ) ;
2015-11-21 23:45:02 +00:00
}
void RootView : : touchMove ( const boo : : STouchCoord & coord , uintptr_t tid )
{
2016-01-04 23:58:38 +00:00
for ( View * v : m_views )
v - > touchMove ( coord , tid ) ;
2015-11-21 23:45:02 +00:00
}
void RootView : : charKeyDown ( unsigned long charCode , boo : : EModifierKey mods , bool isRepeat )
{
2016-01-04 23:58:38 +00:00
for ( View * v : m_views )
v - > charKeyDown ( charCode , mods , isRepeat ) ;
2015-12-27 23:25:10 +00:00
if ( m_activeTextView & &
( mods & ( boo : : EModifierKey : : Ctrl | boo : : EModifierKey : : Command ) ) ! = boo : : EModifierKey : : None )
{
if ( charCode = = ' c ' | | charCode = = ' C ' )
m_activeTextView - > clipboardCopy ( ) ;
else if ( charCode = = ' x ' | | charCode = = ' X ' )
m_activeTextView - > clipboardCut ( ) ;
else if ( charCode = = ' v ' | | charCode = = ' V ' )
m_activeTextView - > clipboardPaste ( ) ;
}
2015-11-21 23:45:02 +00:00
}
void RootView : : charKeyUp ( unsigned long charCode , boo : : EModifierKey mods )
{
2016-01-04 23:58:38 +00:00
for ( View * v : m_views )
v - > charKeyUp ( charCode , mods ) ;
2015-11-21 23:45:02 +00:00
}
void RootView : : specialKeyDown ( boo : : ESpecialKey key , boo : : EModifierKey mods , bool isRepeat )
{
2015-12-02 06:13:43 +00:00
if ( key = = boo : : ESpecialKey : : Enter & & ( mods & boo : : EModifierKey : : Alt ) ! = boo : : EModifierKey : : None )
2015-12-20 04:39:09 +00:00
{
2015-12-02 06:13:43 +00:00
m_window - > setFullscreen ( ! m_window - > isFullscreen ( ) ) ;
2015-12-20 04:39:09 +00:00
return ;
}
2016-03-30 19:15:32 +00:00
if ( key = = boo : : ESpecialKey : : Esc & & m_splitMenuSystem - > m_phase ! = SplitMenuSystem : : Phase : : Inactive )
2016-02-01 20:04:29 +00:00
{
2016-03-30 19:15:32 +00:00
m_splitMenuSystem - > m_phase = SplitMenuSystem : : Phase : : Inactive ;
2016-02-01 20:04:29 +00:00
return ;
}
2016-01-04 23:58:38 +00:00
for ( View * v : m_views )
v - > specialKeyDown ( key , mods , isRepeat ) ;
2015-12-20 04:39:09 +00:00
if ( m_activeTextView )
m_activeTextView - > specialKeyDown ( key , mods , isRepeat ) ;
2015-11-21 23:45:02 +00:00
}
void RootView : : specialKeyUp ( boo : : ESpecialKey key , boo : : EModifierKey mods )
{
2016-01-04 23:58:38 +00:00
for ( View * v : m_views )
v - > specialKeyUp ( key , mods ) ;
2015-12-20 04:39:09 +00:00
if ( m_activeTextView )
m_activeTextView - > specialKeyUp ( key , mods ) ;
2015-11-21 23:45:02 +00:00
}
void RootView : : modKeyDown ( boo : : EModifierKey mod , bool isRepeat )
{
2016-01-04 23:58:38 +00:00
for ( View * v : m_views )
v - > modKeyDown ( mod , isRepeat ) ;
2015-12-20 04:39:09 +00:00
if ( m_activeTextView )
m_activeTextView - > modKeyDown ( mod , isRepeat ) ;
2015-11-21 23:45:02 +00:00
}
void RootView : : modKeyUp ( boo : : EModifierKey mod )
{
2016-01-04 23:58:38 +00:00
for ( View * v : m_views )
v - > modKeyUp ( mod ) ;
2015-12-20 04:39:09 +00:00
if ( m_activeTextView )
m_activeTextView - > modKeyUp ( mod ) ;
2015-11-21 23:45:02 +00:00
}
2015-12-13 02:26:41 +00:00
void RootView : : resetTooltip ( ViewResources & res )
{
m_tooltip . reset ( new Tooltip ( res , * this , " Test " , " Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi hendrerit nisl quis lobortis mattis. Mauris efficitur, est a vestibulum iaculis, leo orci pellentesque nunc, non rutrum ipsum lectus eget nisl. Aliquam accumsan vestibulum turpis. Duis id lacus ac lectus sollicitudin posuere vel sit amet metus. Aenean nec tortor id enim efficitur accumsan vitae eu ante. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce magna eros, lacinia a leo eget, volutpat rhoncus urna. " ) ) ;
}
2015-12-06 01:24:51 +00:00
void RootView : : displayTooltip ( const std : : string & name , const std : : string & help )
{
2015-12-02 21:11:50 +00:00
}
2016-01-31 01:07:52 +00:00
void RootView : : internalThink ( )
{
2016-03-30 19:15:32 +00:00
if ( m_splitMenuSystem - > m_deferredSplit )
2016-01-31 01:07:52 +00:00
{
2016-03-30 19:15:32 +00:00
m_splitMenuSystem - > m_deferredSplit = false ;
2016-01-31 01:07:52 +00:00
m_rightClickMenu . m_view . reset ( ) ;
2016-03-30 19:15:32 +00:00
m_splitMenuSystem - > m_phase = SplitMenuSystem : : Phase : : InteractiveSplit ;
m_splitMenuSystem - > mouseMove ( m_splitMenuSystem - > m_deferredCoord ) ;
2016-01-31 01:07:52 +00:00
}
2016-03-30 19:15:32 +00:00
if ( m_splitMenuSystem - > m_deferredJoin )
2016-01-31 01:07:52 +00:00
{
2016-03-30 19:15:32 +00:00
m_splitMenuSystem - > m_deferredJoin = false ;
2016-01-31 01:07:52 +00:00
m_rightClickMenu . m_view . reset ( ) ;
2016-03-30 19:15:32 +00:00
m_splitMenuSystem - > m_phase = SplitMenuSystem : : Phase : : InteractiveJoin ;
m_splitMenuSystem - > mouseMove ( m_splitMenuSystem - > m_deferredCoord ) ;
2016-01-31 01:07:52 +00:00
}
if ( m_rightClickMenu . m_view )
m_rightClickMenu . m_view - > think ( ) ;
}
2015-11-21 23:45:02 +00:00
void RootView : : draw ( boo : : IGraphicsCommandQueue * gfxQ )
2016-01-29 04:30:04 +00:00
{
2015-11-26 07:35:43 +00:00
if ( m_resizeRTDirty )
2015-11-26 23:03:56 +00:00
{
2015-11-26 07:35:43 +00:00
gfxQ - > resizeRenderTexture ( m_renderTex , m_rootRect . size [ 0 ] , m_rootRect . size [ 1 ] ) ;
2015-11-26 23:03:56 +00:00
m_resizeRTDirty = false ;
2015-12-21 00:42:18 +00:00
gfxQ - > schedulePostFrameHandler ( [ & ] ( ) { m_events . m_resizeCv . notify_one ( ) ; } ) ;
2015-11-26 23:03:56 +00:00
}
2015-11-26 07:35:43 +00:00
gfxQ - > setRenderTarget ( m_renderTex ) ;
gfxQ - > setViewport ( m_rootRect ) ;
2015-11-27 22:20:22 +00:00
gfxQ - > setScissor ( m_rootRect ) ;
2015-11-26 00:24:01 +00:00
View : : draw ( gfxQ ) ;
2016-01-04 23:58:38 +00:00
for ( View * v : m_views )
v - > draw ( gfxQ ) ;
2015-12-07 00:52:07 +00:00
if ( m_tooltip )
m_tooltip - > draw ( gfxQ ) ;
2016-03-30 19:15:32 +00:00
m_splitMenuSystem - > draw ( gfxQ ) ;
2016-01-28 23:55:19 +00:00
if ( m_rightClickMenu . m_view )
m_rightClickMenu . m_view - > draw ( gfxQ ) ;
2015-11-26 07:35:43 +00:00
gfxQ - > resolveDisplay ( m_renderTex ) ;
2015-11-21 23:45:02 +00:00
}
2016-01-31 01:07:52 +00:00
void RootView : : SplitMenuSystem : : draw ( boo : : IGraphicsCommandQueue * gfxQ )
{
2016-02-01 01:12:30 +00:00
if ( m_phase = = Phase : : Inactive )
2016-01-31 01:07:52 +00:00
return ;
gfxQ - > setShaderDataBinding ( m_vertsBinding ) ;
if ( m_phase = = Phase : : InteractiveJoin )
gfxQ - > draw ( 0 , 28 ) ;
else
gfxQ - > draw ( 28 , 4 ) ;
}
2015-11-21 23:45:02 +00:00
}