From 06e1b7a712086a7cc78fc316f7f350705dac089c Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Tue, 15 Nov 2016 03:36:01 +0100 Subject: [PATCH 1/6] test with nana-demo/hotfix --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 170ef287..ba037042 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,7 +56,7 @@ matrix: - llvm-toolchain-precise before_install: - - git clone --depth=1 --branch=develop https://github.com/qPCR4vir/nana-demo.git ../nana-demo + - git clone --depth=1 --branch=hotfix-1.4 https://github.com/qPCR4vir/nana-demo.git ../nana-demo - export PATH="$HOME/bin:$PATH" - mkdir ~/bin - wget --no-check-certificate --no-clobber -O /tmp/tools/cmake https://cmake.org/files/v3.4/cmake-3.4.0-rc3-Linux-x86_64.sh || true From be6625b89041911b47a4e9a4c700ff0185b025fb Mon Sep 17 00:00:00 2001 From: dankan1890 Date: Thu, 17 Nov 2016 20:48:56 +0100 Subject: [PATCH 2/6] Disable display of field_title with an empty title. --- source/gui/widgets/group.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/gui/widgets/group.cpp b/source/gui/widgets/group.cpp index 615bfac2..d2b7b91b 100644 --- a/source/gui/widgets/group.cpp +++ b/source/gui/widgets/group.cpp @@ -77,6 +77,9 @@ namespace nana{ if (options.empty()) place_content.field_display(field_options, false); + + if (caption.caption().empty()) + place_content.field_display(field_title, false); } }; From 8e8e5c484702060f74aa94e618e862d198a6ba21 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sat, 26 Nov 2016 06:13:18 +0800 Subject: [PATCH 3/6] add contributor info --- source/gui/widgets/group.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/gui/widgets/group.cpp b/source/gui/widgets/group.cpp index d2b7b91b..3ba3179b 100644 --- a/source/gui/widgets/group.cpp +++ b/source/gui/widgets/group.cpp @@ -12,6 +12,9 @@ * @Author: Stefan Pfeifer(st-321), Ariel Vina-Rodriguez (qPCR4vir) * * @brief group is a widget used to visually group and layout other widgets. + * + * @contributor: + * dankan1890(https://github.com/dankan1890) */ From b23cfc8888726489a0e0ed168e4943aa71db2e1f Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sun, 27 Nov 2016 11:17:47 +0800 Subject: [PATCH 4/6] fix listbox bordless bug(#170) --- include/nana/gui/widgets/listbox.hpp | 2 - source/gui/widgets/listbox.cpp | 177 +++++++++++++-------------- 2 files changed, 88 insertions(+), 91 deletions(-) diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index 19fe1093..d334e8fd 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -757,8 +757,6 @@ namespace nana trigger(); ~trigger(); essence& ess() const; - private: - void _m_draw_border(); private: void attached(widget_reference, graph_reference) override; void detached() override; diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index c2cdedf1..35f4300c 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -2255,8 +2255,12 @@ namespace nana /// @param with_rest: Means whether including extra one item that is not completely contained in reset pixels. size_type number_of_lister_items(bool with_rest) const { - unsigned lister_s = graph->height() - 2 - header_visible_px() - (scroll.h.empty() ? 0 : scroll.scale); - return (lister_s / scheme_ptr->item_height) + (with_rest && (lister_s % scheme_ptr->item_height) ? 1 : 0); + unsigned lister_s = content_area().height - header_visible_px() - (scroll.h.empty() ? 0 : scroll.scale); + + auto item_px = (std::max)(static_castitem_height)>(1), scheme_ptr->item_height); + item_px = scheme_ptr->item_height; + + return (lister_s / item_px) + (with_rest && (lister_s % item_px) ? 1 : 0); } //keep the first selected item in the display area: the distances are in display positions! @@ -2362,42 +2366,31 @@ namespace nana { internal_scope_guard lock; - const unsigned border_px = 1; - const unsigned border_px_twice = (border_px << 1); - - const nana::size sz = graph->size(); - - if ((sz.width <= border_px_twice) || (sz.height <= border_px_twice)) - { - scroll.h.close(); - scroll.v.close(); - return; - } + auto const ctt_area = this->content_area(); // Adjust the ranged column assume the vertical scrollbar is enabled. - auto range_adjusted = this->header.calc_ranged_columns(sz.width - border_px_twice - scroll.scale); - auto columns_pixels = header.pixels(); + auto range_adjusted = this->header.calc_ranged_columns(ctt_area.width - scroll.scale); + auto const columns_pixels = header.pixels(); //H scroll enabled //If range_adjusted is true, it indicates no horzontal scroll bar is enabled. - bool enable_horz = ((!range_adjusted) && (columns_pixels + 4 > sz.width)); // 4px = left and right borders(2px) + left and right gaps(2px) + bool enable_horz = ((!range_adjusted) && (columns_pixels + 2 > ctt_area.width)); // 2px = left and right gaps(2px) unsigned head_scroll = 2 + header_visible_px() + (enable_horz ? scroll.scale : 0); // 2px left and right gaps(2px) - unsigned lister_s = sz.height > head_scroll ? sz.height - head_scroll : 0; - size_type screen_number = (lister_s / scheme_ptr->item_height); + size_type exposed_count = ((ctt_area.height > head_scroll ? ctt_area.height - head_scroll : 0) / scheme_ptr->item_height); //V scroll enabled - auto enable_vert = (lister.the_number_of_expanded() > screen_number); + auto enable_vert = (lister.the_number_of_expanded() > exposed_count); if (enable_vert) { if (!enable_horz) - enable_horz = ((columns_pixels + 2 + scroll.scale) > sz.width); + enable_horz = (columns_pixels + scroll.scale > ctt_area.width); } else if (range_adjusted) { //No vertical scrollbar, then re-adjust the range columns for a new width that excludes vert scroll. - this->header.calc_ranged_columns(sz.width - border_px_twice); + this->header.calc_ranged_columns(ctt_area.width); } //event hander for scrollbars @@ -2417,7 +2410,7 @@ namespace nana API::refresh_window(this->lister.wd_ptr()->handle()); }; - unsigned horz_px = sz.width - border_px_twice; + auto horz_px = ctt_area.width; if (enable_vert) { if (horz_px < scroll.scale) @@ -2426,7 +2419,7 @@ namespace nana horz_px -= scroll.scale; } - unsigned vert_px = sz.height - border_px_twice; + auto vert_px = ctt_area.height; if (enable_horz) { if (vert_px < scroll.scale) @@ -2438,7 +2431,7 @@ namespace nana const auto wd_handle = lister.wd_ptr()->handle(); if (enable_horz && horz_px) { - rectangle r(border_px, static_cast(sz.height - border_px) - static_cast(scroll.scale), horz_px, scroll.scale); + rectangle r(ctt_area.x, ctt_area.bottom() - static_cast(scroll.scale), horz_px, scroll.scale); if(scroll.h.empty()) { scroll.h.create(wd_handle, r); @@ -2453,7 +2446,7 @@ namespace nana if (enable_vert && vert_px) { - rectangle r(static_cast(sz.width - border_px) - static_cast(scroll.scale), border_px, scroll.scale, vert_px); + rectangle r(ctt_area.right() - static_cast(scroll.scale), ctt_area.y, scroll.scale, vert_px); if(scroll.v.empty()) { scroll.v.create(wd_handle, r); @@ -2554,28 +2547,43 @@ namespace nana pos.x += static_cast(scroll.x_offset()) - 2; } - bool rect_header(nana::rectangle& r) const + void draw_peripheral() { - if(header.visible()) - { - if (lister.wd_ptr()->borderless()) - { - r.dimension(graph->size()); - r.height = scheme_ptr->header_height; - return !r.empty(); - } + auto ctt_area = this->content_area(); + + if (!API::widget_borderless(*lister.wd_ptr())) + { + //Draw Border + graph->rectangle(false, static_cast(0x9cb6c5)); + + graph->line({ ctt_area.x, ctt_area.y }, { ctt_area.x, ctt_area.bottom() - 1 }, colors::white); + graph->line({ ctt_area.right() - 1, ctt_area.y }, { ctt_area.right() - 1, ctt_area.bottom() - 1 }); - const unsigned ex_width = 4 + (scroll.v.empty() ? 0 : scroll.scale - 1); - if(graph->width() > ex_width) - { - r.x = 2; - r.y = 1; - r.width = graph->width() - ex_width; - r.height = scheme_ptr->header_height; - return true; - } } - return false; + + if ((scroll.h.empty() == false) && (scroll.v.empty() == false)) + { + graph->rectangle({ ctt_area.right() - static_cast(scroll.scale), + ctt_area.bottom() - static_cast(scroll.scale), + scroll.scale, + scroll.scale }, + true, colors::button_face); + } + } + + rectangle content_area() const + { + rectangle r{ graph->size() }; + + if (!this->listbox_ptr->borderless()) + { + r.x = 1; + r.width -= (r.width > 2 ? 2 : r.width); + + r.y = 1; + r.height -= (r.height > 2 ? 2 : r.height); + } + return r; } unsigned header_visible_px() const @@ -2583,31 +2591,45 @@ namespace nana return (header.visible() ? scheme_ptr->header_height : 0); } + bool rect_header(nana::rectangle& r) const + { + if(header.visible()) + { + r = this->content_area(); + + r.height = scheme_ptr->header_height; + + if (lister.wd_ptr()->borderless()) + return !r.empty(); + + const unsigned ex_width = 2 + (scroll.v.empty() ? 0 : scroll.scale - 1); + if(r.width > ex_width) + { + r.x += 1; + r.width -= ex_width; + return true; + } + } + return false; + } + bool rect_lister(nana::rectangle& r) const { auto head_pixels = header_visible_px(); - unsigned width = (scroll.v.empty() ? 0 : scroll.scale - 1); - unsigned height = (scroll.h.empty() ? 0 : scroll.scale) + head_pixels; + unsigned extr_w = (scroll.v.empty() ? 0 : scroll.scale - 1); + unsigned extr_h = (scroll.h.empty() ? 0 : scroll.scale) + head_pixels; + r = this->content_area(); + r.y += head_pixels; if (!lister.wd_ptr()->borderless()) { - width += 4; - height += 2; - - r.x = 2; - r.y = head_pixels + 1; - } - else - { - r.x = 0; - r.y = head_pixels; + extr_w += 2; + r.x += 1; } - nana::size gsz = graph->size(); - if(gsz.width <= width || gsz.height <= height) return false; + if(r.width <= extr_w || r.height <= extr_h) + return false; - r.width = gsz.width - width; - r.height = gsz.height - height; return true; } @@ -3745,7 +3767,7 @@ namespace nana //Draw selecting inner rectangle if (sel && (categ.expand == false)) { - _m_draw_border(r.x, y, (std::min)(r.width, width - essence_->scroll.x_offset())); + _m_draw_item_border(r.x, y, (std::min)(r.width, width - essence_->scroll.x_offset())); } } @@ -3946,7 +3968,7 @@ namespace nana //Draw selecting inner rectangle if(item.flags.selected) - _m_draw_border(content_r.x, y, show_w); + _m_draw_item_border(content_r.x, y, show_w); } inline_pane * _m_get_inline_pane(const category_t& cat, std::size_t column_pos) const @@ -3985,7 +4007,7 @@ namespace nana return nullptr; } - void _m_draw_border(int x, int y, unsigned width) const + void _m_draw_item_border(int x, int y, unsigned width) const { //Draw selecting inner rectangle rectangle r{ x, y, width, essence_->scheme_ptr->item_height }; @@ -4021,30 +4043,6 @@ namespace nana return *essence_; } - void trigger::_m_draw_border() - { - if (API::widget_borderless(*essence_->lister.wd_ptr())) - return; - - auto & graph = *essence_->graph; - - int right = static_cast(graph.width()) - 1; - int bottom = static_cast(graph.height()) - 1; - - //Draw Border - graph.rectangle(false, static_cast(0x9cb6c5)); - - graph.line({ 1, 1 }, { 1, bottom - 1}, colors::white); - graph.line({ right - 1, 1 }, { right - 1, bottom - 1 }); - - if ((essence_->scroll.h.empty() == false) && (essence_->scroll.v.empty() == false)) - graph.rectangle({ right - static_cast(essence_->scroll.scale), - bottom - static_cast(essence_->scroll.scale), - essence_->scroll.scale, - essence_->scroll.scale }, - true, colors::button_face); - } - void trigger::attached(widget_reference widget, graph_reference graph) { essence_->listbox_ptr = static_cast(&widget); @@ -4081,7 +4079,8 @@ namespace nana drawer_header_->draw(graph, r); if (essence_->rect_lister(r)) drawer_lister_->draw(r); - _m_draw_border(); + + essence_->draw_peripheral(); } void trigger::mouse_move(graph_reference graph, const arg_mouse& arg) @@ -4274,7 +4273,7 @@ namespace nana if(update) { - _m_draw_border(); + essence_->draw_peripheral(); API::dev::lazy_refresh(); } } From abe2f0687f41be64b4e60bb5896084e3ade39ef8 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sun, 27 Nov 2016 12:39:26 +0800 Subject: [PATCH 5/6] fix some compiler warnings and errors for GCC --- source/gui/notifier.cpp | 4 ++++ source/gui/place.cpp | 2 -- source/paint/detail/image_ico_ex.hpp | 6 +++--- source/paint/image.cpp | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/source/gui/notifier.cpp b/source/gui/notifier.cpp index ddecc68d..7db75217 100644 --- a/source/gui/notifier.cpp +++ b/source/gui/notifier.cpp @@ -331,6 +331,8 @@ namespace nana impl_->set_icon(image_ico); impl_->icon = image_ico; } +#else + static_cast(icon_file); //eliminate unused parameter warning #endif } @@ -341,6 +343,8 @@ namespace nana auto icon_handle = paint::image_accessor::icon(image_ico); if (icon_handle) impl_->icons.emplace_back(static_cast(image_ico)); +#else + static_cast(icon_file); //eliminate unused parameter warning #endif } diff --git a/source/gui/place.cpp b/source/gui/place.cpp index b1d26889..30053a00 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -472,8 +472,6 @@ namespace nana if (depth < 0 || start_pos >= div.length()) return{}; - const char* p = div.c_str() + start_pos; - while (depth >= 0) { auto pos = div.find_last_of("<>", start_pos); diff --git a/source/paint/detail/image_ico_ex.hpp b/source/paint/detail/image_ico_ex.hpp index 33f1d96c..9beef0c8 100644 --- a/source/paint/detail/image_ico_ex.hpp +++ b/source/paint/detail/image_ico_ex.hpp @@ -57,7 +57,7 @@ typedef struct class image_ico_ex : public basic_image_pixbuf { - bool _m_read_ico(const void* data, std::size_t size) + bool _m_read_ico(const void* data, std::size_t /*size*/) { auto width = 0; auto height = 0; @@ -94,7 +94,7 @@ class image_ico_ex cursor += offset; auto icon = reinterpret_cast(cursor); auto realBitsCount = static_cast(icon->icHeader.biBitCount); - auto hasAndMask = (realBitsCount < 32) && (height != icon->icHeader.biHeight); + auto hasAndMask = (realBitsCount < 32) && (height != static_cast(icon->icHeader.biHeight)); cursor += 40; pixbuf_.open(width, height); @@ -259,4 +259,4 @@ public: }//end namespace paint }//end namespace nana -#endif \ No newline at end of file +#endif diff --git a/source/paint/image.cpp b/source/paint/image.cpp index 65ad6ba2..6875a198 100644 --- a/source/paint/image.cpp +++ b/source/paint/image.cpp @@ -363,8 +363,9 @@ namespace paint if (!ptr && bytes > 40 /* sizeof(BITMAPINFOHEADER) */ && (40 == *reinterpret_cast(data))) { ptr = std::make_shared(true); } + else #endif - else if (!ptr && bytes > 40 && (0x00010000 == *reinterpret_cast(data))) + if (!ptr && bytes > 40 && (0x00010000 == *reinterpret_cast(data))) ptr = std::make_shared(); } } From 8fef9916a969937a0ca130739f1b031fd3691526 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Mon, 28 Nov 2016 06:23:18 +0800 Subject: [PATCH 6/6] fix filebox warning bug that occurs on Linux --- source/gui/filebox.cpp | 52 +++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/source/gui/filebox.cpp b/source/gui/filebox.cpp index 21c5de30..07752e41 100644 --- a/source/gui/filebox.cpp +++ b/source/gui/filebox.cpp @@ -734,69 +734,73 @@ namespace nana void _m_ok() { - if(0 == selection_.target.size()) + std::string tar = selection_.target; + + if(selection_.target.empty()) { auto file = tb_file_.caption(); if(file.size()) { - if(file[0] == L'.') + if(file[0] == '.') { msgbox mb(*this, caption()); mb.icon(msgbox::icon_warning); - mb<