- windows can now enable/disable drawing of background and titlebar
- improved window serialization git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2402 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
e404e5d63c
commit
b02776afcc
|
@ -38,6 +38,18 @@ namespace gui
|
||||||
//! Sets whether the window can be dragged by the mouse
|
//! Sets whether the window can be dragged by the mouse
|
||||||
virtual void setDraggable(bool draggable) = 0;
|
virtual void setDraggable(bool draggable) = 0;
|
||||||
|
|
||||||
|
//! Set if the window background will be drawn
|
||||||
|
virtual void setDrawBackground(bool draw) = 0;
|
||||||
|
|
||||||
|
//! Get if the window background will be drawn
|
||||||
|
virtual bool getDrawBackground() const = 0;
|
||||||
|
|
||||||
|
//! Set if the window titlebar will be drawn
|
||||||
|
//! Note: If the background is not drawn, then the titlebar is automatically also not drawn
|
||||||
|
virtual void setDrawTitlebar(bool draw) = 0;
|
||||||
|
|
||||||
|
//! Get if the window titlebar will be drawn
|
||||||
|
virtual bool getDrawTitlebar() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace gui
|
||||||
|
|
||||||
//! constructor
|
//! constructor
|
||||||
CGUIWindow::CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
|
CGUIWindow::CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
|
||||||
: IGUIWindow(environment, parent, id, rectangle), Dragging(false), IsDraggable(true)
|
: IGUIWindow(environment, parent, id, rectangle), Dragging(false), IsDraggable(true), DrawBackground(true), DrawTitlebar(true)
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
setDebugName("CGUIWindow");
|
setDebugName("CGUIWindow");
|
||||||
|
@ -216,22 +216,25 @@ void CGUIWindow::draw()
|
||||||
core::rect<s32> rect = AbsoluteRect;
|
core::rect<s32> rect = AbsoluteRect;
|
||||||
|
|
||||||
// draw body fast
|
// draw body fast
|
||||||
rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER),
|
if ( DrawBackground )
|
||||||
AbsoluteRect, &AbsoluteClippingRect);
|
{
|
||||||
|
rect = skin->draw3DWindowBackground(this, DrawTitlebar, skin->getColor(EGDC_ACTIVE_BORDER),
|
||||||
|
AbsoluteRect, &AbsoluteClippingRect);
|
||||||
|
|
||||||
if (Text.size())
|
if (DrawTitlebar && Text.size())
|
||||||
{
|
{
|
||||||
rect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X);
|
rect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X);
|
||||||
rect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y);
|
rect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y);
|
||||||
rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5;
|
rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5;
|
||||||
|
|
||||||
IGUIFont* font = skin->getFont(EGDF_WINDOW);
|
IGUIFont* font = skin->getFont(EGDF_WINDOW);
|
||||||
if (font)
|
if (font)
|
||||||
{
|
{
|
||||||
font->draw(Text.c_str(), rect,
|
font->draw(Text.c_str(), rect,
|
||||||
skin->getColor(EGDC_ACTIVE_CAPTION), false, true, &AbsoluteClippingRect);
|
skin->getColor(EGDC_ACTIVE_CAPTION), false, true, &AbsoluteClippingRect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IGUIElement::draw();
|
IGUIElement::draw();
|
||||||
|
@ -273,7 +276,65 @@ void CGUIWindow::setDraggable(bool draggable)
|
||||||
Dragging = false;
|
Dragging = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Set if the window background will be drawn
|
||||||
|
void CGUIWindow::setDrawBackground(bool draw)
|
||||||
|
{
|
||||||
|
DrawBackground = draw;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Get if the window background will be drawn
|
||||||
|
bool CGUIWindow::getDrawBackground() const
|
||||||
|
{
|
||||||
|
return DrawBackground;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Set if the window titlebar will be drawn
|
||||||
|
void CGUIWindow::setDrawTitlebar(bool draw)
|
||||||
|
{
|
||||||
|
DrawTitlebar = draw;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Get if the window titlebar will be drawn
|
||||||
|
bool CGUIWindow::getDrawTitlebar() const
|
||||||
|
{
|
||||||
|
return DrawTitlebar;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Writes attributes of the element.
|
||||||
|
void CGUIWindow::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
|
||||||
|
{
|
||||||
|
IGUIWindow::serializeAttributes(out,options);
|
||||||
|
|
||||||
|
out->addBool("IsDraggable", IsDraggable);
|
||||||
|
out->addBool("DrawBackground", DrawBackground);
|
||||||
|
out->addBool("DrawTitlebar", DrawTitlebar);
|
||||||
|
|
||||||
|
// Currently we can't just serialize attributes of sub-elements.
|
||||||
|
// To do this we either
|
||||||
|
// a) allow further serialization after attribute serialiation (second function, callback or event)
|
||||||
|
// b) add an IGUIElement attribute
|
||||||
|
// c) extend the attribute system to allow attributes to have sub-attributes
|
||||||
|
// We just serialize the most important info for now until we can do one of the above solutions.
|
||||||
|
out->addBool("IsCloseVisible", CloseButton->isVisible());
|
||||||
|
out->addBool("IsMinVisible", MinButton->isVisible());
|
||||||
|
out->addBool("IsRestoreVisible", RestoreButton->isVisible());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! Reads attributes of the element
|
||||||
|
void CGUIWindow::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
|
||||||
|
{
|
||||||
|
IGUIWindow::deserializeAttributes(in,options);
|
||||||
|
|
||||||
|
Dragging = false;
|
||||||
|
IsDraggable = in->getAttributeAsBool("IsDraggable");
|
||||||
|
DrawBackground = in->getAttributeAsBool("DrawBackground");
|
||||||
|
DrawTitlebar = in->getAttributeAsBool("DrawTitlebar");
|
||||||
|
|
||||||
|
CloseButton->setVisible( in->getAttributeAsBool("IsCloseVisible") );
|
||||||
|
MinButton->setVisible( in->getAttributeAsBool("IsMinVisible") );
|
||||||
|
RestoreButton->setVisible( in->getAttributeAsBool("IsRestoreVisible") );
|
||||||
|
}
|
||||||
|
|
||||||
} // end namespace gui
|
} // end namespace gui
|
||||||
} // end namespace irr
|
} // end namespace irr
|
||||||
|
|
|
@ -50,6 +50,25 @@ namespace gui
|
||||||
//! Sets whether the window is draggable
|
//! Sets whether the window is draggable
|
||||||
virtual void setDraggable(bool draggable);
|
virtual void setDraggable(bool draggable);
|
||||||
|
|
||||||
|
//! Set if the window background will be drawn
|
||||||
|
virtual void setDrawBackground(bool draw);
|
||||||
|
|
||||||
|
//! Get if the window background will be drawn
|
||||||
|
virtual bool getDrawBackground() const;
|
||||||
|
|
||||||
|
//! Set if the window titlebar will be drawn
|
||||||
|
//! Note: If the background is not drawn, then the titlebar is automatically also not drawn
|
||||||
|
virtual void setDrawTitlebar(bool draw);
|
||||||
|
|
||||||
|
//! Get if the window titlebar will be drawn
|
||||||
|
virtual bool getDrawTitlebar() const;
|
||||||
|
|
||||||
|
//! Writes attributes of the element.
|
||||||
|
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
|
||||||
|
|
||||||
|
//! Reads attributes of the element
|
||||||
|
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
IGUIButton* CloseButton;
|
IGUIButton* CloseButton;
|
||||||
|
@ -58,6 +77,8 @@ namespace gui
|
||||||
|
|
||||||
core::position2d<s32> DragStart;
|
core::position2d<s32> DragStart;
|
||||||
bool Dragging, IsDraggable;
|
bool Dragging, IsDraggable;
|
||||||
|
bool DrawBackground;
|
||||||
|
bool DrawTitlebar;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace gui
|
} // end namespace gui
|
||||||
|
|
Loading…
Reference in New Issue