Beispiel #1
0
ZRange Button::calcZRange(void) const
	{
	/* Calculate the parent class widget's z range: */
	ZRange myZRange=Label::calcZRange();
	
	/* Adjust for the popping in/out when arming/disarming: */
	myZRange+=ZRange(getExterior().origin[2]-getBorderWidth(),getExterior().origin[2]+getBorderWidth());
	
	return myZRange;
	}
Beispiel #2
0
MWWorld::CellStore *MWWorld::Cells::getCell (const ESM::CellId& id)
{
    if (id.mPaged)
        return getExterior (id.mIndex.mX, id.mIndex.mY);

    return getInterior (id.mWorldspace);
}
Beispiel #3
0
void Margin::setAlignment(const Alignment& newAlignment)
	{
	/* Set the child alignment: */
	alignment=newAlignment;
	
	/* Resize the widget to the same size to update the child's padding: */
	if(child!=0)
		resize(getExterior());
	
	/* Notify parent widgets that the visual representation has changed: */
	update();
	}
Beispiel #4
0
void PopupWindow::pointerButtonDown(Event& event)
	{
	/* Check which part of the resizing border was clicked: */
	const Point& p=event.getWidgetPoint().getPoint();
	GLfloat left=getExterior().origin[0];
	GLfloat right=left+getExterior().size[0];
	GLfloat bottom=getExterior().origin[1];
	// GLfloat top=bottom+getExterior().size[1];
	GLfloat cornerSize=childBorderWidth*5.0f;
	resizeBorderMask=0x0;
	if(resizableMask&0x1)
		{
		if(p[0]<=left+cornerSize)
			{
			resizeBorderMask|=0x1;
			resizeOffset[0]=left-p[0];
			}
		else if(p[0]>=right-cornerSize)
			{
			resizeBorderMask|=0x2;
			resizeOffset[0]=right-p[0];
			}
		}
	if(resizableMask&0x2)
		{
		if(p[1]<=bottom+cornerSize)
			{
			resizeBorderMask|=0x4;
			resizeOffset[1]=bottom-p[1];
			}
		#if 0 // Can't -- or shouldn't -- resize by pulling on top
		else if(p[1]>=top-cornerSize)
			{
			resizeBorderMask|=0x8;
			resizeOffset[1]=top-p[1];
			}
		#endif
		}
	isResizing=true;
	}
void DropdownBox::resize(const Box& newExterior)
	{
	/* Resize the parent class widget: */
	Label::resize(newExterior);
	
	/* Position the dropdown arrow: */
	Box arrowBox=getInterior().inset(Vector(marginWidth,marginWidth,0.0f));
	arrowBox.origin[0]+=arrowBox.size[0]-arrow.getPreferredBoxSize();
	arrowBox.size[0]=arrow.getPreferredBoxSize();
	arrow.setGlyphBox(arrowBox);
	
	if(popup!=0)
		{
		/* Resize the popup to match the interior of the dropdown box: */
		Box popupBox=popup->getExterior();
		popupBox.size[0]=getExterior().size[0]-arrowBox.size[0]-spacing;
		popup->resize(popupBox);
		}
	}
Beispiel #6
0
void DropdownButton::setArmed(bool newArmed)
	{
	/* Call the base class widget's setArmed method: */
	DecoratedButton::setArmed(newArmed);
	
	/* Pop the secondary top level widget up or down: */
	if(isArmed&&!isPopped)
		{
		/* Calculate the popup's transformation: */
		Vector offset=getExterior().getCorner(3);
		Vector popupHotSpot=popup->getChild()->getExterior().getCorner(2);
		offset[0]-=popupHotSpot[0];
		offset[1]-=popupHotSpot[1];
		offset[2]-=popupHotSpot[2];
		offset[2]+=getZRange().second-popup->getChild()->getZRange().first;
		getManager()->popupSecondaryWidget(this,popup,offset);
		isPopped=true;
		}
	else if(!isArmed&&isPopped)
		{
		popup->getManager()->popdownWidget(popup);
		isPopped=false;
		}
	}
