Patch for set Visibility of TabItems

Mind

04-05-2011 15:48:51

Hi,

i need a feature to set TabItems to visible yes/no.
So i add this feature and it seems to work 8)

I post the patch in hope of adding this in next version :wink:



Index: MyGUIEngine/include/MyGUI_TabItem.h
===================================================================
--- MyGUIEngine/include/MyGUI_TabItem.h (revision 4294)
+++ MyGUIEngine/include/MyGUI_TabItem.h (working copy)
@@ -45,11 +45,17 @@
//! Set button width
void setButtonWidth(int _value = DEFAULT);

+ void setTabVisible(bool _value);
+ bool getTabVisible();
+
protected:
virtual void initialiseOverride();
virtual void shutdownOverride();

virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
+
+ private:
+ bool mTabVisible;
};

} // namespace MyGUI
Index: MyGUIEngine/src/MyGUI_TabControl.cpp
===================================================================
--- MyGUIEngine/src/MyGUI_TabControl.cpp (revision 4294)
+++ MyGUIEngine/src/MyGUI_TabControl.cpp (working copy)
@@ -874,6 +874,11 @@
break;
}

+ if(!info.item->getVisible())
+ {
+ continue;
+ }
+
// проверяем физическое наличие кнопки
if (count >= mItemButton.size())
_createItemButton();
@@ -1017,6 +1022,11 @@
{
break;
}
+
+ if(!info.item->getTabVisible())
+ {
+ continue;
+ }

// проверяем физическое наличие кнопки
if (count >= mItemButton.size())
Index: MyGUIEngine/src/MyGUI_TabItem.cpp
===================================================================
--- MyGUIEngine/src/MyGUI_TabItem.cpp (revision 4294)
+++ MyGUIEngine/src/MyGUI_TabItem.cpp (working copy)
@@ -25,7 +25,7 @@
namespace MyGUI
{

- TabItem::TabItem()
+ TabItem::TabItem() : mTabVisible(true)
{
}

@@ -82,4 +82,26 @@
eventChangeProperty(this, _key, _value);
}

+ void TabItem::setTabVisible(bool _value)
+ {
+ TabControl* owner = getParent() != nullptr ? getParent()->castType<TabControl>(false) : nullptr;
+ if (owner != nullptr)
+ {
+ if(!_value && owner->getItemSelected() == this)
+ {
+ owner->_showItem(this, false, false);
+ }
+ }
+
+ mTabVisible = _value;
+
+ if (owner != nullptr)
+ owner->updateBar();
+ }
+
+ bool TabItem::getTabVisible()
+ {
+ return mTabVisible;
+ }
+
} // namespace MyGUI

snoefler

05-05-2011 13:02:52

Yeah this is a great feature, exaclty what Iam looking for.

I applied it manually with the 3.2.0 RC1 and it workded.

But the offsets are not completely correct for 3.2.0RC1, I think this is a patch for the latest SVN version.
Perhaps a admin can play this patch back in the trunk?