Add setUserIndex/getUserIndex (int index) to btCollisionShape
Share physics setup of BasicDemo between different graphics frameworks, see Demos\BasicDemo\BasicDemoPhysicsSetup.* Plan is to do this for all Bullet demos. Improve gwen performance and cursor navigation for tree control. tweak shadowmap size SimpleOpenGL3App::registerCubeShape accepts half extents
This commit is contained in:
@@ -105,6 +105,8 @@ void Base::Invalidate()
|
||||
{
|
||||
m_bNeedsLayout = true;
|
||||
m_bCacheTextureDirty = true;
|
||||
extern int avoidUpdate;
|
||||
avoidUpdate = -3;
|
||||
}
|
||||
|
||||
void Base::DelayedDelete()
|
||||
@@ -403,12 +405,13 @@ void Base::OnBoundsChanged(Gwen::Rect oldBounds)
|
||||
//Anything that needs to update on size changes
|
||||
//Iterate my children and tell them I've changed
|
||||
//
|
||||
if ( GetParent() )
|
||||
GetParent()->OnChildBoundsChanged( oldBounds, this );
|
||||
|
||||
|
||||
|
||||
if ( m_Bounds.w != oldBounds.w || m_Bounds.h != oldBounds.h )
|
||||
{
|
||||
if ( GetParent() )
|
||||
GetParent()->OnChildBoundsChanged( oldBounds, this );
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
@@ -694,6 +697,8 @@ void Base::Layout( Skin::Base* skin )
|
||||
skin->GetRender()->GetCTT()->CreateControlCacheTexture( this );
|
||||
}
|
||||
|
||||
int avoidUpdate = -15;
|
||||
|
||||
void Base::RecurseLayout( Skin::Base* skin )
|
||||
{
|
||||
if ( m_Skin ) skin = m_Skin;
|
||||
@@ -704,6 +709,10 @@ void Base::RecurseLayout( Skin::Base* skin )
|
||||
m_bNeedsLayout = false;
|
||||
Layout( skin );
|
||||
}
|
||||
|
||||
|
||||
if (avoidUpdate>0)
|
||||
return;
|
||||
|
||||
Gwen::Rect rBounds = GetRenderBounds();
|
||||
|
||||
@@ -713,13 +722,21 @@ void Base::RecurseLayout( Skin::Base* skin )
|
||||
rBounds.y += m_Padding.top;
|
||||
rBounds.h -= m_Padding.top + m_Padding.bottom;
|
||||
|
||||
int sz = Children.size();
|
||||
if (sz>100)
|
||||
{
|
||||
// printf("!\n");
|
||||
|
||||
}
|
||||
int curChild = 0;
|
||||
for (Base::List::iterator iter = Children.begin(); iter != Children.end(); ++iter)
|
||||
{
|
||||
Base* pChild = *iter;
|
||||
|
||||
curChild++;
|
||||
if ( pChild->Hidden() )
|
||||
continue;
|
||||
|
||||
|
||||
int iDock = pChild->GetDock();
|
||||
|
||||
if ( iDock & Pos::Fill )
|
||||
@@ -768,10 +785,12 @@ void Base::RecurseLayout( Skin::Base* skin )
|
||||
}
|
||||
|
||||
pChild->RecurseLayout( skin );
|
||||
|
||||
}
|
||||
|
||||
m_InnerBounds = rBounds;
|
||||
|
||||
curChild = 0;
|
||||
//
|
||||
// Fill uses the left over space, so do that now.
|
||||
//
|
||||
@@ -779,10 +798,12 @@ void Base::RecurseLayout( Skin::Base* skin )
|
||||
{
|
||||
Base* pChild = *iter;
|
||||
int iDock = pChild->GetDock();
|
||||
|
||||
curChild++;
|
||||
if ( !(iDock & Pos::Fill) )
|
||||
continue;
|
||||
|
||||
|
||||
|
||||
const Margin& margin = pChild->GetMargin();
|
||||
|
||||
pChild->SetBounds( rBounds.x + margin.left, rBounds.y + margin.top, rBounds.w - margin.left - margin.right, rBounds.h - margin.top - margin.bottom );
|
||||
|
||||
@@ -164,19 +164,43 @@ namespace Gwen
|
||||
virtual void RestrictToParent( bool restrict ) { m_bRestrictToParent = restrict; }
|
||||
virtual bool ShouldRestrictToParent() { return m_bRestrictToParent; }
|
||||
|
||||
virtual int X() const { return m_Bounds.x; }
|
||||
virtual int Y() const { return m_Bounds.y; }
|
||||
virtual int Width() const { return m_Bounds.w; }
|
||||
virtual int Height() const { return m_Bounds.h; }
|
||||
virtual int Bottom() const { return m_Bounds.y + m_Bounds.h + m_Margin.bottom; }
|
||||
virtual int Right() const { return m_Bounds.x + m_Bounds.w + m_Margin.right; }
|
||||
virtual int X() const
|
||||
{
|
||||
return m_Bounds.x;
|
||||
}
|
||||
virtual int Y() const
|
||||
{
|
||||
return m_Bounds.y;
|
||||
}
|
||||
virtual int Width() const
|
||||
{
|
||||
return m_Bounds.w;
|
||||
}
|
||||
virtual int Height() const
|
||||
{
|
||||
return m_Bounds.h;
|
||||
}
|
||||
virtual int Bottom() const
|
||||
{
|
||||
return m_Bounds.y + m_Bounds.h + m_Margin.bottom;
|
||||
}
|
||||
virtual int Right() const
|
||||
{
|
||||
return m_Bounds.x + m_Bounds.w + m_Margin.right;
|
||||
}
|
||||
|
||||
virtual const Margin& GetMargin() const { return m_Margin; }
|
||||
virtual const Padding& GetPadding() const { return m_Padding; }
|
||||
|
||||
virtual void SetPos( int x, int y );
|
||||
virtual void SetWidth( int w ) { SetSize( w, Height()); }
|
||||
virtual void SetHeight( int h ) { SetSize( Width(), h); }
|
||||
virtual void SetWidth( int w )
|
||||
{
|
||||
SetSize( w, Height());
|
||||
}
|
||||
virtual void SetHeight( int h )
|
||||
{
|
||||
SetSize( Width(), h);
|
||||
}
|
||||
virtual bool SetSize( int w, int h );
|
||||
virtual bool SetBounds( int x, int y, int w, int h );
|
||||
virtual bool SetBounds( const Gwen::Rect& bounds );
|
||||
@@ -188,7 +212,10 @@ namespace Gwen
|
||||
virtual void MoveTo (int x, int y );
|
||||
virtual void MoveBy (int x, int y );
|
||||
|
||||
virtual const Gwen::Rect& GetBounds() const { return m_Bounds; }
|
||||
virtual const Gwen::Rect& GetBounds() const
|
||||
{
|
||||
return m_Bounds;
|
||||
}
|
||||
|
||||
virtual Controls::Base* GetControlAt( int x, int y );
|
||||
|
||||
|
||||
@@ -61,6 +61,16 @@ namespace Gwen
|
||||
|
||||
Gwen::Event::Caller onBarMoved;
|
||||
|
||||
float getContentSize()
|
||||
{
|
||||
return m_fContentSize;
|
||||
}
|
||||
float getViewableContentSize() const
|
||||
{
|
||||
|
||||
return m_fViewableContentSize;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
ControlsInternal::ScrollBarButton* m_ScrollButton[2];
|
||||
|
||||
@@ -42,9 +42,14 @@ void TreeControl::Render( Skin::Base* skin )
|
||||
skin->DrawTreeControl( this );
|
||||
}
|
||||
|
||||
void TreeControl::ForceUpdateScrollBars()
|
||||
{
|
||||
m_ScrollControl->UpdateScrollBars();
|
||||
}
|
||||
|
||||
void TreeControl::OnChildBoundsChanged( Gwen::Rect /*oldChildBounds*/, Base* /*pChild*/ )
|
||||
{
|
||||
m_ScrollControl->UpdateScrollBars();
|
||||
//m_ScrollControl->UpdateScrollBars();
|
||||
}
|
||||
|
||||
void TreeControl::Clear()
|
||||
@@ -74,7 +79,7 @@ void TreeControl::OnNodeSelection( Controls::Base* /*control*/ )
|
||||
}
|
||||
|
||||
|
||||
void TreeControl::iterate(int action, int* curIndex, int* targetIndex)
|
||||
void TreeControl::iterate(int action, int* maxItem, int* curItem)
|
||||
{
|
||||
|
||||
Base::List& children = m_InnerPanel->GetChildren();
|
||||
@@ -83,7 +88,7 @@ void TreeControl::iterate(int action, int* curIndex, int* targetIndex)
|
||||
TreeNode* pChild = (*iter)->DynamicCastTreeNode();
|
||||
if ( !pChild )
|
||||
continue;
|
||||
pChild->iterate(action ,curIndex, targetIndex);
|
||||
pChild->iterate(action ,maxItem, curItem);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -93,26 +98,52 @@ bool TreeControl::OnKeyUp( bool bDown )
|
||||
{
|
||||
if (bDown)
|
||||
{
|
||||
ForceUpdateScrollBars();
|
||||
int maxIndex = 0;
|
||||
int newIndex = 0;
|
||||
int curIndex=0;
|
||||
int targetIndex=-1;
|
||||
iterate(ITERATE_ACTION_FIND_SELECTED_INDEX,&curIndex,&targetIndex);
|
||||
maxIndex = curIndex;
|
||||
if (targetIndex>0)
|
||||
int maxItem=0;
|
||||
int curItem=-1;
|
||||
iterate(ITERATE_ACTION_FIND_SELECTED_INDEX,&maxItem,&curItem);
|
||||
maxIndex = maxItem;
|
||||
int targetItem = curItem;
|
||||
if (curItem>0)
|
||||
{
|
||||
curIndex=0;
|
||||
int deselectIndex = targetIndex;
|
||||
targetIndex--;
|
||||
newIndex = targetIndex;
|
||||
iterate(ITERATE_ACTION_SELECT,&curIndex,&targetIndex);
|
||||
if (targetIndex<0)
|
||||
maxItem=0;
|
||||
int deselectIndex = targetItem;
|
||||
targetItem--;
|
||||
newIndex = targetItem;
|
||||
iterate(ITERATE_ACTION_SELECT,&maxItem,&targetItem);
|
||||
if (targetItem<0)
|
||||
{
|
||||
curIndex=0;
|
||||
iterate(ITERATE_ACTION_DESELECT_INDEX,&curIndex,&deselectIndex);
|
||||
maxItem=0;
|
||||
iterate(ITERATE_ACTION_DESELECT_INDEX,&maxItem,&deselectIndex);
|
||||
}
|
||||
curItem = newIndex;
|
||||
float amount = float(newIndex)/float(maxIndex);
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(amount,true);
|
||||
float viewSize = m_ScrollControl->m_VerticalScrollBar->getViewableContentSize();
|
||||
float contSize = m_ScrollControl->m_VerticalScrollBar->getContentSize();
|
||||
|
||||
float curAmount = m_ScrollControl->m_VerticalScrollBar->GetScrolledAmount();
|
||||
float minCoordViewableWindow = curAmount*contSize;
|
||||
float maxCoordViewableWindow = minCoordViewableWindow+viewSize;
|
||||
float minCoordSelectedItem = curItem*16.f;
|
||||
float maxCoordSelectedItem = (curItem+1)*16.f;
|
||||
{
|
||||
float newAmount = float(minCoordSelectedItem)/(contSize-viewSize);
|
||||
if (newAmount<curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
}
|
||||
}
|
||||
{
|
||||
int numItems = (viewSize)/16-1;
|
||||
float newAmount = float((curItem-numItems)*16)/(contSize-viewSize);
|
||||
|
||||
if (newAmount>curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -123,26 +154,52 @@ bool TreeControl::OnKeyDown( bool bDown )
|
||||
{
|
||||
if (bDown)
|
||||
{
|
||||
ForceUpdateScrollBars();
|
||||
int maxIndex = 0;
|
||||
int newIndex = 0;
|
||||
int curIndex=0;
|
||||
int targetIndex=-1;
|
||||
iterate(ITERATE_ACTION_FIND_SELECTED_INDEX,&curIndex,&targetIndex);
|
||||
maxIndex = curIndex;
|
||||
if (targetIndex>=0)
|
||||
int maxItem=0;
|
||||
int curItem=-1;
|
||||
iterate(ITERATE_ACTION_FIND_SELECTED_INDEX,&maxItem,&curItem);
|
||||
maxIndex = maxItem;
|
||||
int targetItem = curItem;
|
||||
if (curItem>=0)
|
||||
{
|
||||
curIndex=0;
|
||||
int deselectIndex = targetIndex;
|
||||
targetIndex++;
|
||||
newIndex = targetIndex;
|
||||
iterate(ITERATE_ACTION_SELECT,&curIndex,&targetIndex);
|
||||
if (targetIndex<0)
|
||||
maxItem=0;
|
||||
int deselectIndex = targetItem;
|
||||
targetItem++;
|
||||
newIndex = targetItem;
|
||||
iterate(ITERATE_ACTION_SELECT,&maxItem,&targetItem);
|
||||
if (targetItem<0)
|
||||
{
|
||||
curIndex=0;
|
||||
iterate(ITERATE_ACTION_DESELECT_INDEX,&curIndex,&deselectIndex);
|
||||
maxItem=0;
|
||||
iterate(ITERATE_ACTION_DESELECT_INDEX,&maxItem,&deselectIndex);
|
||||
}
|
||||
curItem= newIndex;
|
||||
float amount = (int)float(newIndex)/float(maxIndex);
|
||||
float viewSize = m_ScrollControl->m_VerticalScrollBar->getViewableContentSize();
|
||||
float contSize = m_ScrollControl->m_VerticalScrollBar->getContentSize();
|
||||
|
||||
float curAmount = m_ScrollControl->m_VerticalScrollBar->GetScrolledAmount();
|
||||
float minCoordViewableWindow = curAmount*contSize;
|
||||
float maxCoordViewableWindow = minCoordViewableWindow+viewSize;
|
||||
float minCoordSelectedItem = curItem*16.f;
|
||||
float maxCoordSelectedItem = (curItem+1)*16.f;
|
||||
{
|
||||
float newAmount = float(minCoordSelectedItem)/(contSize-viewSize);
|
||||
if (newAmount<curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
}
|
||||
}
|
||||
{
|
||||
int numItems = (viewSize)/16-1;
|
||||
float newAmount = float((curItem-numItems)*16)/(contSize-viewSize);
|
||||
|
||||
if (newAmount>curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
}
|
||||
}
|
||||
float amount = float(newIndex)/float(maxIndex);
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(amount,true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -153,12 +210,39 @@ bool TreeControl::OnKeyRight( bool bDown )
|
||||
{
|
||||
if (bDown)
|
||||
{
|
||||
extern int avoidUpdate;
|
||||
avoidUpdate = -3;
|
||||
ForceUpdateScrollBars();
|
||||
iterate(ITERATE_ACTION_OPEN,0,0);
|
||||
int curIndex=0;
|
||||
int targetIndex=0;
|
||||
iterate(ITERATE_ACTION_FIND_SELECTED_INDEX,&curIndex,&targetIndex);
|
||||
float amount = float(targetIndex)/float(curIndex);
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(amount,true);
|
||||
int maxItem=0;
|
||||
int curItem=0;
|
||||
iterate(ITERATE_ACTION_FIND_SELECTED_INDEX,&maxItem,&curItem);
|
||||
float amount = float(curItem)/float(maxItem);
|
||||
float viewSize = m_ScrollControl->m_VerticalScrollBar->getViewableContentSize();
|
||||
float contSize = m_ScrollControl->m_VerticalScrollBar->getContentSize();
|
||||
|
||||
float curAmount = m_ScrollControl->m_VerticalScrollBar->GetScrolledAmount();
|
||||
float minCoordViewableWindow = curAmount*contSize;
|
||||
float maxCoordViewableWindow = minCoordViewableWindow+viewSize;
|
||||
float minCoordSelectedItem = curItem*16.f;
|
||||
float maxCoordSelectedItem = (curItem+1)*16.f;
|
||||
{
|
||||
float newAmount = float(minCoordSelectedItem)/(contSize-viewSize);
|
||||
if (newAmount<curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
}
|
||||
}
|
||||
{
|
||||
int numItems = (viewSize)/16-1;
|
||||
float newAmount = float((curItem-numItems)*16)/(contSize-viewSize);
|
||||
|
||||
if (newAmount>curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
}
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -166,13 +250,51 @@ bool TreeControl::OnKeyLeft( bool bDown )
|
||||
{
|
||||
if (bDown)
|
||||
{
|
||||
extern int avoidUpdate;
|
||||
avoidUpdate = -3;
|
||||
|
||||
ForceUpdateScrollBars();
|
||||
|
||||
iterate(ITERATE_ACTION_CLOSE,0,0);
|
||||
|
||||
int curIndex=0;
|
||||
int targetIndex=0;
|
||||
iterate(ITERATE_ACTION_FIND_SELECTED_INDEX,&curIndex,&targetIndex);
|
||||
float amount = float(targetIndex)/float(curIndex);
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(amount,true);
|
||||
int maxItems=0;
|
||||
int curItem=0;
|
||||
iterate(ITERATE_ACTION_FIND_SELECTED_INDEX,&maxItems,&curItem);
|
||||
float amount = float(curItem)/float(maxItems);
|
||||
|
||||
// m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(amount,true);
|
||||
float viewSize = m_ScrollControl->m_VerticalScrollBar->getViewableContentSize();
|
||||
float contSize = m_ScrollControl->m_VerticalScrollBar->getContentSize();
|
||||
|
||||
float curAmount = m_ScrollControl->m_VerticalScrollBar->GetScrolledAmount();
|
||||
float minCoordViewableWindow = curAmount*contSize;
|
||||
float maxCoordViewableWindow = minCoordViewableWindow+viewSize;
|
||||
float minCoordSelectedItem = curItem*16.f;
|
||||
float maxCoordSelectedItem = (curItem+1)*16.f;
|
||||
|
||||
{
|
||||
float newAmount = float(minCoordSelectedItem)/(contSize-viewSize);
|
||||
if (newAmount<curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
}
|
||||
}
|
||||
{
|
||||
int numItems = (viewSize)/16-1;
|
||||
float newAmount = float((curItem-numItems)*16)/(contSize-viewSize);
|
||||
|
||||
if (newAmount>curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
//viewSize/contSize
|
||||
|
||||
printf("!\n");
|
||||
|
||||
//this->Layout(0);
|
||||
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace Gwen
|
||||
|
||||
virtual void iterate(int action,int* curIndex, int* resultIndex);
|
||||
|
||||
virtual void ForceUpdateScrollBars();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -73,6 +73,7 @@ void TreeNode::Render( Skin::Base* skin )
|
||||
|
||||
TreeNode* TreeNode::AddNode( const UnicodeString& strLabel )
|
||||
{
|
||||
int sz = sizeof(TreeNode);
|
||||
TreeNode* node = new TreeNode( this );
|
||||
node->SetText( strLabel );
|
||||
node->Dock( Pos::Top );
|
||||
@@ -112,9 +113,16 @@ void TreeNode::Layout( Skin::Base* skin )
|
||||
|
||||
BaseClass::Layout( skin );
|
||||
}
|
||||
|
||||
//too many calls to PostLayout...
|
||||
//int numCalls = 0xfd;
|
||||
void TreeNode::PostLayout( Skin::Base* /*skin*/ )
|
||||
{
|
||||
|
||||
//int bla = numCalls&0xffff;
|
||||
//if (bla==0)
|
||||
// printf("TreeNode::PostLayout numCalls = %d\n", numCalls);
|
||||
|
||||
//numCalls++;
|
||||
if ( SizeToChildren( false, true ) )
|
||||
{
|
||||
InvalidateParent();
|
||||
|
||||
Reference in New Issue
Block a user