Merge branch 'hotfix-1.5.5' of https://github.com/cnjinhao/nana into hotfix-1.5.5

This commit is contained in:
cnjinhao 2017-09-22 15:45:38 +08:00
commit f14fc9bf6d
5 changed files with 34 additions and 2 deletions

View File

@ -50,6 +50,7 @@
<Unit filename="../../source/datetime.cpp" /> <Unit filename="../../source/datetime.cpp" />
<Unit filename="../../source/deploy.cpp" /> <Unit filename="../../source/deploy.cpp" />
<Unit filename="../../source/detail/platform_abstraction.cpp" /> <Unit filename="../../source/detail/platform_abstraction.cpp" />
<Unit filename="../../source/detail/platform_spec_posix.cpp" />
<Unit filename="../../source/detail/platform_spec_windows.cpp" /> <Unit filename="../../source/detail/platform_spec_windows.cpp" />
<Unit filename="../../source/filesystem/filesystem.cpp" /> <Unit filename="../../source/filesystem/filesystem.cpp" />
<Unit filename="../../source/gui/animation.cpp" /> <Unit filename="../../source/gui/animation.cpp" />

View File

@ -61,6 +61,7 @@ namespace nana
void focus(graph_reference, const arg_focus&) override; void focus(graph_reference, const arg_focus&) override;
void mouse_wheel(graph_reference, const arg_wheel&) override; void mouse_wheel(graph_reference, const arg_wheel&) override;
void dbl_click(graph_reference, const arg_mouse&) override;
void mouse_down(graph_reference, const arg_mouse&) override; void mouse_down(graph_reference, const arg_mouse&) override;
void mouse_move(graph_reference, const arg_mouse&) override; void mouse_move(graph_reference, const arg_mouse&) override;
void mouse_up(graph_reference, const arg_mouse& arg) override; void mouse_up(graph_reference, const arg_mouse& arg) override;

View File

@ -556,6 +556,7 @@ namespace nana{ namespace widgets
virtual void merge_lines(std::size_t first, std::size_t second) = 0; virtual void merge_lines(std::size_t first, std::size_t second) = 0;
//Calculates how many lines the specified line of text takes with a specified pixels of width. //Calculates how many lines the specified line of text takes with a specified pixels of width.
virtual void add_lines(std::size_t pos, std::size_t lines) = 0; virtual void add_lines(std::size_t pos, std::size_t lines) = 0;
virtual void prepare() = 0;
virtual void pre_calc_line(std::size_t line, unsigned pixels) = 0; virtual void pre_calc_line(std::size_t line, unsigned pixels) = 0;
virtual void pre_calc_lines(unsigned pixels) = 0; virtual void pre_calc_lines(unsigned pixels) = 0;
virtual std::size_t take_lines() const = 0; virtual std::size_t take_lines() const = 0;
@ -668,6 +669,12 @@ namespace nana{ namespace widgets
} }
} }
void prepare() override
{
auto const line_count = editor_.textbase().lines();
this->sections_.resize(line_count);
}
void pre_calc_line(std::size_t pos, unsigned) override void pre_calc_line(std::size_t pos, unsigned) override
{ {
auto const & text = editor_.textbase().getline(pos); auto const & text = editor_.textbase().getline(pos);
@ -781,6 +788,12 @@ namespace nana{ namespace widgets
} }
} }
void prepare() override
{
auto const lines = editor_.textbase().lines();
linemtr_.resize(lines);
}
void pre_calc_line(std::size_t line, unsigned pixels) override void pre_calc_line(std::size_t line, unsigned pixels) override
{ {
const string_type& lnstr = editor_.textbase().getline(line); const string_type& lnstr = editor_.textbase().getline(line);
@ -1234,7 +1247,7 @@ namespace nana{ namespace widgets
void text_editor::typeface_changed() void text_editor::typeface_changed()
{ {
impl_->capacities.behavior->pre_calc_lines(width_pixels()); _m_reset_content_size(true);
} }
void text_editor::indent(bool enb, std::function<std::string()> generator) void text_editor::indent(bool enb, std::function<std::string()> generator)
@ -2886,10 +2899,14 @@ namespace nana{ namespace widgets
auto text_lines = textbase().lines(); auto text_lines = textbase().lines();
if (text_lines <= max_lines) if (text_lines <= max_lines)
{ {
impl_->capacities.behavior->prepare();
auto const width_px = _m_width_px(true);
std::size_t lines = 0; std::size_t lines = 0;
for (std::size_t i = 0; i < text_lines; ++i) for (std::size_t i = 0; i < text_lines; ++i)
{ {
impl_->capacities.behavior->pre_calc_line(i, csize.width); impl_->capacities.behavior->pre_calc_line(i, width_px);
lines += impl_->capacities.behavior->take_lines(i); lines += impl_->capacities.behavior->take_lines(i);
if (lines > max_lines) if (lines > max_lines)

View File

@ -560,6 +560,12 @@ namespace nana
impl_->editor()->reset_caret(); impl_->editor()->reset_caret();
API::dev::lazy_refresh(); API::dev::lazy_refresh();
} }
void drawer::dbl_click(graph_reference, const arg_mouse& arg)
{
if (impl_->mouse_button(arg, true))
API::dev::lazy_refresh();
}
void drawer::mouse_down(graph_reference, const arg_mouse& arg) void drawer::mouse_down(graph_reference, const arg_mouse& arg)
{ {
@ -599,7 +605,10 @@ namespace nana
{ {
impl_->editor()->respond_char(arg); impl_->editor()->respond_char(arg);
if (impl_->editor()->try_refresh()) if (impl_->editor()->try_refresh())
{
impl_->draw_spins();
API::dev::lazy_refresh(); API::dev::lazy_refresh();
}
} }
void drawer::resized(graph_reference, const arg_resized&) void drawer::resized(graph_reference, const arg_resized&)

View File

@ -240,12 +240,16 @@ namespace paint
graphics::graphics(graphics&& other) graphics::graphics(graphics&& other)
: impl_(std::move(other.impl_)) : impl_(std::move(other.impl_))
{ {
other.impl_.reset(new implementation);
} }
graphics& graphics::operator=(graphics&& other) graphics& graphics::operator=(graphics&& other)
{ {
if (this != &other) if (this != &other)
{
impl_ = std::move(other.impl_); impl_ = std::move(other.impl_);
other.impl_.reset(new implementation);
}
return *this; return *this;
} }