Ejemplo n.º 1
0
void GlassLayer::draw(Graphics* const TheGraphics, const Pnt2f& TopLeft, const Pnt2f& BottomRight, const Real32 Opacity) const
{
    Pnt2f IntermediatePosition;
    Vec3f Bounds(BottomRight- TopLeft);
    
    //Setup the Blending equations properly
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);

    glBegin(GL_TRIANGLE_FAN);
        glColor4f(getEdgeColor().red(),getEdgeColor().green(),getEdgeColor().blue(),getEdgeColor().alpha() * Opacity);
        glVertex2f(getStartPosition().x(), getEndPosition().y());
        glColor4f(getCenterColor().red(),getCenterColor().green(),getCenterColor().blue(),getCenterColor().alpha() * Opacity);
        glVertex2fv(getStartPosition().getValues());
        for(UInt32 i(0) ; i<_Segments.size(); ++i)
        {
            IntermediatePosition.setValues(_Segments[i].x() * Bounds.x(),_Segments[i].y() * Bounds.y());
            glVertex2fv(IntermediatePosition.getValues());
        }
        glVertex2fv(getEndPosition().getValues());
    glEnd();

    glDisable(GL_BLEND);

}
Ejemplo n.º 2
0
void TableHeader::MarginDraggedListener::mouseDragged(const MouseEventUnrecPtr e)
{
	if(e->getButton() == e->BUTTON1)
	{
		Pnt2f MousePosInComponent = ViewportToComponent(e->getLocation(), TableHeaderRefPtr(_TableHeader), e->getViewport());


        TableColumnRefPtr TheColumn(_TableHeader->getColumnModel()->getColumn(_TableHeader->_ResizingColumn));
        Real32 NewWidth(MousePosInComponent.x() - _TableHeader->getColumnHeaders(_TableHeader->_ResizingColumn)->getPosition().x());

        if(NewWidth <= 0 || NewWidth < TheColumn->getMinWidth())
        {
            NewWidth = TheColumn->getMinWidth();
        }

        if(NewWidth > TheColumn->getMaxWidth())
        {
            NewWidth = TheColumn->getMaxWidth();
        }
        
		//Get the new desired center for this margin
	        TheColumn->setWidth(NewWidth);
        _TableHeader->updateLayout();
	}
}
Ejemplo n.º 3
0
Vec2f AbsoluteLayout::layoutSize(const MFUnrecChildComponentPtr* Components,
                                 const Component* ParentComponent,
                                 SizeType TheSizeType) const
{
    Vec2f Result(0.0,0.0);

	Pnt2f borderTopLeft, borderBottomRight;
	dynamic_cast<const ComponentContainer*>(ParentComponent)->getInsideInsetsBounds(borderTopLeft, borderBottomRight);
	Vec2f borderSize(borderBottomRight-borderTopLeft);

    Vec2f ComponentSize;
    Pnt2f ComponentPosition;
    for(UInt32 i(0) ; i<Components->size() ; ++i)
    {
        ComponentPosition = dynamic_cast<AbsoluteLayoutConstraints*>((*Components)[i]->getConstraints())->getPosition();

        ComponentSize = getComponentSize((*Components)[i],TheSizeType);
        if(ComponentPosition.x() + ComponentSize.x() > Result.x())
        {
            Result[0] = ComponentPosition.x() + ComponentSize.x();
        }
        if(ComponentPosition.y() + ComponentSize.y() > Result.y())
        {
            Result[1] = ComponentPosition.y() + ComponentSize.y();
        }
    }

    return Result;
}
Ejemplo n.º 4
0
void GradientLayer::drawGradient(Graphics* const TheGraphics, const Pnt2f& Origin, const Vec2f& Size, const Vec2f& UAxis, const Real32& Start, const Real32& End, const Real32& Opacity) const
{
	glPushMatrix();
	Matrix Transformation;
	Transformation.setTransform(Vec3f(Origin.x()+Start*UAxis.x()*Size.x(), Origin.y()+Start*UAxis.y()*Size.x(),0.0f), Quaternion(Vec3f(1.0f,0.0f,0.0f),Vec3f(UAxis.x(), UAxis.y(), 0.0f)), Vec3f(Size.x()*(End-Start), Size.y(),0.0f));
	glMultMatrixf(Transformation.getValues());

	if (osgMin(getMFColors()->size(),getMFStops()->size()) > 1)
	{
		if(getMFColors()->size() != getMFStops()->size())
		{    
			SWARNING << "GradientLayer::drawGradient: The number of colors and the number of stops are not equal." << std::endl;
		}

		UInt32 NumStops = osgMin(getMFColors()->size(),getMFStops()->size());
		Real32 CurentRelaviteStop= 0.0f;
			
		for(UInt32 i(0) ; i<NumStops-1 ; ++i)
		{
			TheGraphics->drawQuad(Pnt2f(getStops(i),0.0f),
				                  Pnt2f(getStops(i+1),0.0f),
				                  Pnt2f(getStops(i+1),1.0f),
				                  Pnt2f(getStops(i),1.0f),
								  getColors(i),
								  getColors(i+1),
								  getColors(i+1),
								  getColors(i),
								  Opacity);
		}
	}
	glPopMatrix();
}
void Graphics3DExtrude::drawText(const Pnt2f& Position, const std::string& Text, const UIFontUnrecPtr TheFont, const Color4f& Color, const Real32& Opacity) const
{
   TextLayoutParam layoutParam;
   layoutParam.spacing = 1.1;
   layoutParam.majorAlignment = TextLayoutParam::ALIGN_BEGIN;
   layoutParam.minorAlignment = TextLayoutParam::ALIGN_BEGIN;
 
   TextLayoutResult layoutResult;
   TheFont->layout(Text, layoutParam, layoutResult);

   TheFont->getTexture()->activate(getDrawEnv());

   Real32 Alpha(Color.alpha() * Opacity * getOpacity());
	
   //Setup the blending equations properly
   glPushAttrib(GL_COLOR_BUFFER_BIT);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glEnable(GL_BLEND);

   glColor4f(Color.red(), Color.green(), Color.blue(), Alpha );
   glPushMatrix();
   glTranslatef(Position.x(), Position.y(), 0.0);
   glScalef(TheFont->getSize(), TheFont->getSize(), 1);
   drawCharacters(layoutResult, TheFont);
   glPopMatrix();

   TheFont->getTexture()->deactivate(getDrawEnv());

	glDisable(GL_BLEND);
   glPopAttrib();
}
Ejemplo n.º 6
0
void TableHeader::handleColBorderMouseDragged(MouseEventDetails* const e)
{
	if(e->getButton() == MouseEventDetails::BUTTON1)
	{
		Pnt2f MousePosInComponent = ViewportToComponent(e->getLocation(), this, e->getViewport());


        TableColumnRefPtr TheColumn(getColumnModel()->getColumn(_ResizingColumn));
        Real32 NewWidth(MousePosInComponent.x() - getColumnHeaders(_ResizingColumn)->getPosition().x());

        if(NewWidth <= 0 || NewWidth < TheColumn->getMinWidth())
        {
            NewWidth = TheColumn->getMinWidth();
        }

        if(NewWidth > TheColumn->getMaxWidth())
        {
            NewWidth = TheColumn->getMaxWidth();
        }
        
		//Get the new desired center for this margin
	    TheColumn->setWidth(NewWidth);
        updateLayout();
	}
}
Ejemplo n.º 7
0
Vec2f AbsoluteLayout::layoutSize(const MFUnrecComponentPtr* Components,
                                 const Component* ParentComponent,
                                 SizeType TheSizeType) const
{
    Vec2f Result(0.0,0.0);

    Vec2f ComponentSize;
    Pnt2f ComponentPosition;
    for(UInt32 i(0) ; i<Components->size() ; ++i)
    {
        ComponentPosition = dynamic_cast<AbsoluteLayoutConstraints*>((*Components)[i]->getConstraints())->getPosition();

        ComponentSize = getComponentSize((*Components)[i],TheSizeType);
        if(ComponentPosition.x() + ComponentSize.x() > Result.x())
        {
            Result[0] = ComponentPosition.x() + ComponentSize.x();
        }
        if(ComponentPosition.y() + ComponentSize.y() > Result.y())
        {
            Result[1] = ComponentPosition.y() + ComponentSize.y();
        }
    }

    return Result;
}
Ejemplo n.º 8
0
void InternalWindow::borderDragMouseDragged(MouseEventDetails* const e)
{
    Vec2f Size;
    bool PositionChange;
    Pnt2f Position;
    Pnt2f BottomRight(getPosition() + getSize());
    switch(_BorderDragged)
    {
        case WINDOW_LEFT_BORDER:
            Size.setValues(BottomRight.x() - e->getLocation().x(), getPreferredSize().y());
            PositionChange = true;
            Position = BottomRight - Size;
            break;
        case WINDOW_RIGHT_BORDER:
            PositionChange = false;
            Size.setValues(e->getLocation().x() - getPosition().x(), getPreferredSize().y());
            break;
        case WINDOW_TOP_BORDER:
            Size.setValues(getPreferredSize().x(), BottomRight.y() - e->getLocation().y());
            PositionChange = true;
            Position = BottomRight - Size;
            break;
        case WINDOW_BOTTOM_BORDER:
            PositionChange = false;
            Size.setValues(getPreferredSize().x(), e->getLocation().y() - getPosition().y());
            break;
        case WINDOW_TOP_LEFT_BORDER:
            Size.setValues(BottomRight.x() - e->getLocation().x(), BottomRight.y() - e->getLocation().y());
            PositionChange = true;
            Position = BottomRight - Size;
            break;
        case WINDOW_BOTTOM_RIGHT_BORDER:
            PositionChange = false;
            Size.setValues(e->getLocation().x() - getPosition().x(), e->getLocation().y() - getPosition().y());
            break;
        case WINDOW_TOP_RIGHT_BORDER:
            Size.setValues(e->getLocation().x() - getPosition().x(), BottomRight.y() - e->getLocation().y());
            PositionChange = true;
            Position.setValues(getPosition().x(), BottomRight.y() - Size.y());
            break;
        case WINDOW_BOTTOM_LEFT_BORDER:
            Size.setValues(BottomRight.x() - e->getLocation().x(), e->getLocation().y() - getPosition().y());
            PositionChange = true;
            Position.setValues( BottomRight.x() - Size.x(), getPosition().y());
            break;
    }

    if(PositionChange)
    {
        setPreferredSize(Size);
        setPosition(Position);
    }
    else
    {
        setPreferredSize(Size);
    }
}
Ejemplo n.º 9
0
void InternalWindow::BorderDraggedListener::mouseDragged(const MouseEventUnrecPtr e)
{
    Vec2f Size;
    bool PositionChange;
    Pnt2f Position;
    Pnt2f BottomRight(_InternalWindow->getPosition() + _InternalWindow->getSize());
    switch(_BorderDragged)
    {
        case WINDOW_LEFT_BORDER:
            Size.setValues(BottomRight.x() - e->getLocation().x(), _InternalWindow->getPreferredSize().y());
            PositionChange = true;
            Position = BottomRight - Size;
            break;
        case WINDOW_RIGHT_BORDER:
            PositionChange = false;
            Size.setValues(e->getLocation().x() - _InternalWindow->getPosition().x(), _InternalWindow->getPreferredSize().y());
            break;
        case WINDOW_TOP_BORDER:
            Size.setValues(_InternalWindow->getPreferredSize().x(), BottomRight.y() - e->getLocation().y());
            PositionChange = true;
            Position = BottomRight - Size;
            break;
        case WINDOW_BOTTOM_BORDER:
            PositionChange = false;
            Size.setValues(_InternalWindow->getPreferredSize().x(), e->getLocation().y() - _InternalWindow->getPosition().y());
            break;
        case WINDOW_TOP_LEFT_BORDER:
            Size.setValues(BottomRight.x() - e->getLocation().x(), BottomRight.y() - e->getLocation().y());
            PositionChange = true;
            Position = BottomRight - Size;
            break;
        case WINDOW_BOTTOM_RIGHT_BORDER:
            PositionChange = false;
            Size.setValues(e->getLocation().x() - _InternalWindow->getPosition().x(), e->getLocation().y() - _InternalWindow->getPosition().y());
            break;
        case WINDOW_TOP_RIGHT_BORDER:
            Size.setValues(e->getLocation().x() - _InternalWindow->getPosition().x(), BottomRight.y() - e->getLocation().y());
            PositionChange = true;
            Position.setValues(_InternalWindow->getPosition().x(), BottomRight.y() - Size.y());
            break;
        case WINDOW_BOTTOM_LEFT_BORDER:
            Size.setValues(BottomRight.x() - e->getLocation().x(), e->getLocation().y() - _InternalWindow->getPosition().y());
            PositionChange = true;
            Position.setValues( BottomRight.x() - Size.x(), _InternalWindow->getPosition().y());
            break;
    }

    if(PositionChange)
    {
        _InternalWindow->setPreferredSize(Size);
        _InternalWindow->setPosition(Position);
    }
    else
    {
        _InternalWindow->setPreferredSize(Size);
    }
}
void TexturedQuadUIDrawObject::getBounds(Pnt2f& TopLeft, Pnt2f& BottomRight) const
{
   TopLeft.setValues(
       osgMin(osgMin(osgMin(getPoint1().x(), getPoint2().x()),getPoint3().x()),getPoint4().x()),
       osgMin(osgMin(osgMin(getPoint1().y(), getPoint2().y()),getPoint3().y()),getPoint4().y()));
   
   BottomRight.setValues(
       osgMax(osgMax(osgMax(getPoint1().x(), getPoint2().x()),getPoint3().x()),getPoint4().x()),
       osgMax(osgMax(osgMax(getPoint1().y(), getPoint2().y()),getPoint3().y()),getPoint4().y()));
}
Ejemplo n.º 11
0
void InternalWindow::getTitlebarBounds(Pnt2f& TopLeft, Pnt2f& BottomRight) const
{
    if(getDrawDecorations() && getDrawTitlebar() && getDrawnBorder()->getType().isDerivedFrom(WindowBorder::getClassType()))
    {
        dynamic_pointer_cast<WindowBorder>(getDrawnBorder())->getTitlebarBounds(0, 0, getSize().x(), getSize().y(), TopLeft, BottomRight);
    }
    else
    {
        TopLeft.setValues(0,0);
        BottomRight.setValues(0,0);
    }
}
Ejemplo n.º 12
0
void Component::getInsideBorderBounds(Pnt2f& TopLeft, Pnt2f& BottomRight) const
{
    Real32 TopInset(0), LeftInset(0), BottomInset(0), RightInset(0);

    if(getBorder() != NULL)
    {
        //Get Border Insets
        getBorder()->getInsets(LeftInset,RightInset,TopInset,BottomInset);
    }
    TopLeft.setValues(LeftInset, TopInset);
    BottomRight.setValues(TopLeft.x()+getSize().x()-(LeftInset + RightInset), TopLeft.y()+getSize().y()-(TopInset + BottomInset));
}
Ejemplo n.º 13
0
void MenuBar::updateLayout(void)
{
	//Determine the Max Preferred Height of my MenuItems
	Real32 MaxHeight(0);
	Real32 TotalWidth(0);
    for(UInt32 i(0) ; i<getMFChildren()->size() ; ++i)
    {
        if(MaxHeight < getChildren(i)->getPreferredSize().y())
        {
            MaxHeight = getChildren(i)->getPreferredSize().y();
	    }
	    TotalWidth += getChildren(i)->getPreferredSize().x();
	}

    //Set My preferred Size
	Pnt2f TopLeft, BottomRight;
	Pnt2f InsetsTopLeft, InsetsBottomRight;
	getBounds(TopLeft, BottomRight);
	getInsideInsetsBounds(InsetsTopLeft, InsetsBottomRight);

	Vec2f InsetSize( (BottomRight-TopLeft) - (InsetsBottomRight-InsetsTopLeft) );

    Vec2f NewSize( TotalWidth+InsetSize.x(), MaxHeight+InsetSize.y());
    if(getPreferredSize() != NewSize)
    {
        setPreferredSize(NewSize);
    }
    
	getInsideInsetsBounds(InsetsTopLeft, InsetsBottomRight);
	
	//Now position and size the Items
	Real32 LeftOffset(InsetsTopLeft.x());
    Vec2f Size;
    Pnt2f Pos;
    for(UInt32 i(0) ; i<getMFChildren()->size() ; ++i)
    {
        Size.setValues(getChildren(i)->getPreferredSize().x(), MaxHeight);
        if(getChildren(i)->getSize() != Size)
        {
            getChildren(i)->setSize(Size);
        }
        Pos.setValues(LeftOffset, InsetsTopLeft.y());
        if(getChildren(i)->getPosition() != Pos)
        {
            getChildren(i)->setPosition(Pos);
        }

        LeftOffset += getChildren(i)->getPreferredSize().x();
    }
}
Ejemplo n.º 14
0
void Graphics3DExtrude::drawTextUnderline(const Pnt2f& Position, const std::string& Text, const UIFontUnrecPtr TheFont, const Color4f& Color, const Real32& Opacity) const
{
    Pnt2f TextTopLeft, TextBottomRight;
    TheFont->getBounds(Text, TextTopLeft, TextBottomRight);
    
    Pnt2f CharacterTopLeft, CharacterBottomRight;
    TheFont->getBounds("A", CharacterTopLeft, CharacterBottomRight);
    
    //Line Start Point
    Pnt2f LineStart(Position.x() + TextTopLeft.x(), Position.y() + CharacterBottomRight.y()-1);
    //Line End Point
    Pnt2f LineEnd(LineStart + Vec2f(TextBottomRight.x()-TextTopLeft.x(),1));

    drawRect(LineStart, LineEnd, Color, Opacity);
}
Ejemplo n.º 15
0
void GradientLayer::drawPad(Graphics* const TheGraphics, const Pnt2f& Origin, const Vec2f& Size, const Vec2f& UAxis, const Real32& Start, const Real32& End, const Color4f Color, const Real32& Opacity) const
{
	glPushMatrix();
	Matrix Transformation;
	Transformation.setTransform(Vec3f(Origin.x()+Start*UAxis.x()*Size.x(), Origin.y()+Start*UAxis.y()*Size.x(),0.0f), Quaternion(Vec3f(1.0f,0.0f,0.0f),Vec3f(UAxis.x(), UAxis.y(), 0.0f)), Vec3f(Size.x()*(End-Start), Size.y(),0.0f));
	glMultMatrixf(Transformation.getValues());

	
	TheGraphics->drawRect(Pnt2f(0.0,0.0f),
		                  Pnt2f(1.0,1.0f),
						  Color,
						  Opacity);

	glPopMatrix();
}
Ejemplo n.º 16
0
void WindowBorder::getTitlebarBounds(const Real32 x, const Real32 y , const Real32 Width, const Real32 Height, Pnt2f& TopLeft, Pnt2f& BottomRight)
{
    Real32 LeftIn(0.0f), RightIn(0.0f), BottomIn(0.0f), UpperIn(0.0f);
    if(getOuterBorder() != NULL)
    {
        getOuterBorder()->getInsets(LeftIn, RightIn, UpperIn, BottomIn);
    }

    TopLeft.setValues(x+LeftIn, y+UpperIn);
    if(getTitlebar() != NULL)
    {
        UpperIn += getTitlebar()->getSize().y();
    }

    BottomRight.setValues(x+Width-RightIn, y+UpperIn);
}
Ejemplo n.º 17
0
void Graphics3DExtrude::drawArc(const Pnt2f& Center, const Real32& Width, const Real32& Height, const Real32& StartAngleRad, const Real32& EndAngleRad, const Real32& LineWidth, const UInt16& SubDivisions, const Color4f& Color, const Real32& Opacity) const
{
	GLfloat previousLineWidth;
	glGetFloatv(GL_LINE_WIDTH, &previousLineWidth);
	Real32 angleNow = StartAngleRad;
	Real32 angleDiff = (EndAngleRad-StartAngleRad)/(static_cast<Real32>(SubDivisions));
	//If andle difference is bigger to a circle, set it to equal to a circle
	if(EndAngleRad-StartAngleRad > 2*3.1415926535)
		angleDiff = 2*3.1415926535/static_cast<Real32>(SubDivisions);
   Real32 Alpha(Color.alpha() * Opacity * getOpacity());
	if(Alpha < 1.0)
	{
		//Setup the blending equations properly
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		glEnable(GL_BLEND);
	}
	glLineWidth(LineWidth);
	glBegin(GL_LINE_STRIP);
      glColor4f(Color.red(), Color.green(), Color.blue(), Alpha );
		//draw vertex lines
      for(UInt16 i = 0 ; i<SubDivisions+1 ; ++i)
      {
			glVertex2f( static_cast<Real32>(Center.x()) + static_cast<Real32>(Width)*osgCos(angleNow ),static_cast<Real32>(Center.y()) +static_cast<Real32>(Height)*osgSin(angleNow));
			//glVertex2f(Center.x() + Width*osgCos(angleNow + angleDiff), Center.y() + Height*osgSin(angleNow+angleDiff));
			angleNow += angleDiff;
		}
	glEnd();

	
	if(Alpha < 1.0)
	{
		glDisable(GL_BLEND);
	}
   glLineWidth(previousLineWidth);
}
ViewportUnrecPtr WindowEventProducer::windowToViewport(const Pnt2f& WindowPoint, Pnt2f& ViewportPoint)
{
	ViewportUnrecPtr ThePort;
	for(UInt32 i(0) ; i<getMFPort()->size() ; ++i)
	{
		ThePort = getPort(i);
        if(ThePort->getEnabled())
        {
            ViewportPoint.setValues(WindowPoint.x() - ThePort->getPixelLeft(), WindowPoint.y() - ThePort->getPixelBottom());
    		
            return ThePort;
        }
		
	}
	return NULL;
}
Ejemplo n.º 19
0
void UIViewport::getViewBounds(Pnt2f& TopLeft, Pnt2f& BottomRight)
{
    Pnt2f InsetsTopLeft, InsetsBottomRight;
    getInsideInsetsBounds(InsetsTopLeft, InsetsBottomRight);

    TopLeft.setValues(getViewPosition().x(),getViewPosition().y());
    BottomRight = TopLeft + (InsetsBottomRight - InsetsTopLeft);
}
Ejemplo n.º 20
0
void UIFont::getBounds(const std::string& Text, Pnt2f& TopLeft, Pnt2f& BottomRight)
{
    TextLayoutParam layoutParam;
    layoutParam.spacing = 1.1;
    layoutParam.majorAlignment = TextLayoutParam::ALIGN_BEGIN;
    layoutParam.minorAlignment = TextLayoutParam::ALIGN_BEGIN;

    TextLayoutResult layoutResult;
    layout(Text, layoutParam, layoutResult);

    //Vec2f BottomLeft, TopRight;
    Vec2f size = Vec2f(layoutResult.textBounds.x()*getSize(),layoutResult.textBounds.y()*getSize());
    // _face->calculateBoundingBox(layoutResult,BottomLeft, TopRight);

    TopLeft.setValues(0, 0);
    BottomRight.setValue(size);
}
TreePath FixedHeightTreeModelLayout::getPathClosestTo(const Pnt2f& Loc) const
{
    //Determine the row
    UInt32 Row(osgMin<UInt32>(Loc.y()/getRowHeight(),getRowCount()-1));

    //Get the Path for that row
    return getPathForRow(Row);
}
Ejemplo n.º 22
0
void Graphics3DExtrude::drawQuad(const Pnt2f& p1, const Pnt2f& p2, const Pnt2f& p3, const Pnt2f& p4, 
						const Vec2f& t1, const Vec2f& t2, const Vec2f& t3, const Vec2f& t4,
						const MaterialUnrecPtr Material,
						const Real32& Opacity) const
{
	Real32 Alpha( Opacity * getOpacity());
	if(Alpha < 1.0 || Material->isTransparent())
	{
		//Setup the Blending equations properly
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		glEnable(GL_BLEND);
	}

    StateUnrecPtr state = NULL;
    if(Material != NULL)
    {
        state = Material->finalize(MaterialMapKey(),getDrawEnv()->getWindow())->getState();

        state->activate(getDrawEnv());
    }
	
	glBegin(GL_QUADS);
	   glColor4f(1.0, 1.0, 1.0, Alpha );
	   glTexCoord2fv(t1.getValues());
	   glVertex2fv(p1.getValues());
	   glTexCoord2fv(t2.getValues());
	   glVertex2fv(p2.getValues());
	   glTexCoord2fv(t3.getValues());
	   glVertex2fv(p3.getValues());
	   glTexCoord2fv(t4.getValues());
	   glVertex2fv(p4.getValues());
	glEnd();
	
	if(state != NULL)
	{
		state->deactivate(getDrawEnv());
	}

	if(Alpha < 1.0 || Material->isTransparent())
	{
		glDisable(GL_BLEND);
	}
}
bool UIRectangleMouseTransformFunctor::viewportToRenderingSurface(const Pnt2f& ViewportPoint,
                                                                  const Viewport* TheViewport,
                                                                  Pnt2f& Result) const
{
    //Get Viewport to View Space line
    Line l;
    if( !TheViewport->getCamera()->calcViewRay( l, ViewportPoint.x(), ViewportPoint.y(), *TheViewport ) )
    {
        return false;
    }

    //Transform Line to UIRectangle Space
    Matrix m ;
    getParent()->accumulateMatrix(m);

    m.invert();

    Pnt3f pos;
    Vec3f dir;

    m.multFull(l.getPosition (), pos);
    m.mult    (l.getDirection(), dir);

    l.setValue(pos, dir);
    //ia->scale(dir.length());

    //Intersect the Line with the UIRectangle quad
    Real32 t;
    if(!intersectLineRect(l,getParent()->getPoint(),
                          getParent()->getPoint() + Vec3f(getParent()->getWidth(),0,0),
                          getParent()->getPoint() + Vec3f(getParent()->getWidth(),getParent()->getHeight(),0),
                          getParent()->getPoint() + Vec3f(0,getParent()->getHeight(),0)
                          ,t))
    {
        return false;
    }

    //Return the point on the quad of the intersection if there was one
    Result.setValues(l.getPosition().x() + t*l.getDirection().x() - getParent()->getPoint().x(), 
                     getParent()->getHeight() - l.getPosition().y() - t*l.getDirection().y() + getParent()->getPoint().y());
    return true;
}
Ejemplo n.º 24
0
void TableHeader::checkMouseMargins(MouseEventDetails* const e)
{
    if(isContainedClipBounds(e->getLocation(), this))
    {
		Pnt2f MousePosInComponent = ViewportToComponent(e->getLocation(), this, e->getViewport());
        UInt32 CumulativeHeaderWidth(0);
        for(UInt32 i(0) ; i<getMFColumnHeaders()->size() ; ++i)
        {
            CumulativeHeaderWidth += getColumnHeaders(i)->getSize().x();
            if(MousePosInComponent.x() >= CumulativeHeaderWidth - getResizingCursorDriftAllowance() &&
               MousePosInComponent.x() <= CumulativeHeaderWidth + getColumnModel()->getColumnMargin() + getResizingCursorDriftAllowance())
            {
                getParentWindow()->getParentDrawingSurface()->getEventProducer()->setCursorType(WindowEventProducer::CURSOR_RESIZE_W_TO_E);
                return;
            }
            CumulativeHeaderWidth += getColumnModel()->getColumnMargin();
        }
    }
    getParentWindow()->getParentDrawingSurface()->getEventProducer()->setCursorType(WindowEventProducer::CURSOR_POINTER);
}
void WindowEventProducer::updateCursor(Pnt2f MousePos)
{
	CursorRegionListItor ListItor;
	bool CursorChanged(false);
	for(ListItor = _CursorRegions.begin() ; ListItor != _CursorRegions.end() ; ++ListItor)
	{
		if(MousePos.x() >= ListItor->_TopLeft.x() &&
		   MousePos.y() >= ListItor->_TopLeft.y() &&
		   MousePos.x() <= ListItor->_BottomRight.x() &&
		   MousePos.y() <= ListItor->_TopLeft.y())
		{
			setCursorType(ListItor->_CursorType);
			CursorChanged = true;
		}
	}
	if(!CursorChanged)
	{
		setCursorType(CURSOR_POINTER);
	}
}
Ejemplo n.º 26
0
	/// \brief Adjust the Volume of this DynamicTerrain Node (for culling!)
	void DynamicTerrain::adjustVolume( Volume & volume )
	{   
		volume.setValid();
		volume.setEmpty();

		const Pnt2f& worldOffset = getWorldOffset();
		const Pnt2f& worldSize = getWorldSize();
		Pnt2f worldMax;

		worldMax.setValues ( worldOffset[0] + worldSize[0],
							 worldOffset[1] + worldSize[1] );

		const float heightScale = getHeightDataScale();
		const float heightOffset = getHeightDataOffset();

		const float minHeight = heightScale * imageHeightSource_.getMinHeight() + heightOffset;
		const float maxHeight = heightScale * imageHeightSource_.getMaxHeight() + heightOffset;

		volume.extendBy( Pnt3f( worldOffset[ 0 ], minHeight, worldOffset[ 1 ] ) );
		volume.extendBy( Pnt3f( worldMax[ 0 ], maxHeight, worldMax[ 1 ] ) );
	}