Beispiel #7
0
void PopupWindow::pointerMotion(Event& event)
	{
	if(isResizing)
		{
		const Point& p=event.getWidgetPoint().getPoint();
		
		/* Get the current exterior box: */
		Box exterior=getExterior();
		
		/* Get the minimal exterior size: */
		Vector minSize=calcNaturalSize();
		
		/* Resize the box horizontally: */
		if(resizeBorderMask&0x1)
			{
			GLfloat right=exterior.origin[0]+exterior.size[0];
			GLfloat newLeft=p[0]+resizeOffset[0];
			GLfloat newSize=right-newLeft;
			if(newSize<minSize[0])
				newSize=minSize[0];
			exterior.origin[0]=right-newSize;
			exterior.size[0]=newSize;
			}
		else if(resizeBorderMask&0x2)
			{
			GLfloat left=exterior.origin[0];
			GLfloat newRight=p[0]+resizeOffset[0];
			GLfloat newSize=newRight-left;
			if(newSize<minSize[0])
				newSize=minSize[0];
			exterior.size[0]=newSize;
			}
		
		/* Resize the box vertically: */
		if(resizeBorderMask&0x4)
			{
			GLfloat top=exterior.origin[1]+exterior.size[1];
			GLfloat newBottom=p[1]+resizeOffset[1];
			GLfloat newSize=top-newBottom;
			if(newSize<minSize[1])
				newSize=minSize[1];
			exterior.origin[1]=top-newSize;
			exterior.size[1]=newSize;
			}
		else if(resizeBorderMask&0x8)
			{
			GLfloat bottom=exterior.origin[1];
			GLfloat newTop=p[1]+resizeOffset[1];
			GLfloat newSize=newTop-bottom;
			if(newSize<minSize[1])
				newSize=minSize[1];
			exterior.size[1]=newSize;
			}
		
		if(exterior.size[0]!=getExterior().size[0]||exterior.size[1]!=getExterior().size[1])
			{
			/* Resize the popup window: */
			resize(exterior);
			}
		}
	}
Beispiel #8
0
void PopupWindow::draw(GLContextData& contextData) const
	{
	#if GLMOTIF_POPUPWINDOW_USE_RENDERCACHE
	/* Retrieve the data item: */
	DataItem* dataItem=contextData.retrieveDataItem<DataItem>(this);
	
	/* Check if the display list's contents are current: */
	if(dataItem->version==version)
		{
		/* Render the geometry stored in the display list: */
		glCallList(dataItem->displayListId);
		
		/* Bail out: */
		return;
		}
	else
		{
		/* Cache the popup window's visual representation into the display list: */
		glNewList(dataItem->displayListId,GL_COMPILE_AND_EXECUTE);
		}
	#endif
	
	/* Draw the popup window's back side: */
	Box back=getExterior().offset(Vector(0.0,0.0,getZRange().first));
	glColor(borderColor);
	glBegin(GL_QUADS);
	glNormal3f(0.0f,0.0f,-1.0f);
	glVertex(back.getCorner(0));
	glVertex(back.getCorner(2));
	glVertex(back.getCorner(3));
	glVertex(back.getCorner(1));
	glNormal3f(0.0f,-1.0f,0.0f);
	glVertex(back.getCorner(0));
	glVertex(back.getCorner(1));
	glVertex(getExterior().getCorner(1));
	glVertex(getExterior().getCorner(0));
	glEnd();
	glBegin(GL_TRIANGLE_FAN);
	glNormal3f(0.0f,1.0f,0.0f);
	glVertex(back.getCorner(3));
	glVertex(back.getCorner(2));
	glVertex(titleBar->getExterior().getCorner(2));
	glVertex(titleBar->getExterior().getCorner(3));
	if(hideButton!=0)
		glVertex(hideButton->getExterior().getCorner(3));
	if(closeButton!=0)
		glVertex(closeButton->getExterior().getCorner(3));
	glEnd();
	glBegin(GL_TRIANGLE_FAN);
	glNormal3f(-1.0f,0.0f,0.0f);
	glVertex(back.getCorner(2));
	glVertex(back.getCorner(0));
	glVertex(getExterior().getCorner(0));
	glVertex(titleBar->getExterior().getCorner(0));
	glVertex(titleBar->getExterior().getCorner(2));
	glEnd();
	glBegin(GL_TRIANGLE_FAN);
	glNormal3f(1.0f,0.0f,0.0f);
	glVertex(back.getCorner(1));
	glVertex(back.getCorner(3));
	if(closeButton!=0)
		{
		glVertex(closeButton->getExterior().getCorner(3));
		glVertex(closeButton->getExterior().getCorner(1));
		}
	else if(hideButton!=0)
		{
		glVertex(hideButton->getExterior().getCorner(3));
		glVertex(hideButton->getExterior().getCorner(1));
		}
	else
		{
		glVertex(titleBar->getExterior().getCorner(3));
		glVertex(titleBar->getExterior().getCorner(1));
		}
	glVertex(getExterior().getCorner(1));
	glEnd();
	
	/* Draw the title bar: */
	titleBar->draw(contextData);
	if(hideButton!=0)
		hideButton->draw(contextData);
	if(closeButton!=0)
		closeButton->draw(contextData);
	
	/* Draw the child border: */
	Box childBorder=getInterior();
	childBorder.size[1]-=titleBar->getExterior().size[1];
	Box childBox=childBorder;
	childBox.doInset(Vector(childBorderWidth,childBorderWidth,0.0f));
	glColor(backgroundColor);
	glBegin(GL_QUAD_STRIP);
	glNormal3f(0.0f,0.0f,1.0f);
	glVertex(childBox.getCorner(0));
	glVertex(childBorder.getCorner(0));
	glVertex(childBox.getCorner(1));
	glVertex(childBorder.getCorner(1));
	glVertex(childBox.getCorner(3));
	glVertex(childBorder.getCorner(3));
	glVertex(childBox.getCorner(2));
	glVertex(childBorder.getCorner(2));
	glVertex(childBox.getCorner(0));
	glVertex(childBorder.getCorner(0));
	glEnd();
	
	/* Draw the child: */
	if(child!=0)
		child->draw(contextData);
	
	#if GLMOTIF_POPUPWINDOW_USE_RENDERCACHE
	if(dataItem->version!=version)
		{
		/* Finish caching the popup window's visual representation: */
		glEndList();
		
		/* Mark the display list as up-to-date: */
		dataItem->version=version;
		}
	#endif
	}
