fix tabbar flying-close issue

This commit is contained in:
Jinhao
2015-11-02 23:39:32 +08:00
parent 9fd1a594cb
commit 67752172a0
2 changed files with 47 additions and 17 deletions

View File

@@ -140,7 +140,16 @@ namespace nana
: public drawer_trigger
{
public:
enum toolbox_button_t{ButtonAdd, ButtonScroll, ButtonList, ButtonClose};
//enum toolbox_button_t{ButtonAdd, ButtonScroll, ButtonList, ButtonClose}; //deprecated
enum class kits
{
add,
scroll,
list,
close
};
trigger();
~trigger();
void activate(std::size_t);
@@ -158,7 +167,7 @@ namespace nana
void tab_image(size_t, const nana::paint::image&);
void text(std::size_t, const nana::string&);
nana::string text(std::size_t) const;
bool toolbox_button(toolbox_button_t, bool);
bool toolbox(kits, bool);
private:
void attached(widget_reference, graph_reference) override;
void detached() override;
@@ -182,18 +191,28 @@ namespace nana
typedef Type value_type; ///< The type of element data which is stored in the tabbar.
typedef drawerbase::tabbar::item_renderer item_renderer; ///< A user-defined item renderer should be derived from this interface.
//These member types is deprecated, they will be removed in Nana 1.3
struct button_add{}; ///< The type identifies the add button of the tabbar's toolbox.
struct button_scroll{}; ///< The type identifies the scroll button of the tabbar's toolbox.
struct button_list{}; ///< The type identifies the list button of the tabbar's toolbox.
struct button_close{}; ///< The type identifies the close button of the tabbar's toolbox.
/// A template class identifies the buttons of the tabbar<61>s toolbox. Refer to notes for more details.
//This template class is deprecated, it will be removed in 1.3
/// A template class identifies the buttons of the tabbar's toolbox. Refer to notes for more details.
template<typename ButtonAdd = nana::null_type, typename ButtonScroll = nana::null_type, typename ButtonList = nana::null_type, typename ButtonClose = nana::null_type>
struct button_container
{
typedef meta::fixed_type_set<ButtonAdd, ButtonScroll, ButtonList, ButtonClose> type_set;
};
enum class kits
{
add, ///< The type identifies the add button of the tabbar's toolbox.
scroll, ///< The type identifies the scroll button of the tabbar's toolbox
list, ///< The type identifies the list button of the tabbar's toolbox
close ///< The type identifies the close button of the tabbar's toolbox
};
tabbar()
{
evt_agent_.reset(new drawerbase::tabbar::event_agent<value_type, drawer_trigger_t>(*this, this->get_drawer_trigger()));
@@ -304,22 +323,30 @@ namespace nana
auto & tg = this->get_drawer_trigger();
bool redraw = false;
using inner_kits = drawerbase::tabbar::trigger::kits;
if(type_set::template count<button_add>::value)
redraw |= tg.toolbox_button(tg.ButtonAdd, enable);
redraw |= tg.toolbox(inner_kits::add, enable);
if(type_set::template count<button_scroll>::value)
redraw |= tg.toolbox_button(tg.ButtonScroll, enable);
redraw |= tg.toolbox(inner_kits::scroll, enable);
if(type_set::template count<button_list>::value)
redraw |= tg.toolbox_button(tg.ButtonList, enable);
redraw |= tg.toolbox(inner_kits::add, enable);
if(type_set::template count<button_close>::value)
redraw |= tg.toolbox_button(tg.ButtonClose, enable);
redraw |= tg.toolbox(inner_kits::close, enable);
if(redraw)
API::refresh_window(this->handle());
}
void toolbox(kits kit, bool enable)
{
if (this->get_drawer_trigger().toolbox(kit, enable))
API::refresh_window(this->handle());
}
void text(std::size_t pos, const nana::string& str) /// Sets the title of the specified item, If pos is invalid, the method throws an std::out_of_range object.
{
this->get_drawer_trigger().text(pos, str);