Ejemplo n.º 27
0
TableColumnRefPtr TableHeader::columnAtPoint(const Pnt2f& point) const
{
    Int32 ColumnIndex = getColumnModel()->getColumnIndexAtX(point.x());
    if(ColumnIndex == -1)
    {
        return NULL;
    }
    else
    {
        return getColumnModel()->getColumn(ColumnIndex);
    }
}
Ejemplo n.º 28
0
void Graphics3DExtrude::drawQuad(const Pnt2f& p1, const Pnt2f& p2, const Pnt2f& p3, const Pnt2f& p4, 
						const Vec2f& t1, const Vec2f& t2, const Vec2f& t3, const Vec2f& t4,
						const Color4f& color, const TextureObjChunkUnrecPtr Texture,
						const Real32& Opacity) const
{
	Real32 Alpha( Opacity * getOpacity() * color.alpha());
	if(Alpha < 1.0 || Texture->getImage()->hasAlphaChannel())
	{
		//Setup the Blending equations properly
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		glEnable(GL_BLEND);
	}

	if(Texture != NULL)
	{
		Texture->activate(getDrawEnv());
	}
	
	glBegin(GL_QUADS);
	   glColor4f(color.red(), color.green(), color.blue(), Alpha );
	   glTexCoord2fv(t1.getValues());
	   glVertex2fv(p1.getValues());
	   glTexCoord2fv(t2.getValues());
	   glVertex2fv(p2.getValues());
	   glTexCoord2fv(t3.getValues());
	   glVertex2fv(p3.getValues());
	   glTexCoord2fv(t4.getValues());
	   glVertex2fv(p4.getValues());
	glEnd();
	
	if(Texture != NULL)
	{
		Texture->deactivate(getDrawEnv());
	}

	if(Alpha < 1.0 || Texture->getImage()->hasAlphaChannel())
	{
		glDisable(GL_BLEND);
	}
}
Ejemplo n.º 29
0
void TableHeader::mousePressed(MouseEventDetails* const e)
{
    if(getResizingAllowed())
    {
		Pnt2f MousePosInComponent = ViewportToComponent(e->getLocation(), this, e->getViewport());
        UInt32 CumulativeHeaderWidth(0);
        for(UInt32 i(0) ; i<getMFColumnHeaders()->size() ; ++i)
        {
            CumulativeHeaderWidth += getColumnHeaders(i)->getSize().x();
            if(MousePosInComponent.x() >= CumulativeHeaderWidth - getResizingCursorDriftAllowance() &&
               MousePosInComponent.x() <= CumulativeHeaderWidth + getColumnModel()->getColumnMargin() + getResizingCursorDriftAllowance())
            {
                _ColBorderMouseDraggedConnection = getParentWindow()->getParentDrawingSurface()->getEventProducer()->connectMouseDragged(boost::bind(&TableHeader::handleColBorderMouseDragged, this, _1));
                _ColBorderMouseReleasedConnection = getParentWindow()->getParentDrawingSurface()->getEventProducer()->connectMouseReleased(boost::bind(&TableHeader::mouseColBorderMouseReleased, this, _1));
                _ResizingColumn = i;
                return;
            }
            CumulativeHeaderWidth += getColumnModel()->getColumnMargin();
        }
    }
    Inherited::mousePressed(e);
}
Ejemplo n.º 30
0
void AbsoluteLayout::updateLayout(const MFUnrecComponentPtr* Components,
                                  const Component* ParentComponent) const
{
    Pnt2f ParentInsetsTopLeft, ParentInsetBottomRight;
    dynamic_cast<const ComponentContainer*>(ParentComponent)->getInsideInsetsBounds(ParentInsetsTopLeft, ParentInsetBottomRight);
    for(UInt32 i = 0 ; i<Components->size(); ++i)
    {
        //Calculate the Components Size
        (*Components)[i]->setSize((*Components)[i]->getPreferredSize());
        if((*Components)[i]->getConstraints() != NULL)
        {
            //Get the Components Position
            Pnt2f pos = dynamic_cast<AbsoluteLayoutConstraints*>((*Components)[i]->getConstraints())->getPosition();

            (*Components)[i]->setPosition(ParentInsetsTopLeft + pos.subZero());
        }
        else
        {
            (*Components)[i]->setPosition(ParentInsetsTopLeft);
        }
    }
}