Beispiel #9
0
void Popup::draw(GLContextData& contextData) const
	{
	/* Draw the parent class widget: */
	Container::draw(contextData);
	
	/* Draw the widget's back side: */
	Box back=getExterior().offset(Vector(0.0,0.0,getZRange().first));
	glColor(borderColor);
	glBegin(GL_QUADS);
	glNormal3f(0.0f,0.0f,-1.0f);
	glVertex(back.getCorner(0));
	glVertex(back.getCorner(2));
	glVertex(back.getCorner(3));
	glVertex(back.getCorner(1));
	glNormal3f(0.0f,-1.0f,0.0f);
	glVertex(back.getCorner(0));
	glVertex(back.getCorner(1));
	glVertex(getExterior().getCorner(1));
	glVertex(getExterior().getCorner(0));
	glNormal3f(1.0f,0.0f,0.0f);
	glVertex(back.getCorner(1));
	glVertex(back.getCorner(3));
	glVertex(getExterior().getCorner(3));
	glVertex(getExterior().getCorner(1));
	glNormal3f(0.0f,1.0f,0.0f);
	glVertex(back.getCorner(3));
	glVertex(back.getCorner(2));
	glVertex(getExterior().getCorner(2));
	glVertex(getExterior().getCorner(3));
	glNormal3f(-1.0f,0.0f,0.0f);
	glVertex(back.getCorner(2));
	glVertex(back.getCorner(0));
	glVertex(getExterior().getCorner(0));
	glVertex(getExterior().getCorner(2));
	glEnd();
	
	/* Draw the margin and title separator: */
	glColor(backgroundColor);
	
	/* Draw the top left margin part: */
	glBegin(GL_TRIANGLE_FAN);
	glNormal3f(0.0f,0.0f,1.0f);
	glVertex(getInterior().getCorner(2));
	glVertex(getInterior().getCorner(0));
	if(child!=0)
		{
		glVertex(child->getExterior().getCorner(0));
		glVertex(child->getExterior().getCorner(2));
		}
	if(title!=0)
		{
		glVertex(title->getExterior().getCorner(0));
		glVertex(title->getExterior().getCorner(2));
		glVertex(title->getExterior().getCorner(3));
		}
	else if(child!=0)
		glVertex(child->getExterior().getCorner(3));
	glVertex(getInterior().getCorner(3));
	glEnd();
	
	/* Draw the bottom right margin part: */
	glBegin(GL_TRIANGLE_FAN);
	glVertex(getInterior().getCorner(1));
	glVertex(getInterior().getCorner(3));
	if(title!=0)
		{
		glVertex(title->getExterior().getCorner(3));
		glVertex(title->getExterior().getCorner(1));
		}
	if(child!=0)
		{
		glVertex(child->getExterior().getCorner(3));
		glVertex(child->getExterior().getCorner(1));
		glVertex(child->getExterior().getCorner(0));
		}
	else if(title!=0)
		glVertex(title->getExterior().getCorner(0));
	glVertex(getInterior().getCorner(0));
	glEnd();
	
	/* Draw the title separator: */
	if(title!=0&&child!=0)
		{
		glBegin(GL_QUADS);
		glVertex(child->getExterior().getCorner(2));
		glVertex(child->getExterior().getCorner(3));
		glVertex(title->getExterior().getCorner(1));
		glVertex(title->getExterior().getCorner(0));
		glEnd();
		}
	
	/* Draw the title and child: */
	if(title!=0)
		title->draw(contextData);
	if(child!=0)
		child->draw(contextData);
	}