From d85383e0f8bde85d5c1f0e66383013cd1db4a294 Mon Sep 17 00:00:00 2001 From: codicodi Date: Sun, 14 May 2017 15:16:14 +0200 Subject: [PATCH 1/5] CMake: fix NANA_LINKS for MSVC --- CMakeLists.txt | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f0dc030..20189f26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,7 +100,7 @@ endif(WIN32) if(APPLE) add_definitions(-DAPPLE) include_directories(/opt/X11/include/) - set(NANA_LINKS "${NANA_LINKS} -L/opt/X11/lib/ -liconv") + list(APPEND NANA_LINKS -L/opt/X11/lib/ -liconv) set(ENABLE_AUDIO OFF) elseif(UNIX) add_definitions(-Dlinux) @@ -108,11 +108,11 @@ elseif(UNIX) endif(APPLE) if(UNIX) - set(NANA_LINKS "${NANA_LINKS} -lX11") + list(APPEND NANA_LINKS -lX11) find_package(Freetype) if (FREETYPE_FOUND) include_directories( ${FREETYPE_INCLUDE_DIRS}) - set(NANA_LINKS "${NANA_LINKS} -lXft") + list(APPEND NANA_LINKS -lXft) endif(FREETYPE_FOUND) endif(UNIX) @@ -140,13 +140,13 @@ endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # enable static linkage # GNU || CLang not MinGW if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AND NOT MINGW # set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -pthread") - set(NANA_LINKS "${NANA_LINKS} -static-libgcc -static-libstdc++ -pthread") + list(APPEND NANA_LINKS -static-libgcc -static-libstdc++ -pthread) # message("Setting NANA_LINKS to -static-libgcc -static-libstdc++ -pthread or ${NANA_LINKS}") if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3) # IS_GNUCXX < 5.3 else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3) # set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++fs") # IS_GNUCXX 5.3 or more - set(NANA_LINKS "${NANA_LINKS} -lstdc++fs") + list(APPEND NANA_LINKS -lstdc++fs) endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3) endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AND NOT MINGW @@ -154,7 +154,7 @@ endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # if (APPLE AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # APPLE Clang # set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libstdc++") - set(NANA_LINKS "${NANA_LINKS} -stdlib=libstdc++") + list(APPEND NANA_LINKS -stdlib=libstdc++) endif () @@ -163,11 +163,11 @@ endif () # Find PNG if(NANA_CMAKE_ENABLE_PNG) add_definitions(-DNANA_ENABLE_PNG) - set(NANA_LINKS "${NANA_LINKS} -lpng") if(NANA_CMAKE_LIBPNG_FROM_OS) find_package(PNG) if (PNG_FOUND) include_directories( ${PNG_INCLUDE_DIRS}) + list(APPEND NANA_LINKS ${PNG_LIBRARIES}) add_definitions(-DUSE_LIBPNG_FROM_OS) endif(PNG_FOUND) endif(NANA_CMAKE_LIBPNG_FROM_OS) @@ -176,11 +176,11 @@ endif(NANA_CMAKE_ENABLE_PNG) # Find JPEG if(NANA_CMAKE_ENABLE_JPEG) add_definitions(-DNANA_ENABLE_JPEG) - set(NANA_LINKS "${NANA_LINKS} -ljpeg") if(NANA_CMAKE_LIBJPEG_FROM_OS) find_package(JPEG) if (JPEG_FOUND) - include_directories( ${JPEG_INCLUDE_DIRS}) + include_directories( ${JPEG_INCLUDE_DIR}) + list(APPEND NANA_LINKS ${JPEG_LIBRARY}) add_definitions(-DUSE_LIBJPEG_FROM_OS) endif(JPEG_FOUND) endif(NANA_CMAKE_LIBJPEG_FROM_OS) @@ -193,7 +193,7 @@ if(NANA_CMAKE_ENABLE_AUDIO) find_package(ASOUND) if (ASOUND_FOUND) include_directories( ${ASOUND_INCLUDE_DIRS}) - set(NANA_LINKS "${NANA_LINKS} -lasound") + list(APPEND NANA_LINKS -lasound) else(ASOUND_FOUND) message(FATAL_ERROR "libasound is not found") endif(ASOUND_FOUND) @@ -217,7 +217,7 @@ elseif (NANA_CMAKE_FIND_BOOST_FILESYSTEM OR NANA_CMAKE_BOOST_FILESYSTEM_FORCE) if (Boost_FOUND) add_definitions(-DNANA_BOOST_FILESYSTEM_AVAILABLE) include_directories(SYSTEM "${Boost_INCLUDE_DIR}") - set(NANA_LINKS "${NANA_LINKS} ${Boost_LIBRARIES}") ###### FIRST !!!!!!!!!!!!!!!!! add is not first + list(APPEND NANA_LINKS ${Boost_LIBRARIES}) ###### FIRST !!!!!!!!!!!!!!!!! add is not first endif (Boost_FOUND) set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_STATIC_RUNTIME ON) # ?? From 260715dd0beae3363e43cdfa597709871e6bb070 Mon Sep 17 00:00:00 2001 From: FirstTimeInForever Date: Sun, 21 May 2017 02:11:43 +0300 Subject: [PATCH 2/5] Fix VS2017 project win32 config For some reason win32 configuration was broken. There were no include paths and other stuff were just set to their defaults. --- build/vc2017/nana.vcxproj | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/build/vc2017/nana.vcxproj b/build/vc2017/nana.vcxproj index 6ee38270..b1e450b8 100644 --- a/build/vc2017/nana.vcxproj +++ b/build/vc2017/nana.vcxproj @@ -23,7 +23,7 @@ {42D0520F-EFA5-4831-84FE-2B9085301C5D} Win32Proj nana - 10.0.14393.0 + 10.0.15063.0 @@ -82,6 +82,18 @@ ..\..\..\temp\$(ProjectName)\$(PlatformToolset)_$(Configuration)_$(PlatformShortName)\ $(ProjectName)_$(PlatformToolset)_$(Configuration)_$(PlatformShortName) + + ../bin/ + ..\..\..\temp\$(ProjectName)\$(PlatformToolset)_$(Configuration)_$(PlatformShortName)\ + $(ProjectName)_$(PlatformToolset)_$(Configuration)_$(PlatformShortName) + ..\..\include;$(IncludePath) + + + ../bin/ + ..\..\..\temp\$(ProjectName)\$(PlatformToolset)_$(Configuration)_$(PlatformShortName)\ + $(ProjectName)_$(PlatformToolset)_$(Configuration)_$(PlatformShortName) + ..\..\include;$(IncludePath) + From a92b3e4274a183fe85015530b208ef9e2d88e47a Mon Sep 17 00:00:00 2001 From: Leonardo Backes Vargas Date: Sun, 28 May 2017 12:16:26 -0300 Subject: [PATCH 3/5] Fix constness on const functions with nana::any and related casts. --- include/nana/gui/widgets/listbox.hpp | 2 +- include/nana/gui/widgets/tabbar.hpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index f3cc09df..552b2e36 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -893,7 +893,7 @@ namespace nana } template - T* value_ptr() const + T const * value_ptr() const { return any_cast(_m_value()); } diff --git a/include/nana/gui/widgets/tabbar.hpp b/include/nana/gui/widgets/tabbar.hpp index f22e6e5c..0e2e2e9c 100644 --- a/include/nana/gui/widgets/tabbar.hpp +++ b/include/nana/gui/widgets/tabbar.hpp @@ -237,9 +237,9 @@ namespace nana return this->get_drawer_trigger().activated(); } - value_type & at(std::size_t pos) const /// Returns pos'th element + value_type const & at(std::size_t pos) const /// Returns pos'th element { - return static_cast(this->get_drawer_trigger().at(pos)); + return any_cast(this->get_drawer_trigger().at(pos)); } void close_fly(bool fly) /// Draw or not a close button in each tab. From d384a6a8e7629bbcdf19049b9b2411ac85ee23db Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sun, 4 Jun 2017 05:47:57 +0800 Subject: [PATCH 4/5] fix issue that graphics::gradual_rectangle modifies fgcolor unexpectedly --- source/detail/mswin/platform_spec.hpp | 3 +-- source/detail/platform_spec_posix.cpp | 29 ------------------------- source/detail/platform_spec_windows.cpp | 5 ----- source/detail/posix/platform_spec.hpp | 3 +-- source/gui/widgets/listbox.cpp | 11 ---------- source/paint/graphics.cpp | 9 +++++--- 6 files changed, 8 insertions(+), 52 deletions(-) diff --git a/source/detail/mswin/platform_spec.hpp b/source/detail/mswin/platform_spec.hpp index 6de8c4e2..ed4b0d9a 100644 --- a/source/detail/mswin/platform_spec.hpp +++ b/source/detail/mswin/platform_spec.hpp @@ -1,7 +1,7 @@ /* * Platform Specification Implementation * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -144,7 +144,6 @@ namespace detail drawable_impl_type(); ~drawable_impl_type(); - void fgcolor(const ::nana::color&); //deprecated unsigned get_color() const; unsigned get_text_color() const; void set_color(const ::nana::color&); diff --git a/source/detail/platform_spec_posix.cpp b/source/detail/platform_spec_posix.cpp index 89ea7b8c..0b7e9538 100644 --- a/source/detail/platform_spec_posix.cpp +++ b/source/detail/platform_spec_posix.cpp @@ -423,35 +423,6 @@ namespace detail } } - void drawable_impl_type::fgcolor(const ::nana::color& clr) - { - auto rgb = clr.px_color().value; - - if (rgb != current_color_) - { - auto & spec = nana::detail::platform_spec::instance(); - platform_scope_guard psg; - - current_color_ = rgb; - switch(spec.screen_depth()) - { - case 16: - rgb = ((((rgb >> 16) & 0xFF) * 31 / 255) << 11) | - ((((rgb >> 8) & 0xFF) * 63 / 255) << 5) | - (rgb & 0xFF) * 31 / 255; - break; - } - ::XSetForeground(spec.open_display(), context, rgb); - ::XSetBackground(spec.open_display(), context, rgb); -#if defined(NANA_USE_XFT) - xft_fgcolor.color.red = ((0xFF0000 & rgb) >> 16) * 0x101; - xft_fgcolor.color.green = ((0xFF00 & rgb) >> 8) * 0x101; - xft_fgcolor.color.blue = (0xFF & rgb) * 0x101; - xft_fgcolor.color.alpha = 0xFFFF; -#endif - } - } - platform_scope_guard::platform_scope_guard() { platform_spec::instance().lock_xlib(); diff --git a/source/detail/platform_spec_windows.cpp b/source/detail/platform_spec_windows.cpp index 3e4e044b..eb58c603 100644 --- a/source/detail/platform_spec_windows.cpp +++ b/source/detail/platform_spec_windows.cpp @@ -221,11 +221,6 @@ namespace detail ::DeleteObject(round_region.handle); } - void drawable_impl_type::fgcolor(const ::nana::color& clr) - { - set_text_color(clr); - } - unsigned drawable_impl_type::get_color() const { return color_; diff --git a/source/detail/posix/platform_spec.hpp b/source/detail/posix/platform_spec.hpp index f1f32448..2ada1eac 100644 --- a/source/detail/posix/platform_spec.hpp +++ b/source/detail/posix/platform_spec.hpp @@ -1,7 +1,7 @@ /* * Platform Specification Implementation * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -101,7 +101,6 @@ namespace detail drawable_impl_type(); ~drawable_impl_type(); - void fgcolor(const ::nana::color&); //deprecated unsigned get_color() const; unsigned get_text_color() const; void set_color(const ::nana::color&); diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 1b33d880..3aa2262f 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -2248,7 +2248,6 @@ namespace nana if (seq.empty()) return 0; - //return (header.position(seq[0], nullptr) - this->content_view->origin().x + r.x); //deprecated return header.range(seq.front()).first + r.x - this->content_view->origin().x; } @@ -3226,14 +3225,10 @@ namespace nana auto i = essence_->header.column_from_point(x); if (i == npos) - //i = essence_->header.boundary(essence_->header.position(grab, nullptr) >= x); //deprecated i = essence_->header.boundary(essence_->header.range(grab).first >= x); if(grab != i) { - //unsigned item_pixels = 0; - //auto item_x = essence_->header.position(i, &item_pixels); //deprecated - auto item_rg = essence_->header.range(i); //Get the item pos @@ -3319,7 +3314,6 @@ namespace nana _m_draw_header_item(fl_graph, margin, rectangle{ fl_graph.size()}, colors::white, col, item_state::floated); - //auto xpos = essence_->header.position(col.index, nullptr) + pos.x - grabs_.start_pos; //deprecated auto xpos = essence_->header.range(col.index).first + pos.x - grabs_.start_pos; essence_->graph->blend(rectangle{ point{ xpos - essence_->content_view->origin().x + rect.x, rect.y } , fl_graph.size() }, fl_graph, {}, 0.5); } @@ -3405,7 +3399,6 @@ namespace nana auto & ptr_where = essence_->pointer_where; - //int item_top = rect.y - (origin.y % item_height_px); //deprecated auto first_disp = essence_->first_display(); point item_coord{ @@ -3444,8 +3437,6 @@ namespace nana ind->detach(); } - //const int x = essence_->item_xpos(rect); //deprecated - //Here we draw the root categ (0) or a first item if the first drawing is not a categ.(item!=npos)) if (idx.cat == 0 || !idx.is_category()) { @@ -3579,7 +3570,6 @@ namespace nana //Draw selecting inner rectangle if (item.flags.selected && (categ.expand == false)) - //_m_draw_item_border(r.x, y, (std::min)(r.width, width - essence_->content_view->origin().x)); //deprecated _m_draw_item_border(y); } @@ -3816,7 +3806,6 @@ namespace nana //Draw selecting inner rectangle if (item.flags.selected) - //_m_draw_item_border(content_r.x, coord.y, show_w); //deprecated _m_draw_item_border(coord.y); } diff --git a/source/paint/graphics.cpp b/source/paint/graphics.cpp index b3bedd40..18a9df2a 100644 --- a/source/paint/graphics.cpp +++ b/source/paint/graphics.cpp @@ -1208,7 +1208,8 @@ namespace paint unsigned last_color = (int(r) << 16) | (int(g) << 8) | int(b); Display * disp = nana::detail::platform_spec::instance().open_display(); - impl_->handle->fgcolor(static_cast(last_color)); + impl_->handle->set_color(static_cast(last_color)); + impl_->handle->update_color(); const int endpos = deltapx + (vertical ? rct.y : rct.x); if (endpos > 0) { @@ -1223,7 +1224,8 @@ namespace paint if (new_color != last_color) { last_color = new_color; - impl_->handle->fgcolor(static_cast(last_color)); + impl_->handle->set_color(static_cast(last_color)); + impl_->handle->update_color(); } } } @@ -1238,7 +1240,8 @@ namespace paint if (new_color != last_color) { last_color = new_color; - impl_->handle->fgcolor(static_cast(last_color)); + impl_->handle->set_color(static_cast(last_color)); + impl_->handle->update_color(); } } } From bd38e96ed78e9600b9fdee178e68755ffba25edd Mon Sep 17 00:00:00 2001 From: Jinhao Date: Thu, 8 Jun 2017 00:44:27 +0800 Subject: [PATCH 5/5] fix issue that textbox&spinbox don't update immediately --- source/gui/widgets/spinbox.cpp | 6 +++++- source/gui/widgets/textbox.cpp | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/source/gui/widgets/spinbox.cpp b/source/gui/widgets/spinbox.cpp index 87cec724..2cb89870 100644 --- a/source/gui/widgets/spinbox.cpp +++ b/source/gui/widgets/spinbox.cpp @@ -441,7 +441,10 @@ namespace nana text = to_wstring(modifier_.prefix + range_->value() + modifier_.suffix); if (editor_->text() != text) + { editor_->text(text, false); + editor_->try_refresh(); + } _m_draw_spins(spin_stated_); } @@ -736,7 +739,8 @@ namespace nana if (editor) { editor->text(to_wstring(text), false); - API::refresh_window(*this); + if (editor->try_refresh()) + API::update_window(*this); } } }//end namespace nana diff --git a/source/gui/widgets/textbox.cpp b/source/gui/widgets/textbox.cpp index 909cde92..5ae9454b 100644 --- a/source/gui/widgets/textbox.cpp +++ b/source/gui/widgets/textbox.cpp @@ -738,7 +738,9 @@ namespace drawerbase { if (editor) { editor->text(to_wstring(str), false); - API::update_window(this->handle()); + + if (editor->try_refresh()) + API::update_window(this->handle()); } }