fix tabbar flying-close issue
This commit is contained in:
parent
9fd1a594cb
commit
67752172a0
@ -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’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);
|
||||
|
||||
@ -435,6 +435,7 @@ namespace nana
|
||||
{
|
||||
if ((nullptr == evt_agent_) || evt_agent_->removed(pos))
|
||||
{
|
||||
API::show_window(iterator_at(pos)->relative, false);
|
||||
list_.erase(iterator_at(pos));
|
||||
_m_adjust();
|
||||
|
||||
@ -459,6 +460,8 @@ namespace nana
|
||||
basis_.scroll_pixels = 0;
|
||||
}
|
||||
|
||||
if (basis_.active != ::nana::npos)
|
||||
API::show_window(iterator_at(basis_.active)->relative, true);
|
||||
if(evt_agent_)
|
||||
evt_agent_->activated(basis_.active);
|
||||
return true;
|
||||
@ -1192,23 +1195,23 @@ namespace nana
|
||||
return layouter_->text(i);
|
||||
}
|
||||
|
||||
bool trigger::toolbox_button(toolbox_button_t btn, bool enable)
|
||||
bool trigger::toolbox(kits btn, bool enable)
|
||||
{
|
||||
toolbox::button_t tb = toolbox::ButtonSize;
|
||||
toolbox & tbobj = layouter_->toolbox_object();
|
||||
auto tb = toolbox::ButtonSize;
|
||||
auto& tbox = layouter_->toolbox_object();
|
||||
switch(btn)
|
||||
{
|
||||
case trigger::ButtonAdd:
|
||||
case kits::add:
|
||||
tb = toolbox::ButtonAdd; break;
|
||||
case trigger::ButtonList:
|
||||
case kits::list:
|
||||
tb = toolbox::ButtonList; break;
|
||||
case trigger::ButtonClose:
|
||||
case kits::close:
|
||||
tb = toolbox::ButtonClose; break;
|
||||
case trigger::ButtonScroll:
|
||||
tbobj.enable(toolbox::ButtonScrollBack, enable);
|
||||
return tbobj.enable(tbobj.ButtonScrollNext, enable);
|
||||
case kits::scroll:
|
||||
tbox.enable(toolbox::ButtonScrollBack, enable);
|
||||
return tbox.enable(tbox.ButtonScrollNext, enable);
|
||||
}
|
||||
return (tb != toolbox::ButtonSize ? tbobj.enable(tb, enable) : false);
|
||||
return (tb != toolbox::ButtonSize ? tbox.enable(tb, enable) : false);
|
||||
}
|
||||
|
||||
void trigger::attached(widget_reference widget, graph_reference graph)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user