"svn:/svn.code.sf.net/p/irrlicht/code/trunk@5054" did not exist on "db604be1112a511a67429649f9f93b0348df4a25"
Commit d8676389 authored by cutealien's avatar cutealien

Fixed several selection, highlighting and clipping bugs in CGUITreeview (thx @...

Fixed several selection, highlighting and clipping bugs in CGUITreeview (thx @ AReichl for the patch + test)


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4910 dfc29bdd-3216-0410-991c-e03cc46cb475
parent aa082cbb
--------------------------
Changes in 1.9 (not yet released)
- Fixed several selection, highlighting and clipping bugs in CGUITreeview (thx @ AReichl for the patch + test)
- Removed DllMain from the static windows build (thx @ AReichl for reporting)
- Fixed maximize/minimize under Linux by supporting NETWM hints. Patch provided by hendu.
- ISceneNode::deserializeAttributes uses now old values for parameters which are not in the attributes (thx @entity for noticing).
......
// This file is part of the "Irrlicht Engine".
// written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de
// expaned by burningwater
// Written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de
// Expanded by burningwater
// Bugfixes by Michael Zeilfelder
// Bugfixes by Andreas Reichl
#include "CGUITreeView.h"
......@@ -453,11 +455,10 @@ CGUITreeView::CGUITreeView(IGUIEnvironment* environment, IGUIElement* parent,
{
ScrollBarV = new CGUIScrollBar( false, Environment, this, -1,
core::rect<s32>( RelativeRect.getWidth() - s,
0,
RelativeRect.getWidth(),
RelativeRect.getHeight() - (scrollBarHorizontal ? s : 0 )
),
!clip );
0,
RelativeRect.getWidth(),
RelativeRect.getHeight() - s
), !clip );
ScrollBarV->drop();
ScrollBarV->setSubElement(true);
......@@ -468,8 +469,11 @@ CGUITreeView::CGUITreeView(IGUIEnvironment* environment, IGUIElement* parent,
if ( scrollBarHorizontal )
{
ScrollBarH = new CGUIScrollBar( true, Environment, this, -1,
core::rect<s32>( 0, RelativeRect.getHeight() - s, RelativeRect.getWidth() - s, RelativeRect.getHeight() ),
!clip );
core::rect<s32>( 0,
RelativeRect.getHeight() - s,
RelativeRect.getWidth() - s,
RelativeRect.getHeight()
), !clip );
ScrollBarH->drop();
ScrollBarH->setSubElement(true);
......@@ -583,10 +587,24 @@ void CGUITreeView::recalculateItemHeight()
}
if ( ScrollBarV )
ScrollBarV->setMax( core::max_(0,TotalItemHeight - AbsoluteRect.getHeight()) );
{
s32 diffHor = TotalItemHeight - AbsoluteRect.getHeight();
if ( ScrollBarH )
{
diffHor += ScrollBarH->getAbsolutePosition().getHeight();
}
ScrollBarV->setMax( core::max_( 0, diffHor) );
}
if ( ScrollBarH )
ScrollBarH->setMax( core::max_(0, TotalItemWidth - AbsoluteRect.getWidth()) );
{
s32 diffVert = TotalItemWidth - AbsoluteRect.getWidth();
if ( ScrollBarV )
{
// TODO: not sure yet if it needs handling
}
ScrollBarH->setMax( core::max_( 0, diffVert ) );
}
}
......@@ -630,7 +648,6 @@ bool CGUITreeView::OnEvent( const SEvent &event )
break;
case EMIE_LMOUSE_PRESSED_DOWN:
if( ( ScrollBarV && ScrollBarV->getAbsolutePosition().isPointInside( p ) && ScrollBarV->OnEvent( event ) ) ||
( ScrollBarH && ScrollBarH->getAbsolutePosition().isPointInside( p ) && ScrollBarH->OnEvent( event ) )
)
......@@ -665,6 +682,7 @@ bool CGUITreeView::OnEvent( const SEvent &event )
}
}
break;
default:
break;
}
......@@ -697,9 +715,10 @@ void CGUITreeView::mouseAction( s32 xpos, s32 ypos, bool onlyHover /*= false*/ )
ypos -= AbsoluteRect.UpperLeftCorner.Y;
// find new selected item.
if( ItemHeight != 0 && ScrollBarV )
s32 scrollBarVPos = ScrollBarV ? ScrollBarV->getPos() : 0;
if( ItemHeight != 0 )
{
selIdx = ( ( ypos - 1 ) + ScrollBarV->getPos() ) / ItemHeight;
selIdx = ( ( ypos - 1 ) + scrollBarVPos ) / ItemHeight;
}
hitNode = 0;
......@@ -716,6 +735,8 @@ void CGUITreeView::mouseAction( s32 xpos, s32 ypos, bool onlyHover /*= false*/ )
++n;
}
s32 scrollBarHPos = ScrollBarH ? ScrollBarH->getPos() : 0;
xpos += scrollBarHPos; // correction for shift
if( hitNode && xpos > hitNode->getLevel() * IndentWidth )
{
Selected = hitNode;
......@@ -768,7 +789,6 @@ void CGUITreeView::mouseAction( s32 xpos, s32 ypos, bool onlyHover /*= false*/ )
}
}
//! draws the element and its children
void CGUITreeView::draw()
{
......@@ -789,42 +809,38 @@ void CGUITreeView::draw()
}
// draw background
core::rect<s32> frameRect( AbsoluteRect );
if( DrawBack )
{
driver->draw2DRectangle( skin->getColor( EGDC_3D_HIGH_LIGHT ), frameRect,
clipRect );
driver->draw2DRectangle( skin->getColor( EGDC_3D_HIGH_LIGHT ), frameRect, clipRect );
}
// draw the border
frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + 1;
driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), frameRect,
clipRect );
driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), frameRect, clipRect );
frameRect.LowerRightCorner.Y = AbsoluteRect.LowerRightCorner.Y;
frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + 1;
driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), frameRect,
clipRect );
driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), frameRect, clipRect );
frameRect = AbsoluteRect;
frameRect.UpperLeftCorner.X = frameRect.LowerRightCorner.X - 1;
driver->draw2DRectangle( skin->getColor( EGDC_3D_HIGH_LIGHT ), frameRect,
clipRect );
frameRect.UpperLeftCorner.X = frameRect.LowerRightCorner.X - 1;
driver->draw2DRectangle( skin->getColor( EGDC_3D_HIGH_LIGHT ), frameRect, clipRect );
frameRect = AbsoluteRect;
frameRect.UpperLeftCorner.Y = AbsoluteRect.LowerRightCorner.Y - 1;
frameRect.UpperLeftCorner.Y = AbsoluteRect.LowerRightCorner.Y - 1;
frameRect.LowerRightCorner.Y = AbsoluteRect.LowerRightCorner.Y;
driver->draw2DRectangle( skin->getColor( EGDC_3D_HIGH_LIGHT ), frameRect,
clipRect );
driver->draw2DRectangle( skin->getColor( EGDC_3D_HIGH_LIGHT ), frameRect, clipRect );
// draw items
core::rect<s32> clientClip( AbsoluteRect );
clientClip.UpperLeftCorner.Y += 1;
clientClip.UpperLeftCorner.X += 1;
clientClip.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X;
clientClip.UpperLeftCorner.X += 1;
clientClip.UpperLeftCorner.Y += 1;
clientClip.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X;
clientClip.LowerRightCorner.Y -= 1;
if ( ScrollBarV )
......@@ -843,7 +859,7 @@ void CGUITreeView::draw()
if ( ScrollBarV )
{
frameRect.UpperLeftCorner.Y -= ScrollBarV->getPos();
frameRect.UpperLeftCorner.Y -= ScrollBarV->getPos();
frameRect.LowerRightCorner.Y -= ScrollBarV->getPos();
}
......@@ -853,8 +869,7 @@ void CGUITreeView::draw()
frameRect.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X + 1 + node->getLevel() * IndentWidth;
if ( ScrollBarH )
{
frameRect.UpperLeftCorner.X -= ScrollBarH->getPos();
frameRect.LowerRightCorner.X -= ScrollBarH->getPos();
frameRect.UpperLeftCorner.X -= ScrollBarH->getPos();
}
if( frameRect.LowerRightCorner.Y >= AbsoluteRect.UpperLeftCorner.Y
......@@ -862,7 +877,10 @@ void CGUITreeView::draw()
{
if( node == Selected )
{
driver->draw2DRectangle( skin->getColor( EGDC_HIGH_LIGHT ), frameRect, &clientClip );
// selection box beginning from far left
core::rect<s32> copyFrameRect( frameRect ); // local copy to keep original untouched
copyFrameRect.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X + 1;
driver->draw2DRectangle( skin->getColor( EGDC_HIGH_LIGHT ), copyFrameRect, &clientClip );
}
if( node->hasChildren() )
......@@ -880,40 +898,35 @@ void CGUITreeView::draw()
rc.UpperLeftCorner.Y = expanderRect.UpperLeftCorner.Y;
rc.LowerRightCorner.X = expanderRect.LowerRightCorner.X;
rc.LowerRightCorner.Y = rc.UpperLeftCorner.Y + 1;
driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), rc,
clipRect );
driver->draw2DRectangle( skin->getColor( EGDC_3D_DARK_SHADOW ), rc, clipRect );
// box left line
rc.UpperLeftCorner.X = expanderRect.UpperLeftCorner.X;
rc.UpperLeftCorner.Y = expanderRect.UpperLeftCorner.Y;
rc.LowerRightCorner.X = rc.UpperLeftCorner.X + 1;
rc.LowerRightCorner.Y = expanderRect.LowerRightCorner.Y;
driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), rc,
clipRect );
driver->draw2DRectangle( skin->getColor( EGDC_3D_DARK_SHADOW ), rc, clipRect );
// box right line
rc.UpperLeftCorner.X = expanderRect.LowerRightCorner.X - 1;
rc.UpperLeftCorner.Y = expanderRect.UpperLeftCorner.Y;
rc.LowerRightCorner.X = rc.UpperLeftCorner.X + 1;
rc.LowerRightCorner.Y = expanderRect.LowerRightCorner.Y;
driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), rc,
clipRect );
driver->draw2DRectangle( skin->getColor( EGDC_3D_DARK_SHADOW ), rc, clipRect );
// box bottom line
rc.UpperLeftCorner.X = expanderRect.UpperLeftCorner.X;
rc.UpperLeftCorner.Y = expanderRect.LowerRightCorner.Y - 1;
rc.LowerRightCorner.X = expanderRect.LowerRightCorner.X;
rc.LowerRightCorner.Y = rc.UpperLeftCorner.Y + 1;
driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), rc,
clipRect );
driver->draw2DRectangle( skin->getColor( EGDC_3D_DARK_SHADOW ), rc, clipRect );
// horizontal '-' line
rc.UpperLeftCorner.X = expanderRect.UpperLeftCorner.X + 2;
rc.UpperLeftCorner.Y = expanderRect.UpperLeftCorner.Y + ( expanderRect.getHeight() >> 1 );
rc.LowerRightCorner.X = rc.UpperLeftCorner.X + expanderRect.getWidth() - 4;
rc.LowerRightCorner.Y = rc.UpperLeftCorner.Y + 1;
driver->draw2DRectangle( skin->getColor( EGDC_BUTTON_TEXT ), rc,
clipRect );
driver->draw2DRectangle( skin->getColor( EGDC_BUTTON_TEXT ), rc, clipRect );
if( !node->getExpanded() )
{
......@@ -922,8 +935,7 @@ void CGUITreeView::draw()
rc.UpperLeftCorner.Y = expanderRect.UpperLeftCorner.Y + 2;
rc.LowerRightCorner.X = rc.UpperLeftCorner.X + 1;
rc.LowerRightCorner.Y = rc.UpperLeftCorner.Y + expanderRect.getHeight() - 4;
driver->draw2DRectangle( skin->getColor( EGDC_BUTTON_TEXT ), rc,
clipRect );
driver->draw2DRectangle( skin->getColor( EGDC_BUTTON_TEXT ), rc, clipRect );
}
}
......@@ -989,8 +1001,7 @@ void CGUITreeView::draw()
rc.LowerRightCorner.X = frameRect.UpperLeftCorner.X - 2;
}
rc.LowerRightCorner.Y = rc.UpperLeftCorner.Y + 1;
driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), rc,
clipRect );
driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), rc, clipRect );
if( node->getParent() != Root )
{
......@@ -1004,8 +1015,7 @@ void CGUITreeView::draw()
rc.UpperLeftCorner.Y = frameRect.UpperLeftCorner.Y - ( frameRect.getHeight() >> 1 );
}
rc.LowerRightCorner.X = rc.UpperLeftCorner.X + 1;
driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), rc,
clipRect );
driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), rc, clipRect );
// the vertical lines of all parents
IGUITreeViewNode* nodeTmp = node->getParent();
......@@ -1016,8 +1026,7 @@ void CGUITreeView::draw()
rc.LowerRightCorner.X -= IndentWidth;
if( nodeTmp != nodeTmp->getParent()->getLastChild() )
{
driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), rc,
clipRect );
driver->draw2DRectangle( skin->getColor( EGDC_3D_SHADOW ), rc, clipRect );
}
nodeTmp = nodeTmp->getParent();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment