You need to sign in or sign up before continuing.
Commit 1f5444c9 authored by bitplane's avatar bitplane

Fixed menu bug reported by hey_i_am_real, it's now possible to change the font after menu creation.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1057 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 7e857cea
......@@ -24,7 +24,7 @@ CGUIContextMenu::CGUIContextMenu(IGUIEnvironment* environment,
IGUIElement* parent, s32 id,
core::rect<s32> rectangle, bool getFocus, bool allowFocus)
: IGUIContextMenu(environment, parent, id, rectangle), HighLighted(-1),
ChangeTime(0), EventParent(0), AllowFocus(allowFocus)
ChangeTime(0), EventParent(0), AllowFocus(allowFocus), LastFont(0)
{
#ifdef _DEBUG
setDebugName("CGUIContextMenu");
......@@ -46,6 +46,9 @@ CGUIContextMenu::~CGUIContextMenu()
for (u32 i=0; i<Items.size(); ++i)
if (Items[i].SubMenu)
Items[i].SubMenu->drop();
if (LastFont)
LastFont->drop();
}
......@@ -420,6 +423,17 @@ void CGUIContextMenu::draw()
return;
IGUIFont* font = skin->getFont(EGDF_MENU);
if (font != LastFont)
{
if (LastFont)
LastFont->drop();
LastFont = font;
if (LastFont)
LastFont->grab();
recalculateSize();
}
IGUISpriteBank* sprites = skin->getSpriteBank();
core::rect<s32> rect = AbsoluteRect;
......
......@@ -11,6 +11,7 @@
#include "IGUIContextMenu.h"
#include "irrString.h"
#include "irrArray.h"
#include "IGUIFont.h"
namespace irr
{
......@@ -137,6 +138,7 @@ namespace gui
u32 ChangeTime;
IGUIElement* EventParent;
bool AllowFocus;
IGUIFont *LastFont;
};
......
......@@ -40,6 +40,17 @@ void CGUIMenu::draw()
IGUISkin* skin = Environment->getSkin();
IGUIFont* font = skin->getFont(EGDF_MENU);
if (font != LastFont)
{
if (LastFont)
LastFont->drop();
LastFont = font;
if (LastFont)
LastFont->grab();
recalculateSize();
}
core::rect<s32> rect = AbsoluteRect;
......
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