Merge branch 'develop' of https://github.com/kmribti/nana into kmribti-develop
This commit is contained in:
commit
fd2a15b05a
@ -83,8 +83,8 @@ namespace nana
|
|||||||
using size_type = std::size_t; ///< A type to count the number of elements.
|
using size_type = std::size_t; ///< A type to count the number of elements.
|
||||||
|
|
||||||
toolbar() = default;
|
toolbar() = default;
|
||||||
toolbar(window, bool visible);
|
toolbar(window, bool visible, bool detached=false);
|
||||||
toolbar(window, const rectangle& = rectangle(), bool visible = true);
|
toolbar(window, const rectangle& = rectangle(), bool visible = true, bool detached = false);
|
||||||
|
|
||||||
void separate(); ///< Adds a separator.
|
void separate(); ///< Adds a separator.
|
||||||
void append(const ::std::string& text, const nana::paint::image& img); ///< Adds a control button.
|
void append(const ::std::string& text, const nana::paint::image& img); ///< Adds a control button.
|
||||||
@ -92,6 +92,13 @@ namespace nana
|
|||||||
bool enable(size_type index) const;
|
bool enable(size_type index) const;
|
||||||
void enable(size_type index, bool enable_state);
|
void enable(size_type index, bool enable_state);
|
||||||
void scale(unsigned s); ///< Sets the scale of control button.
|
void scale(unsigned s); ///< Sets the scale of control button.
|
||||||
|
|
||||||
|
void go_right();
|
||||||
|
|
||||||
|
bool detached() { return detached_; };
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool detached_;
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
#endif
|
#endif
|
||||||
|
@ -34,6 +34,7 @@ namespace nana
|
|||||||
std::string text;
|
std::string text;
|
||||||
nana::paint::image image;
|
nana::paint::image image;
|
||||||
unsigned pixels{0};
|
unsigned pixels{0};
|
||||||
|
unsigned position{ 0 }; // last item position.
|
||||||
nana::size textsize;
|
nana::size textsize;
|
||||||
bool enable{true};
|
bool enable{true};
|
||||||
|
|
||||||
@ -78,6 +79,16 @@ namespace nana
|
|||||||
insert(cont_.size(), text, nana::paint::image(), item_type::kind::button);
|
insert(cont_.size(), text, nana::paint::image(), item_type::kind::button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void go_right()
|
||||||
|
{
|
||||||
|
right_ = cont_.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t right()
|
||||||
|
{
|
||||||
|
return right_;
|
||||||
|
}
|
||||||
|
|
||||||
void insert(size_type pos)
|
void insert(size_type pos)
|
||||||
{
|
{
|
||||||
if(pos < cont_.size())
|
if(pos < cont_.size())
|
||||||
@ -107,6 +118,7 @@ namespace nana
|
|||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
container_type cont_;
|
container_type cont_;
|
||||||
|
size_t right_{ npos };
|
||||||
};
|
};
|
||||||
|
|
||||||
class item_renderer
|
class item_renderer
|
||||||
@ -224,6 +236,7 @@ namespace nana
|
|||||||
if (item)
|
if (item)
|
||||||
{
|
{
|
||||||
_m_calc_pixels(item, false);
|
_m_calc_pixels(item, false);
|
||||||
|
item->position = x;
|
||||||
ir(x, y, item->pixels, impl_->scale + ir.extra_size, *item, (index == impl_->which ? impl_->state : item_renderer::state_t::normal));
|
ir(x, y, item->pixels, impl_->scale + ir.extra_size, *item, (index == impl_->which ? impl_->state : item_renderer::state_t::normal));
|
||||||
x += item->pixels;
|
x += item->pixels;
|
||||||
}
|
}
|
||||||
@ -234,6 +247,20 @@ namespace nana
|
|||||||
x += 4;
|
x += 4;
|
||||||
}
|
}
|
||||||
++index;
|
++index;
|
||||||
|
if (index == impl_->items.right() && index < impl_->items.size())
|
||||||
|
{
|
||||||
|
int total_x = 0;
|
||||||
|
for (size_t i = index; i < impl_->items.size(); i++) {
|
||||||
|
if (impl_->items.at(i) == nullptr) {
|
||||||
|
total_x += 8; // we assume that separator has width = 8.
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_m_calc_pixels(impl_->items.at(i), false);
|
||||||
|
total_x += impl_->items.at(i)->pixels;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
x = graph.size().width - total_x - 4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,6 +271,8 @@ namespace nana
|
|||||||
widget_ = static_cast< ::nana::toolbar*>(&widget);
|
widget_ = static_cast< ::nana::toolbar*>(&widget);
|
||||||
widget.caption("nana toolbar");
|
widget.caption("nana toolbar");
|
||||||
|
|
||||||
|
if (widget_->detached()) return;
|
||||||
|
|
||||||
impl_->event_size = API::events(widget.parent()).resized.connect_unignorable([this](const arg_resized& arg)
|
impl_->event_size = API::events(widget.parent()).resized.connect_unignorable([this](const arg_resized& arg)
|
||||||
{
|
{
|
||||||
auto wd = widget_->handle();
|
auto wd = widget_->handle();
|
||||||
@ -358,13 +387,10 @@ namespace nana
|
|||||||
std::size_t index = 0;
|
std::size_t index = 0;
|
||||||
for(auto m: impl_->items.container())
|
for(auto m: impl_->items.container())
|
||||||
{
|
{
|
||||||
auto px = static_cast<const int>(m ? m->pixels : 3);
|
unsigned x = static_cast<unsigned>(pos.x);
|
||||||
|
if (m && x >= m->position && x <= (m->position+m->pixels))
|
||||||
if(pos.x < px)
|
|
||||||
return (((!m) || (!m->enable && !want_if_disabled)) ? npos : index);
|
return (((!m) || (!m->enable && !want_if_disabled)) ? npos : index);
|
||||||
|
|
||||||
pos.x -= px;
|
|
||||||
|
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
return npos;
|
return npos;
|
||||||
@ -389,16 +415,23 @@ namespace nana
|
|||||||
}//end namespace drawerbase
|
}//end namespace drawerbase
|
||||||
|
|
||||||
//class toolbar
|
//class toolbar
|
||||||
toolbar::toolbar(window wd, bool visible)
|
toolbar::toolbar(window wd, bool visible, bool detached) :
|
||||||
|
detached_(detached)
|
||||||
{
|
{
|
||||||
create(wd, rectangle(), visible);
|
create(wd, rectangle(), visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
toolbar::toolbar(window wd, const rectangle& r, bool visible)
|
toolbar::toolbar(window wd, const rectangle& r, bool visible, bool detached) :
|
||||||
|
detached_(detached)
|
||||||
{
|
{
|
||||||
create(wd, r, visible);
|
create(wd, r, visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void toolbar::go_right()
|
||||||
|
{
|
||||||
|
get_drawer_trigger().items().go_right();
|
||||||
|
}
|
||||||
|
|
||||||
void toolbar::separate()
|
void toolbar::separate()
|
||||||
{
|
{
|
||||||
get_drawer_trigger().items().separate();
|
get_drawer_trigger().items().separate();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user