added more default fonts to skins, made elements use them by default. updated gui example to show use.
modalscreens now resize to fit parent. updated meshviewer example to lock the image to the bottom left corner. tooltips: added EGDC_TOOLTIP_BACKGROUND to skins. changed the position of tooltips and their time between creation to 500ms. made sure that they do not leave the area of the gui environment. new method: rect::constrainTo to forcing one rectangle to stay inside another. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@697 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
a5fc06d99d
commit
4ee11782f6
24
changes.txt
24
changes.txt
|
@ -1,5 +1,7 @@
|
|||
Changes in version 1.3.1 (?? Mar 2007)
|
||||
|
||||
- Added rect::constrainTo for locking a rectangle inside another without resizing it
|
||||
|
||||
- Moved the OpenGL API functions from COpenGL driver into new extension
|
||||
handler. Thereby, some renaming took place - the ARB and EXT suffix was
|
||||
removed. Simply rename the functions in case you use them.
|
||||
|
@ -117,11 +119,22 @@ Changes in version 1.3.1 (?? Mar 2007)
|
|||
|
||||
GUI:
|
||||
|
||||
- Fixed a messagebox focus bug when no 'okay' button was present
|
||||
- Added EGUI_DEFAULT_FONT for skins, default fonts can now be set for windows, menus, buttons and tooltips.
|
||||
use IGUISkin::setFont and getFont to use them. Fonts are not serialized with saveGUI yet
|
||||
|
||||
- Added EGDC_TOOLTIP_BACKGROUND for setting background color of tooltips.
|
||||
|
||||
- Tooltips now appear relative to mouse position, also they do not appear for 500ms.
|
||||
|
||||
- Fixed a memory leak when dropping the GUIEnvironment when a tooltip was present.
|
||||
|
||||
- Added IGUIStaticText::setDrawBackground and IGUIStaticText::setBackgroundColor.
|
||||
|
||||
- Fixed a messagebox focus bug when no 'okay' button was present.
|
||||
|
||||
- Added setColor and setScaleImage to GUIImage.
|
||||
|
||||
- Made GUIListBox clip properly.
|
||||
- GUIListBox highlighted area now clips properly.
|
||||
|
||||
- added getOSOperator to GUIEnvironment (for clipboard access in elements) and updated CGUIEditBox.
|
||||
|
||||
|
@ -132,7 +145,12 @@ GUI:
|
|||
|
||||
- Fixed a bug with resizing the gui environment when the device is resized
|
||||
|
||||
- XML bitmap fonts now load textures from the XML file directory rather than the current one
|
||||
- Modal screens now resize to fit their parent.
|
||||
|
||||
- XML bitmap fonts now load textures from the XML file directory rather than the current one.
|
||||
|
||||
- Fixed a small bug with click areas in combo boxes.
|
||||
|
||||
|
||||
GUI Editor:
|
||||
|
||||
|
|
|
@ -182,8 +182,9 @@ int main()
|
|||
|
||||
/*
|
||||
To make the font a little bit nicer, we load an external font
|
||||
and set it as new font in the skin. An at last, we create a
|
||||
nice Irrlicht Engine logo in the top left corner.
|
||||
and set it as the new default font in the skin.
|
||||
To keep the standard font for tool tip text, we set it to
|
||||
the built-in font.
|
||||
*/
|
||||
|
||||
IGUISkin* skin = env->getSkin();
|
||||
|
@ -191,6 +192,8 @@ int main()
|
|||
if (font)
|
||||
skin->setFont(font);
|
||||
|
||||
skin->setFont(env->getBuiltInFont(), EGDF_TOOLTIP);
|
||||
|
||||
/*
|
||||
We add three buttons. The first one closes the engine. The second
|
||||
creates a window and the third opens a file open dialog. The third
|
||||
|
@ -198,7 +201,7 @@ int main()
|
|||
the button in the event receiver.
|
||||
*/
|
||||
|
||||
env->addButton(rect<s32>(10,210,110,210 + 32), 0, 101, L"Quit", L"Exits Programm");
|
||||
env->addButton(rect<s32>(10,210,110,210 + 32), 0, 101, L"Quit", L"Exits Program");
|
||||
env->addButton(rect<s32>(10,250,110,250 + 32), 0, 102, L"New Window", L"Launches a new Window");
|
||||
env->addButton(rect<s32>(10,290,110,290 + 32), 0, 103, L"File Open", L"Opens a file");
|
||||
|
||||
|
|
|
@ -622,8 +622,12 @@ int main()
|
|||
setActiveCamera ( Camera[0] );
|
||||
|
||||
// load the irrlicht engine logo
|
||||
env->addImage(driver->getTexture("irrlichtlogo2.png"),
|
||||
core::position2d<s32>(10, driver->getScreenSize().Height - 64));
|
||||
IGUIImage *img =
|
||||
env->addImage(driver->getTexture("irrlichtlogo2.png"),
|
||||
core::position2d<s32>(10, driver->getScreenSize().Height - 64));
|
||||
|
||||
// lock the logo's edges to the bottom left corner of the screen
|
||||
img->setAlignment(EGUIA_UPPERLEFT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT);
|
||||
|
||||
// draw everything
|
||||
|
||||
|
|
|
@ -81,8 +81,10 @@ namespace gui
|
|||
EGDC_INACTIVE_BORDER,
|
||||
//! Inactive window caption.
|
||||
EGDC_INACTIVE_CAPTION,
|
||||
//! Tool tip color
|
||||
//! Tool tip text color
|
||||
EGDC_TOOLTIP,
|
||||
//! Tool tip background color
|
||||
EGDC_TOOLTIP_BACKGROUND,
|
||||
//! Scrollbar gray area
|
||||
EGDC_SCROLLBAR,
|
||||
//! Window background
|
||||
|
@ -116,6 +118,7 @@ namespace gui
|
|||
"InactiveBorder",
|
||||
"InactiveCaption",
|
||||
"ToolTip",
|
||||
"ToolTipBackground",
|
||||
"ScrollBar",
|
||||
"Window",
|
||||
"WindowSymbol",
|
||||
|
@ -268,6 +271,34 @@ namespace gui
|
|||
0
|
||||
};
|
||||
|
||||
// Customizable fonts
|
||||
enum EGUI_DEFAULT_FONT
|
||||
{
|
||||
//! For static text, edit boxes, lists and most other places
|
||||
EGDF_DEFAULT=0,
|
||||
//! Font for buttons
|
||||
EGDF_BUTTON,
|
||||
//! Font for window title bars
|
||||
EGDF_WINDOW,
|
||||
//! Font for menu items
|
||||
EGDF_MENU,
|
||||
//! Font for tooltips
|
||||
EGDF_TOOLTIP,
|
||||
//! this value is not used, it only specifies the amount of default fonts
|
||||
//! available.
|
||||
EGDF_COUNT
|
||||
};
|
||||
|
||||
const c8* const GUISkinFontNames[] =
|
||||
{
|
||||
"defaultFont",
|
||||
"buttonFont",
|
||||
"windowFont",
|
||||
"menuFont",
|
||||
"tooltipFont",
|
||||
0
|
||||
};
|
||||
|
||||
//! A skin modifies the look of the GUI elements.
|
||||
class IGUISkin : public virtual io::IAttributeExchangingObject
|
||||
{
|
||||
|
@ -299,10 +330,10 @@ namespace gui
|
|||
virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size) = 0;
|
||||
|
||||
//! returns the default font
|
||||
virtual IGUIFont* getFont() = 0;
|
||||
virtual IGUIFont* getFont(EGUI_DEFAULT_FONT which=EGDF_DEFAULT) = 0;
|
||||
|
||||
//! sets a default font
|
||||
virtual void setFont(IGUIFont* font) = 0;
|
||||
virtual void setFont(IGUIFont* font, EGUI_DEFAULT_FONT which=EGDF_DEFAULT) = 0;
|
||||
|
||||
//! returns the sprite bank
|
||||
virtual IGUISpriteBank* getSpriteBank() = 0;
|
||||
|
|
|
@ -59,6 +59,12 @@ namespace gui
|
|||
//! \return true if the override color is enabled, false otherwise
|
||||
virtual bool isOverrideColorEnabled(void) = 0;
|
||||
|
||||
//! Sets another color for the background.
|
||||
virtual void setBackgroundColor(video::SColor color) = 0;
|
||||
|
||||
//! Sets whether to draw the background
|
||||
virtual void setDrawBackground(bool draw) = 0;
|
||||
|
||||
//! Enables or disables word wrap for using the static text as multiline text control.
|
||||
/** \param enable: If set to true, words going over one line are
|
||||
breaked to the next line. */
|
||||
|
|
|
@ -144,6 +144,44 @@ namespace core
|
|||
UpperLeftCorner.X = LowerRightCorner.X;
|
||||
}
|
||||
|
||||
//! Moves this rectangle to fit inside another one.
|
||||
//! \return: returns true on success, false if not possible
|
||||
bool constrainTo(const rect<T>& other)
|
||||
{
|
||||
if (other.getWidth() < getWidth() || other.getHeight() < getHeight())
|
||||
return false;
|
||||
|
||||
T diff = other.LowerRightCorner.X - LowerRightCorner.X;
|
||||
if (diff < 0)
|
||||
{
|
||||
LowerRightCorner.X += diff;
|
||||
UpperLeftCorner.X += diff;
|
||||
}
|
||||
|
||||
diff = other.LowerRightCorner.Y - LowerRightCorner.Y;
|
||||
if (diff < 0)
|
||||
{
|
||||
LowerRightCorner.Y += diff;
|
||||
UpperLeftCorner.Y += diff;
|
||||
}
|
||||
|
||||
diff = UpperLeftCorner.X - other.UpperLeftCorner.X;
|
||||
if (diff < 0)
|
||||
{
|
||||
UpperLeftCorner.X -= diff;
|
||||
LowerRightCorner.X -= diff;
|
||||
}
|
||||
|
||||
diff = UpperLeftCorner.Y - other.UpperLeftCorner.Y;
|
||||
if (diff < 0)
|
||||
{
|
||||
UpperLeftCorner.Y -= diff;
|
||||
LowerRightCorner.Y -= diff;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Returns width of rectangle.
|
||||
T getWidth() const
|
||||
{
|
||||
|
|
|
@ -196,7 +196,7 @@ void CGUIButton::draw()
|
|||
|
||||
IGUIFont* font = OverrideFont;
|
||||
if (!OverrideFont)
|
||||
font = skin->getFont();
|
||||
font = skin->getFont(EGDF_BUTTON);
|
||||
|
||||
core::rect<s32> rect = AbsoluteRect;
|
||||
|
||||
|
|
|
@ -445,7 +445,7 @@ void CGUIColorSelectDialog::draw()
|
|||
rect.UpperLeftCorner.X += 2;
|
||||
rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5;
|
||||
|
||||
IGUIFont* font = skin->getFont();
|
||||
IGUIFont* font = skin->getFont(EGDF_WINDOW);
|
||||
if (font)
|
||||
font->draw(Text.c_str(), rect, skin->getColor(EGDC_ACTIVE_CAPTION), false, true,
|
||||
&AbsoluteClippingRect);
|
||||
|
|
|
@ -382,7 +382,7 @@ void CGUIContextMenu::draw()
|
|||
if (!skin)
|
||||
return;
|
||||
|
||||
IGUIFont* font = skin->getFont();
|
||||
IGUIFont* font = skin->getFont(EGDF_MENU);
|
||||
IGUISpriteBank* sprites = skin->getSpriteBank();
|
||||
|
||||
video::IVideoDriver* driver = Environment->getVideoDriver();
|
||||
|
@ -481,7 +481,7 @@ void CGUIContextMenu::draw()
|
|||
void CGUIContextMenu::recalculateSize()
|
||||
{
|
||||
IGUISkin* skin = Environment->getSkin();
|
||||
IGUIFont* font = skin->getFont();
|
||||
IGUIFont* font = skin->getFont(EGDF_MENU);
|
||||
|
||||
if (!font)
|
||||
return;
|
||||
|
|
|
@ -48,7 +48,7 @@ const wchar_t* IRR_XML_FORMAT_GUI_ELEMENT_ATTR_TYPE = L"type";
|
|||
//! constructor
|
||||
CGUIEnvironment::CGUIEnvironment(io::IFileSystem* fs, video::IVideoDriver* driver, IOSOperator* op)
|
||||
: IGUIElement(EGUIET_ELEMENT, 0, 0, 0, core::rect<s32>(core::position2d<s32>(0,0), driver ? driver->getScreenSize() : core::dimension2d<s32>(0,0))),
|
||||
Driver(driver), Hovered(0), Focus(0), CurrentSkin(0),
|
||||
Driver(driver), Hovered(0), Focus(0), LastHoveredMousePos(0,0), CurrentSkin(0),
|
||||
FileSystem(fs), UserReceiver(0), Operator(op)
|
||||
{
|
||||
if (Driver)
|
||||
|
@ -103,6 +103,12 @@ CGUIEnvironment::~CGUIEnvironment()
|
|||
Focus = 0;
|
||||
}
|
||||
|
||||
if (ToolTip.Element)
|
||||
{
|
||||
ToolTip.Element->drop();
|
||||
ToolTip.Element = 0;
|
||||
}
|
||||
|
||||
if (FileSystem)
|
||||
{
|
||||
FileSystem->drop();
|
||||
|
@ -294,21 +300,28 @@ void CGUIEnvironment::OnPostRender( u32 time )
|
|||
Hovered && Hovered != this &&
|
||||
ToolTip.Element == 0 &&
|
||||
Hovered != ToolTip.Element &&
|
||||
Hovered->getToolTipText().size()
|
||||
Hovered->getToolTipText().size() &&
|
||||
getSkin() &&
|
||||
getSkin()->getFont(EGDF_TOOLTIP)
|
||||
)
|
||||
{
|
||||
core::rect<s32> pos;
|
||||
pos.UpperLeftCorner = Hovered->getAbsolutePosition().LowerRightCorner;
|
||||
pos.LowerRightCorner = pos.UpperLeftCorner + core::position2d<s32> ( 100, 50 );
|
||||
if (getSkin() && getSkin()->getFont())
|
||||
{
|
||||
pos.LowerRightCorner = pos.UpperLeftCorner +
|
||||
getSkin()->getFont()->getDimension(Hovered->getToolTipText().c_str()) +
|
||||
core::position2di(getSkin()->getSize(EGDS_TEXT_DISTANCE_X)*2, getSkin()->getSize(EGDS_TEXT_DISTANCE_Y)*2);
|
||||
}
|
||||
|
||||
pos.UpperLeftCorner = LastHoveredMousePos;
|
||||
core::dimension2di dim = getSkin()->getFont(EGDF_TOOLTIP)->getDimension(Hovered->getToolTipText().c_str());
|
||||
dim.Width += getSkin()->getSize(EGDS_TEXT_DISTANCE_X)*2;
|
||||
dim.Height += getSkin()->getSize(EGDS_TEXT_DISTANCE_Y)*2;
|
||||
|
||||
pos.UpperLeftCorner.Y -= dim.Height-1;
|
||||
pos.LowerRightCorner.Y = pos.UpperLeftCorner.Y + dim.Height-1;
|
||||
pos.LowerRightCorner.X = pos.UpperLeftCorner.X + dim.Width;
|
||||
|
||||
pos.constrainTo(getAbsolutePosition());
|
||||
|
||||
ToolTip.Element = addStaticText(Hovered->getToolTipText().c_str(), pos, true, true, this, -1, true);
|
||||
ToolTip.Element->setOverrideColor(getSkin()->getColor(EGDC_TOOLTIP));
|
||||
ToolTip.Element->setBackgroundColor(getSkin()->getColor(EGDC_TOOLTIP_BACKGROUND));
|
||||
ToolTip.Element->setOverrideFont(getSkin()->getFont(EGDF_TOOLTIP));
|
||||
ToolTip.Element->setSubElement(true);
|
||||
ToolTip.Element->grab();
|
||||
|
||||
|
@ -327,6 +340,7 @@ void CGUIEnvironment::OnPostRender( u32 time )
|
|||
void CGUIEnvironment::updateHoveredElement(core::position2d<s32> mousePos)
|
||||
{
|
||||
IGUIElement* lastHovered = Hovered;
|
||||
LastHoveredMousePos = mousePos;
|
||||
|
||||
Hovered = getElementFromPoint(mousePos);
|
||||
|
||||
|
@ -354,13 +368,14 @@ void CGUIEnvironment::updateHoveredElement(core::position2d<s32> mousePos)
|
|||
ToolTip.Element->remove();
|
||||
ToolTip.Element->drop();
|
||||
ToolTip.Element = 0;
|
||||
ToolTip.LastTime += 500;
|
||||
}
|
||||
else
|
||||
{
|
||||
// boost tooltip generation for relaunch
|
||||
if ( now - ToolTip.LastTime < ToolTip.LastTime )
|
||||
{
|
||||
ToolTip.LastTime += 100;
|
||||
ToolTip.LastTime += 500;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -265,6 +265,7 @@ private:
|
|||
video::IVideoDriver* Driver;
|
||||
IGUIElement* Hovered;
|
||||
IGUIElement* Focus;
|
||||
core::position2d<s32> LastHoveredMousePos;
|
||||
IGUISkin* CurrentSkin;
|
||||
io::IFileSystem* FileSystem;
|
||||
IEventReceiver* UserReceiver;
|
||||
|
|
|
@ -247,7 +247,7 @@ void CGUIFileOpenDialog::draw()
|
|||
rect.UpperLeftCorner.X += 2;
|
||||
rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5;
|
||||
|
||||
IGUIFont* font = skin->getFont();
|
||||
IGUIFont* font = skin->getFont(EGDF_WINDOW);
|
||||
if (font)
|
||||
font->draw(Text.c_str(), rect, skin->getColor(EGDC_ACTIVE_CAPTION), false, true,
|
||||
&AbsoluteClippingRect);
|
||||
|
|
|
@ -43,7 +43,7 @@ void CGUIMenu::draw()
|
|||
return;
|
||||
|
||||
IGUISkin* skin = Environment->getSkin();
|
||||
IGUIFont* font = skin->getFont();
|
||||
IGUIFont* font = skin->getFont(EGDF_MENU);
|
||||
|
||||
core::rect<s32> rect = AbsoluteRect;
|
||||
|
||||
|
@ -148,7 +148,7 @@ bool CGUIMenu::OnEvent(SEvent event)
|
|||
void CGUIMenu::recalculateSize()
|
||||
{
|
||||
IGUISkin* skin = Environment->getSkin();
|
||||
IGUIFont* font = skin->getFont();
|
||||
IGUIFont* font = skin->getFont(EGDF_MENU);
|
||||
|
||||
if (!font)
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@ CGUIModalScreen::CGUIModalScreen(IGUIEnvironment* environment, IGUIElement* pare
|
|||
#ifdef _DEBUG
|
||||
setDebugName("CGUIModalScreen");
|
||||
#endif
|
||||
setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace gui
|
|||
{
|
||||
|
||||
CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver)
|
||||
: Font(0), SpriteBank(0), Driver(driver), Type(type)
|
||||
: SpriteBank(0), Driver(driver), Type(type)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CGUISkin");
|
||||
|
@ -25,26 +25,27 @@ CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver)
|
|||
(Type == EGST_WINDOWS_METALLIC)
|
||||
)
|
||||
{
|
||||
Colors[EGDC_3D_DARK_SHADOW] = video::SColor(101,50,50,50);
|
||||
Colors[EGDC_3D_SHADOW] = video::SColor(101,130,130,130);
|
||||
Colors[EGDC_3D_FACE] = video::SColor(101,210,210,210);
|
||||
Colors[EGDC_3D_HIGH_LIGHT] = video::SColor(101,255,255,255);
|
||||
Colors[EGDC_3D_LIGHT] = video::SColor(101,210,210,210);
|
||||
Colors[EGDC_ACTIVE_BORDER] = video::SColor(101,16,14,115);
|
||||
Colors[EGDC_ACTIVE_CAPTION] = video::SColor(240,255,255,255);
|
||||
Colors[EGDC_APP_WORKSPACE] = video::SColor(101,100,100,100);
|
||||
Colors[EGDC_BUTTON_TEXT] = video::SColor(240,10,10,10);
|
||||
Colors[EGDC_GRAY_TEXT] = video::SColor(240,130,130,130);
|
||||
Colors[EGDC_HIGH_LIGHT] = video::SColor(101,8,36,107);
|
||||
Colors[EGDC_HIGH_LIGHT_TEXT] = video::SColor(240,255,255,255);
|
||||
Colors[EGDC_INACTIVE_BORDER] = video::SColor(101,165,165,165);
|
||||
Colors[EGDC_3D_DARK_SHADOW] = video::SColor(101,50,50,50);
|
||||
Colors[EGDC_3D_SHADOW] = video::SColor(101,130,130,130);
|
||||
Colors[EGDC_3D_FACE] = video::SColor(101,210,210,210);
|
||||
Colors[EGDC_3D_HIGH_LIGHT] = video::SColor(101,255,255,255);
|
||||
Colors[EGDC_3D_LIGHT] = video::SColor(101,210,210,210);
|
||||
Colors[EGDC_ACTIVE_BORDER] = video::SColor(101,16,14,115);
|
||||
Colors[EGDC_ACTIVE_CAPTION] = video::SColor(200,255,255,255);
|
||||
Colors[EGDC_APP_WORKSPACE] = video::SColor(101,100,100,100);
|
||||
Colors[EGDC_BUTTON_TEXT] = video::SColor(240,10,10,10);
|
||||
Colors[EGDC_GRAY_TEXT] = video::SColor(240,130,130,130);
|
||||
Colors[EGDC_HIGH_LIGHT] = video::SColor(101,8,36,107);
|
||||
Colors[EGDC_HIGH_LIGHT_TEXT] = video::SColor(240,255,255,255);
|
||||
Colors[EGDC_INACTIVE_BORDER] = video::SColor(101,165,165,165);
|
||||
Colors[EGDC_INACTIVE_CAPTION] = video::SColor(101,210,210,210);
|
||||
Colors[EGDC_TOOLTIP] = video::SColor(101,255,255,230);
|
||||
Colors[EGDC_SCROLLBAR] = video::SColor(101,230,230,230);
|
||||
Colors[EGDC_WINDOW] = video::SColor(101,255,255,255);
|
||||
Colors[EGDC_WINDOW_SYMBOL] = video::SColor(240,10,10,10);
|
||||
Colors[EGDC_ICON] = video::SColor(240,255,255,255);
|
||||
Colors[EGDC_ICON_HIGH_LIGHT] = video::SColor(240,10,10,10);
|
||||
Colors[EGDC_TOOLTIP] = video::SColor(200,0,0,0);
|
||||
Colors[EGDC_TOOLTIP_BACKGROUND]= video::SColor(200,255,255,225);
|
||||
Colors[EGDC_SCROLLBAR] = video::SColor(101,230,230,230);
|
||||
Colors[EGDC_WINDOW] = video::SColor(101,255,255,255);
|
||||
Colors[EGDC_WINDOW_SYMBOL] = video::SColor(200,10,10,10);
|
||||
Colors[EGDC_ICON] = video::SColor(200,255,255,255);
|
||||
Colors[EGDC_ICON_HIGH_LIGHT] = video::SColor(200,10,10,10);
|
||||
|
||||
Sizes[EGDS_SCROLLBAR_SIZE] = 14;
|
||||
Sizes[EGDS_MENU_HEIGHT] = 30;
|
||||
|
@ -78,6 +79,7 @@ CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver)
|
|||
Colors[EGDC_INACTIVE_BORDER]= 0xf0a5a5a5;
|
||||
Colors[EGDC_INACTIVE_CAPTION]= 0xf0d2d2d2;
|
||||
Colors[EGDC_TOOLTIP] = 0xf00f2033;
|
||||
Colors[EGDC_TOOLTIP_BACKGROUND]=0xc0cbd2d9;
|
||||
Colors[EGDC_SCROLLBAR] = 0xf0e0e0e0;
|
||||
Colors[EGDC_WINDOW] = 0xf0f0f0f0;
|
||||
Colors[EGDC_WINDOW_SYMBOL] = 0xd0161616;
|
||||
|
@ -123,6 +125,9 @@ CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver)
|
|||
Icons[EGDI_FILE] = 238;
|
||||
Icons[EGDI_DIRECTORY] = 239;
|
||||
|
||||
for (u32 i=0; i<EGDF_COUNT; ++i)
|
||||
Fonts[i] = 0;
|
||||
|
||||
UseGradient = (Type == EGST_WINDOWS_METALLIC) ||
|
||||
(Type == EGST_BURNING_SKIN) ;
|
||||
}
|
||||
|
@ -131,8 +136,12 @@ CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver)
|
|||
//! destructor
|
||||
CGUISkin::~CGUISkin()
|
||||
{
|
||||
if (Font)
|
||||
Font->drop();
|
||||
for (u32 i=0; i<EGDF_COUNT; ++i)
|
||||
{
|
||||
if (Fonts[i])
|
||||
Fonts[i]->drop();
|
||||
}
|
||||
|
||||
if (SpriteBank)
|
||||
SpriteBank->drop();
|
||||
}
|
||||
|
@ -172,21 +181,24 @@ void CGUISkin::setSize(EGUI_DEFAULT_SIZE which, s32 size)
|
|||
|
||||
|
||||
//! returns the default font
|
||||
IGUIFont* CGUISkin::getFont()
|
||||
IGUIFont* CGUISkin::getFont(EGUI_DEFAULT_FONT which)
|
||||
{
|
||||
return Font;
|
||||
if (Fonts[which])
|
||||
return Fonts[which];
|
||||
else
|
||||
return Fonts[EGDF_DEFAULT];
|
||||
}
|
||||
|
||||
//! sets a default font
|
||||
void CGUISkin::setFont(IGUIFont* font)
|
||||
void CGUISkin::setFont(IGUIFont* font, EGUI_DEFAULT_FONT which)
|
||||
{
|
||||
if (Font)
|
||||
Font->drop();
|
||||
if (Fonts[which])
|
||||
Fonts[which]->drop();
|
||||
|
||||
Font = font;
|
||||
Fonts[which] = font;
|
||||
|
||||
if (Font)
|
||||
Font->grab();
|
||||
if (Fonts[which])
|
||||
Fonts[which]->grab();
|
||||
}
|
||||
|
||||
IGUISpriteBank* CGUISkin::getSpriteBank()
|
||||
|
|
|
@ -39,10 +39,10 @@ namespace gui
|
|||
virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size);
|
||||
|
||||
//! returns the default font
|
||||
virtual IGUIFont* getFont();
|
||||
virtual IGUIFont* getFont(EGUI_DEFAULT_FONT which=EGDF_DEFAULT);
|
||||
|
||||
//! sets a default font
|
||||
virtual void setFont(IGUIFont* font);
|
||||
virtual void setFont(IGUIFont* font, EGUI_DEFAULT_FONT which=EGDF_DEFAULT);
|
||||
|
||||
//! sets the sprite bank used for drawing icons
|
||||
virtual void setSpriteBank(IGUISpriteBank* bank);
|
||||
|
@ -207,7 +207,7 @@ namespace gui
|
|||
video::SColor Colors[EGDC_COUNT];
|
||||
s32 Sizes[EGDS_COUNT];
|
||||
u32 Icons[EGDI_COUNT];
|
||||
IGUIFont* Font;
|
||||
IGUIFont* Fonts[EGDF_COUNT];
|
||||
IGUISpriteBank* SpriteBank;
|
||||
core::stringw Texts[EGDT_COUNT];
|
||||
video::IVideoDriver* Driver;
|
||||
|
|
|
@ -22,12 +22,17 @@ CGUIStaticText::CGUIStaticText(const wchar_t* text, bool border,
|
|||
bool background)
|
||||
: IGUIStaticText(environment, parent, id, rectangle), Border(border),
|
||||
OverrideColorEnabled(false), WordWrap(false), Background(background),
|
||||
OverrideColor(video::SColor(101,255,255,255)), OverrideFont(0), LastBreakFont(0)
|
||||
OverrideColor(video::SColor(101,255,255,255)), OverrideFont(0), LastBreakFont(0),
|
||||
BGColor(video::SColor(101,210,210,210))
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CGUIStaticText");
|
||||
#endif
|
||||
Text = text;
|
||||
if (environment && environment->getSkin())
|
||||
{
|
||||
BGColor = environment->getSkin()->getColor(gui::EGDC_3D_FACE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,8 +61,7 @@ void CGUIStaticText::draw()
|
|||
|
||||
if (Background)
|
||||
{
|
||||
driver->draw2DRectangle( skin->getColor(gui::EGDC_3D_FACE),
|
||||
frameRect, &AbsoluteClippingRect);
|
||||
driver->draw2DRectangle(BGColor, frameRect, &AbsoluteClippingRect);
|
||||
}
|
||||
|
||||
// draw the border
|
||||
|
@ -134,6 +138,19 @@ void CGUIStaticText::setOverrideColor(video::SColor color)
|
|||
OverrideColorEnabled = true;
|
||||
}
|
||||
|
||||
//! Sets another color for the text.
|
||||
void CGUIStaticText::setBackgroundColor(video::SColor color)
|
||||
{
|
||||
BGColor = color;
|
||||
Background = true;
|
||||
}
|
||||
|
||||
//! Sets whether to draw the background
|
||||
void CGUIStaticText::setDrawBackground(bool draw)
|
||||
{
|
||||
Background = draw;
|
||||
}
|
||||
|
||||
video::SColor const & CGUIStaticText::getOverrideColor(void)
|
||||
{
|
||||
return OverrideColor;
|
||||
|
|
|
@ -36,6 +36,12 @@ namespace gui
|
|||
//! Sets another color for the text.
|
||||
virtual void setOverrideColor(video::SColor color);
|
||||
|
||||
//! Sets another color for the background.
|
||||
virtual void setBackgroundColor(video::SColor color);
|
||||
|
||||
//! Sets whether to draw the background
|
||||
virtual void setDrawBackground(bool draw);
|
||||
|
||||
//! Gets the override color
|
||||
virtual video::SColor const & getOverrideColor(void);
|
||||
|
||||
|
@ -78,7 +84,7 @@ namespace gui
|
|||
bool WordWrap;
|
||||
bool Background;
|
||||
|
||||
video::SColor OverrideColor;
|
||||
video::SColor OverrideColor, BGColor;
|
||||
gui::IGUIFont* OverrideFont;
|
||||
gui::IGUIFont* LastBreakFont; // stored because: if skin changes, line break must be recalculated.
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ void CGUIWindow::draw()
|
|||
rect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y);
|
||||
rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5;
|
||||
|
||||
IGUIFont* font = skin->getFont();
|
||||
IGUIFont* font = skin->getFont(EGDF_WINDOW);
|
||||
if (font)
|
||||
font->draw(Text.c_str(), rect, skin->getColor(EGDC_ACTIVE_CAPTION), false, true, cl);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue