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