From b8719f74a81e068097e6e00e86c4ee11ed08674d Mon Sep 17 00:00:00 2001 From: Katsuhisa Yuasa Date: Sun, 28 Oct 2018 21:20:19 +0900 Subject: [PATCH 01/12] Allow multiple file selection with nana::filebox on Windows platform --- include/nana/gui/filebox.hpp | 8 +++- source/gui/filebox.cpp | 85 +++++++++++++++++++++++++++++++----- 2 files changed, 81 insertions(+), 12 deletions(-) diff --git a/include/nana/gui/filebox.hpp b/include/nana/gui/filebox.hpp index f6729318..b5d4e616 100644 --- a/include/nana/gui/filebox.hpp +++ b/include/nana/gui/filebox.hpp @@ -68,8 +68,12 @@ namespace nana }; - ::std::string path() const; - ::std::string file() const; + const ::std::string& path() const; + const ::std::string& file() const; +#if defined(NANA_WINDOWS) + const ::std::vector<::std::string>& files() const; + void allow_multi_select(bool allow); +#endif /// Display the filebox dialog bool show() const; diff --git a/source/gui/filebox.cpp b/source/gui/filebox.cpp index fcaba515..765ff520 100644 --- a/source/gui/filebox.cpp +++ b/source/gui/filebox.cpp @@ -995,7 +995,12 @@ namespace nana window owner; bool open_or_save; +#if defined(NANA_WINDOWS) + bool allow_multi_select; + std::vector files; +#else std::string file; +#endif std::string title; std::string path; std::vector filters; @@ -1012,6 +1017,7 @@ namespace nana impl_->owner = owner; impl_->open_or_save = open; #if defined(NANA_WINDOWS) + impl_->allow_multi_select = false; auto len = ::GetCurrentDirectory(0, nullptr); if(len) { @@ -1068,7 +1074,11 @@ namespace nana filebox& filebox::init_file(const std::string& ifstr) { +#if defined(NANA_WINDOWS) + impl_->files = {ifstr}; +#else impl_->file = ifstr; +#endif return *this; } @@ -1079,22 +1089,41 @@ namespace nana return *this; } - std::string filebox::path() const + const std::string& filebox::path() const { return impl_->path; } - std::string filebox::file() const +#if defined(NANA_WINDOWS) + const std::string& filebox::file() const + { + if(impl_->files.empty()) + { + static const std::string empty = ""; + return empty; + } + else + { + return impl_->files.front(); + } + } + + const std::vector& filebox::files() const + { + return impl_->files; + } +#else + const std::string& filebox::file() const { return impl_->file; } +#endif bool filebox::show() const { #if defined(NANA_WINDOWS) - auto winitfile = to_wstring(impl_->file); - std::wstring wfile(winitfile); - wfile.resize(520); + std::wstring wfile(impl_->files.empty() ? L"" : to_wstring(impl_->files.front())); + wfile.resize(impl_->allow_multi_select ? (520 + 32*256) : 520); OPENFILENAME ofn; memset(&ofn, 0, sizeof ofn); @@ -1159,6 +1188,10 @@ namespace nana if (!impl_->open_or_save) ofn.Flags = OFN_OVERWRITEPROMPT; //Overwrite prompt if it is save mode ofn.Flags |= OFN_NOCHANGEDIR; + if(impl_->allow_multi_select) + { + ofn.Flags |= (OFN_ALLOWMULTISELECT | OFN_EXPLORER); + } { internal_revert_guard revert; @@ -1166,8 +1199,33 @@ namespace nana return false; } - wfile.resize(std::wcslen(wfile.data())); - impl_->file = to_utf8(wfile); + if(impl_->allow_multi_select) + { + wchar_t* str = ofn.lpstrFile; + std::wstring dir = str; + str += (dir.length() + 1); + impl_->files.clear(); + while(*str) + { + std::wstring filename = str; + std::wstring file_path = dir + L"\\" + filename; + impl_->files.emplace_back(to_utf8(file_path)); + str += (filename.length() + 1); + } + impl_->path = to_utf8(dir); + } + else + { + wfile.resize(std::wcslen(wfile.data())); + auto file = to_utf8(wfile); + impl_->files = {file}; + auto tpos = file.find_last_of("\\/"); + if(tpos != file.npos) + impl_->path = file.substr(0, tpos); + else + impl_->path.clear(); + } + #elif defined(NANA_POSIX) using mode = filebox_implement::mode; filebox_implement fb(impl_->owner, (impl_->open_or_save ? mode::open_file : mode::write_file), impl_->title); @@ -1196,16 +1254,23 @@ namespace nana API::modal_window(fb); if(false == fb.file(impl_->file)) return false; -#endif auto tpos = impl_->file.find_last_of("\\/"); if(tpos != impl_->file.npos) impl_->path = impl_->file.substr(0, tpos); else impl_->path.clear(); +#endif return true; - }//end class filebox - + } + +#if defined(NANA_WINDOWS) + void filebox::allow_multi_select(bool allow) + { + impl_->allow_multi_select = allow; + } +#endif + //end class filebox //class directory_picker struct folderbox::implement From ab789837a008d9890bc479b1e1dc5e2822d386fe Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Wed, 7 Nov 2018 19:37:05 +0100 Subject: [PATCH 02/12] cmake-3.12 in travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 42f63050..9d7e849e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,7 +44,7 @@ before_install: - git clone --depth=1 --branch=develop https://github.com/qPCR4vir/nana-demo.git ../nana-demo - export PATH="$HOME/bin:$PATH" #- mkdir ~/bin #it seemd that a bin already exists from 20170901 - - 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 + - wget --no-check-certificate --no-clobber -O /tmp/tools/cmake https://cmake.org/files/v3.12/cmake-3.12.0-rc3-Linux-x86_64.sh || true - chmod -R +x /tmp/tools install: From e7bc1405eced585120b9facb6b024d0daf4a80ba Mon Sep 17 00:00:00 2001 From: James Bremner Date: Sun, 9 Dec 2018 16:01:32 -0500 Subject: [PATCH 03/12] Prevent slider adorn moving when slider disabled Fix suggested be Error Flynn in http://nanapro.org/en-us/forum/index.php?u=/topic/1059/ggslider-appearance-when-disabled#post-2498 --- source/gui/widgets/slider.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/gui/widgets/slider.cpp b/source/gui/widgets/slider.cpp index 20109237..67a67631 100644 --- a/source/gui/widgets/slider.cpp +++ b/source/gui/widgets/slider.cpp @@ -758,6 +758,10 @@ namespace nana void trigger::mouse_move(graph_reference graph, const arg_mouse& arg) { + // check if slider is disabled + if(!API::get_widget(arg.window_handle)->enabled()) + return; // do nothing + bool updated = false; if (model_ptr_->if_trace_slider()) { From 93df609520ff395d6a4d465f6b2e4d799bb9885b Mon Sep 17 00:00:00 2001 From: Jinhao Date: Fri, 14 Dec 2018 07:14:04 +0800 Subject: [PATCH 04/12] fix bug that label renders an additional endline(#365) --- source/gui/widgets/label.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/source/gui/widgets/label.cpp b/source/gui/widgets/label.cpp index 74bedf81..3095ec56 100644 --- a/source/gui/widgets/label.cpp +++ b/source/gui/widgets/label.cpp @@ -130,7 +130,7 @@ namespace nana if (!_m_foreach_visual_line(graph, rs)) break; - rs.pos.y += static_cast(rs.vslines.back().extent_height_px); + //Now the y-position of rs has been modified to next line. } if (transient_.current_font != pre_font) @@ -531,10 +531,6 @@ namespace nana bool _m_foreach_visual_line(graph_reference graph, render_status& rs) { - std::wstring text; - - content_element_iterator block_start; - auto const bottom = static_cast(graph.height()) - 1; for (auto & vsline : rs.vslines) From 36095c91908f7ea6d8b37504e13b431f7480a70f Mon Sep 17 00:00:00 2001 From: besh81 Date: Fri, 14 Dec 2018 12:38:06 +0100 Subject: [PATCH 05/12] fix disabled checkbox square disabled checkbox square now looks like disabled textbox In addition found an unused instruction in text_editor.cpp: could be replaced or removed (or left as it is :) ) --- source/gui/element.cpp | 3 ++- source/gui/widgets/checkbox.cpp | 6 +++++- source/gui/widgets/skeletons/text_editor.cpp | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/source/gui/element.cpp b/source/gui/element.cpp index a67a7341..ea3b94a2 100644 --- a/source/gui/element.cpp +++ b/source/gui/element.cpp @@ -163,7 +163,8 @@ namespace nana bld_fgcolor = fgcolor.blend(highlighted, 0.6); break; case element_state::disabled: - bld_bgcolor = bld_fgcolor = static_cast(0xb2b7bc); + bld_bgcolor = static_cast(0xE0E0E0); + bld_fgcolor = static_cast(0x999A9E); break; default: //Leave things as they are diff --git a/source/gui/widgets/checkbox.cpp b/source/gui/widgets/checkbox.cpp index c458a4ac..a43cd908 100644 --- a/source/gui/widgets/checkbox.cpp +++ b/source/gui/widgets/checkbox.cpp @@ -85,9 +85,13 @@ namespace nana{ namespace drawerbase graph.text_metrics(txt_px, descent, ileading); txt_px += (descent + 2); + auto e_state = API::element_state(*wdg); + if(!wdg->enabled()) + e_state = element_state::disabled; + impl_->crook.draw(graph, impl_->scheme_ptr->square_bgcolor.get(wdg->bgcolor()), impl_->scheme_ptr->square_border_color.get(wdg->fgcolor()), - rectangle(0, txt_px > 16 ? (txt_px - 16) / 2 : 0, 16, 16), API::element_state(*wdg)); + rectangle(0, txt_px > 16 ? (txt_px - 16) / 2 : 0, 16, 16), e_state); } void drawer::mouse_down(graph_reference graph, const arg_mouse&) diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index 304ed929..72d26a2e 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -2002,7 +2002,7 @@ namespace nana { auto fgcolor = scheme_->foreground.get_color(); if (!API::window_enabled(window_)) - fgcolor.blend(bgcolor, 0.5); + fgcolor.blend(bgcolor, 0.5); // do nothing !!! should be replace with fgcolor = fgcolor.blend(bgcolor, 0.5); <\code> or removed if (API::widget_borderless(window_)) graph_.rectangle(false, bgcolor); From fb7a16bc61c51cf3e3bba7c92953ac2744e4e507 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sat, 15 Dec 2018 10:48:16 +0800 Subject: [PATCH 06/12] use std::filesystem instead of std::experimental::filesystem --- include/nana/filesystem/filesystem.hpp | 11 +++++- .../paint/detail/image_impl_interface.hpp | 2 +- include/nana/paint/graphics.hpp | 2 +- source/detail/platform_abstraction.cpp | 2 +- source/detail/platform_abstraction.hpp | 2 +- source/detail/posix/theme.cpp | 5 ++- source/filesystem/filesystem.cpp | 28 +++++++++++--- source/gui/dragdrop.cpp | 37 ++++++++++--------- source/paint/detail/image_bmp.hpp | 4 +- source/paint/detail/image_ico.hpp | 4 +- source/paint/detail/image_ico_resource.hpp | 2 +- source/paint/detail/image_jpeg.hpp | 2 +- source/paint/detail/image_png.hpp | 2 +- source/paint/image.cpp | 2 +- source/paint/truetype.hpp | 2 +- 15 files changed, 68 insertions(+), 39 deletions(-) diff --git a/include/nana/filesystem/filesystem.hpp b/include/nana/filesystem/filesystem.hpp index c17efd6d..c4815c94 100644 --- a/include/nana/filesystem/filesystem.hpp +++ b/include/nana/filesystem/filesystem.hpp @@ -175,7 +175,7 @@ namespace nana { namespace experimental { namespace filesystem unknown = 0xFFFF ///< not known, such as when a file_status object is created without specifying the permissions }; //enum class copy_options; - + enum class directory_options { none, @@ -538,13 +538,20 @@ namespace std { namespace filesystem { using namespace std::experimental::filesystem; -#if (defined(_MSC_VER) && ((!defined(_MSVC_LANG)) || (_MSVC_LANG < 201703))) +#if defined(NANA_FILESYSTEM_FORCE) || \ + (defined(_MSC_VER) && ((!defined(_MSVC_LANG)) || (_MSVC_LANG < 201703))) path absolute(const path& p); path absolute(const path& p, std::error_code& err); path canonical(const path& p); path canonical(const path& p, std::error_code& err); #endif + +#if defined(NANA_FILESYSTEM_FORCE) || defined(NANA_MINGW) + bool exists( std::filesystem::file_status s ) noexcept; + bool exists( const std::filesystem::path& p ); + bool exists( const std::filesystem::path& p, std::error_code& ec ) noexcept; +#endif } } // std diff --git a/include/nana/paint/detail/image_impl_interface.hpp b/include/nana/paint/detail/image_impl_interface.hpp index 4a99abaf..6a0e1141 100644 --- a/include/nana/paint/detail/image_impl_interface.hpp +++ b/include/nana/paint/detail/image_impl_interface.hpp @@ -16,7 +16,7 @@ namespace nana{ namespace paint{ public: using graph_reference = nana::paint::graphics&; virtual ~image_impl_interface() = 0; //The destructor is defined in ../image.cpp - virtual bool open(const std::experimental::filesystem::path& file) = 0; + virtual bool open(const std::filesystem::path& file) = 0; virtual bool open(const void* data, std::size_t bytes) = 0; // reads image from memory virtual bool alpha_channel() const = 0; virtual bool empty() const = 0; diff --git a/include/nana/paint/graphics.hpp b/include/nana/paint/graphics.hpp index 4eed26a6..3cec589c 100644 --- a/include/nana/paint/graphics.hpp +++ b/include/nana/paint/graphics.hpp @@ -33,7 +33,7 @@ namespace nana { friend class graphics; public: - using path_type = ::std::experimental::filesystem::path; + using path_type = ::std::filesystem::path; using font_style = ::nana::detail::font_style; diff --git a/source/detail/platform_abstraction.cpp b/source/detail/platform_abstraction.cpp index c9178c2f..515f6ace 100644 --- a/source/detail/platform_abstraction.cpp +++ b/source/detail/platform_abstraction.cpp @@ -158,7 +158,7 @@ namespace nana : public font_interface { public: - using path_type = std::experimental::filesystem::path; + using path_type = std::filesystem::path; internal_font(const path_type& ttf, const std::string& font_family, double font_size, const font_style& fs, native_font_type native_font): ttf_(ttf), diff --git a/source/detail/platform_abstraction.hpp b/source/detail/platform_abstraction.hpp index 290e0a5c..3e22112a 100644 --- a/source/detail/platform_abstraction.hpp +++ b/source/detail/platform_abstraction.hpp @@ -28,7 +28,7 @@ namespace nana public: using font = font_interface; - using path_type = ::std::experimental::filesystem::path; + using path_type = ::std::filesystem::path; static void initialize(); /// Shutdown before destruction of platform_spec diff --git a/source/detail/posix/theme.cpp b/source/detail/posix/theme.cpp index 417bc744..cebcf8f5 100644 --- a/source/detail/posix/theme.cpp +++ b/source/detail/posix/theme.cpp @@ -1,3 +1,5 @@ +#include +#if defined(NANA_POSIX) && defined(NANA_X11) #include "theme.hpp" #include #include @@ -295,4 +297,5 @@ namespace nana } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/source/filesystem/filesystem.cpp b/source/filesystem/filesystem.cpp index aa2c6ab4..a61e2f66 100644 --- a/source/filesystem/filesystem.cpp +++ b/source/filesystem/filesystem.cpp @@ -116,7 +116,7 @@ namespace nana //Windows stores file times using the FILETIME structure, which is a 64 bit value of 100ns intervals from January 1, 1601. //What's worse is that this 1601 date is fairly common to see given that it's the all zeroes value, and it is far before the //earliest date representable with time_t.std::filesystem can't change the reality of the underlying platform. - + try { #if NANA_USING_BOOST_FILESYSTEM @@ -275,7 +275,7 @@ namespace nana { namespace experimental { namespace filesystem return has_root_directory(); #endif } - + bool path::is_relative() const { return !is_absolute(); @@ -310,7 +310,7 @@ namespace nana { namespace experimental { namespace filesystem ; } - + path path::root_name() const { @@ -1123,11 +1123,12 @@ namespace nana { namespace experimental { namespace filesystem } //end namespace experimental }//end namespace nana -#if (defined(_MSC_VER) && ((!defined(_MSVC_LANG)) || (_MSVC_LANG < 201703))) namespace std { namespace filesystem { +#if defined(NANA_FILESYSTEM_FORCE) || \ + (defined(_MSC_VER) && ((!defined(_MSVC_LANG)) || (_MSVC_LANG < 201703))) path absolute(const path& p) { if (p.empty()) @@ -1236,9 +1237,26 @@ namespace std { return canonical(p, &err); } +#endif + +#if defined(NANA_FILESYSTEM_FORCE) || defined(NANA_MINGW) + bool exists( std::filesystem::file_status s ) noexcept + { + return s.type() != file_type::not_found; + } + + bool exists( const std::filesystem::path& p ) + { + return exists(status(p)); + } + + bool exists( const std::filesystem::path& p, std::error_code& ec ) noexcept + { + return exists(status(p, ec)); + } +#endif }//end namespace filesystem }//end namespace std -#endif #endif diff --git a/source/gui/dragdrop.cpp b/source/gui/dragdrop.cpp index d04e5a92..d6266e69 100644 --- a/source/gui/dragdrop.cpp +++ b/source/gui/dragdrop.cpp @@ -19,6 +19,7 @@ #include #include +#include #ifdef NANA_WINDOWS # include @@ -179,7 +180,7 @@ namespace nana win32com_drop_target(bool simple_mode): simple_mode_(simple_mode) { - + } //Implements IUnknown @@ -279,7 +280,7 @@ namespace nana //Drop the object if left button is released. if (0 == (key_state & (MK_LBUTTON))) return DRAGDROP_S_DROP; - + return S_OK; } @@ -468,7 +469,7 @@ namespace nana auto entry = find(*request_format, true); if (entry) return _m_copy_medium(pmedium, &entry->medium, &entry->format); - + return DV_E_FORMATETC; } @@ -481,10 +482,10 @@ namespace nana { if (NULL == pformatetc) return E_INVALIDARG; - + if (!(DVASPECT_CONTENT & pformatetc->dwAspect)) return DV_E_DVASPECT; - + HRESULT result = DV_E_TYMED; for (auto & entry : entries_) @@ -563,7 +564,7 @@ namespace nana { if (!(stgmed_dst && stgmed_src && fmt_src)) return E_INVALIDARG; - + switch (stgmed_src->tymed) { case TYMED_HGLOBAL: @@ -646,7 +647,7 @@ namespace nana { ++ref_count_; } - + std::size_t release() override { std::size_t val = --ref_count_; @@ -768,7 +769,7 @@ namespace nana auto& atombase = _m_spec().atombase(); auto ddrop = dynamic_cast(i->second); - + auto const native_source = reinterpret_cast(API::root(drag_wd)); { @@ -780,7 +781,7 @@ namespace nana hovered_.window_handle = nullptr; hovered_.native_wd = 0; window target_wd = 0; - + if(ddrop->simple_mode()) { @@ -816,7 +817,7 @@ namespace nana { hovered_.window_handle = cur_wd; - icon = (((drag_wd == cur_wd) || ddrop->has(drag_wd, cur_wd)) ? "dnd-move" : "dnd-none"); + icon = (((drag_wd == cur_wd) || ddrop->has(drag_wd, cur_wd)) ? "dnd-move" : "dnd-none"); } } @@ -855,9 +856,9 @@ namespace nana if(icon) { _m_free_cursor(); - hovered_.cursor = ::XcursorFilenameLoadCursor(disp, icons_.cursor(icon).c_str()); - ::XDefineCursor(disp, native_cur_wd, hovered_.cursor); - } + hovered_.cursor = ::XcursorFilenameLoadCursor(disp, icons_.cursor(icon).c_str()); + ::XDefineCursor(disp, native_cur_wd, hovered_.cursor); + } #endif } else if(msg_pkt.u.xevent.type == ButtonRelease) @@ -868,7 +869,7 @@ namespace nana API::release_capture(drag_wd); return detail::propagation_chain::exit; } - + } return detail::propagation_chain::stop; }); @@ -909,7 +910,7 @@ namespace nana { std::cout<<"ButtonRelease"< predicate_fn) { impl_->predicate = predicate_fn; @@ -1277,4 +1278,4 @@ namespace nana { real_data_->files.emplace_back(std::move(path)); } -}//end namespace nana \ No newline at end of file +}//end namespace nana diff --git a/source/paint/detail/image_bmp.hpp b/source/paint/detail/image_bmp.hpp index e3893c61..ac25812e 100644 --- a/source/paint/detail/image_bmp.hpp +++ b/source/paint/detail/image_bmp.hpp @@ -111,11 +111,11 @@ namespace nana{ namespace paint return true; } - bool open(const std::experimental::filesystem::path& filename) override + bool open(const std::filesystem::path& filename) override { std::ifstream ifs(filename.string(), std::ios::binary); - auto const bytes = static_cast(std::experimental::filesystem::file_size(filename)); + auto const bytes = static_cast(std::filesystem::file_size(filename)); if (ifs && (bytes > static_cast(sizeof(bitmap_file_header)))) { std::unique_ptr buffer{ new char[bytes] }; diff --git a/source/paint/detail/image_ico.hpp b/source/paint/detail/image_ico.hpp index 4f78cad6..ffa4d693 100644 --- a/source/paint/detail/image_ico.hpp +++ b/source/paint/detail/image_ico.hpp @@ -241,7 +241,7 @@ public: #endif } - bool open(const std::experimental::filesystem::path& ico_file) override + bool open(const std::filesystem::path& ico_file) override { std::ifstream file(ico_file.string(), std::ios::binary); if (!file.is_open()) return false; @@ -290,7 +290,7 @@ public: #endif } private: - std::experimental::filesystem::path path_; + std::filesystem::path path_; #if defined(NANA_WINDOWS) void* native_handle_{nullptr}; #endif diff --git a/source/paint/detail/image_ico_resource.hpp b/source/paint/detail/image_ico_resource.hpp index dd451bf0..f7e85818 100644 --- a/source/paint/detail/image_ico_resource.hpp +++ b/source/paint/detail/image_ico_resource.hpp @@ -29,7 +29,7 @@ namespace nana{ namespace paint :public image::image_impl_interface { public: - bool open(const std::experimental::filesystem::path& filename) override + bool open(const std::filesystem::path& filename) override { #if defined(NANA_WINDOWS) SHFILEINFO sfi; diff --git a/source/paint/detail/image_jpeg.hpp b/source/paint/detail/image_jpeg.hpp index d63a2c1d..0b1ecd2c 100644 --- a/source/paint/detail/image_jpeg.hpp +++ b/source/paint/detail/image_jpeg.hpp @@ -47,7 +47,7 @@ namespace nana } } public: - bool open(const std::experimental::filesystem::path& jpeg_file) override + bool open(const std::filesystem::path& jpeg_file) override { auto fp = ::fopen(to_osmbstr(to_utf8(jpeg_file.native())).c_str(), "rb"); if(nullptr == fp) return false; diff --git a/source/paint/detail/image_png.hpp b/source/paint/detail/image_png.hpp index f3cff150..91dd8e2b 100644 --- a/source/paint/detail/image_png.hpp +++ b/source/paint/detail/image_png.hpp @@ -123,7 +123,7 @@ namespace nana delete[] row_ptrs; } public: - bool open(const std::experimental::filesystem::path& png_file) override + bool open(const std::filesystem::path& png_file) override { auto fp = ::fopen(to_osmbstr(to_utf8(png_file.native())).c_str(), "rb"); if(nullptr == fp) return false; diff --git a/source/paint/image.cpp b/source/paint/image.cpp index 1781a657..9d19a46c 100644 --- a/source/paint/image.cpp +++ b/source/paint/image.cpp @@ -38,7 +38,7 @@ #include "detail/image_ico_resource.hpp" #include "detail/image_ico.hpp" -namespace fs = std::experimental::filesystem; +namespace fs = std::filesystem; namespace nana { diff --git a/source/paint/truetype.hpp b/source/paint/truetype.hpp index 5b94cd34..d8ce4b9b 100644 --- a/source/paint/truetype.hpp +++ b/source/paint/truetype.hpp @@ -47,7 +47,7 @@ namespace nana std::uint16_t string_offset; //from start of storage area }; public: - using path_type = ::std::experimental::filesystem::path; + using path_type = ::std::filesystem::path; truetype(const path_type& filename) { From 4e4fbbde46d6c80c94810a3e8de346e8a52bd850 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sat, 15 Dec 2018 10:53:33 +0800 Subject: [PATCH 07/12] fix compiling error --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 896e4134..e9252dce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,7 @@ set(NANA_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/source) set(NANA_SOURCE_SUBDIRS /. /detail + /detail/posix /filesystem /gui /gui/detail From 01ed1d13e942c8865ca85d0ffe6920b6ce911480 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Thu, 20 Dec 2018 07:03:24 +0800 Subject: [PATCH 08/12] add icon theme for KDE --- source/detail/posix/theme.cpp | 43 +++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/source/detail/posix/theme.cpp b/source/detail/posix/theme.cpp index cebcf8f5..2eec4797 100644 --- a/source/detail/posix/theme.cpp +++ b/source/detail/posix/theme.cpp @@ -85,9 +85,9 @@ namespace nana return values; } + namespace fs = std::filesystem; std::string find_gnome_theme_name() { - namespace fs = std::filesystem; try { //Searches all the gschema override files @@ -156,6 +156,41 @@ namespace nana } + std::string find_kde_theme_name() + { + auto home = getenv("HOME"); + if(home) + { + fs::path kdeglobals{home}; + kdeglobals /= ".kde/share/config/kdeglobals"; + + std::error_code err; + if(fs::exists(kdeglobals, err)) + { + std::ifstream ifs{kdeglobals}; + return find_value(ifs, "Icons", "Theme"); + } + } + return {}; + } + + std::string find_theme_name() + { + auto name = find_kde_theme_name(); + + if(name.empty()) + { + name = find_gnome_theme_name(); + std::cout<<"GNOME:"< Date: Thu, 27 Dec 2018 07:29:11 +0800 Subject: [PATCH 09/12] improve dnd interfaces --- include/nana/gui/dragdrop.hpp | 37 ++++- source/detail/platform_spec_posix.cpp | 2 + source/detail/posix/platform_spec.hpp | 2 + source/detail/posix/xdnd_protocol.hpp | 188 ++++++++++++-------------- source/gui/dragdrop.cpp | 173 +++++++++++++----------- 5 files changed, 213 insertions(+), 189 deletions(-) diff --git a/include/nana/gui/dragdrop.hpp b/include/nana/gui/dragdrop.hpp index d426d34c..a20c7bb8 100644 --- a/include/nana/gui/dragdrop.hpp +++ b/include/nana/gui/dragdrop.hpp @@ -22,6 +22,14 @@ namespace nana { + /// Drag and drop actions + enum class dnd_action + { + copy, ///< Copy the data to target. + move, ///< Move the data to target. + link ///< Create a link from source data to target. + }; + class simple_dragdrop { struct implementation; @@ -67,7 +75,12 @@ namespace nana data(const data&) = delete; data& operator=(const data&) = delete; public: - data(); + /// Constructor + /** + * Constructs a data object used for drag and drop + * @param requested_action Indicates how the data to be transferred. + */ + data(dnd_action requested_action = dnd_action::copy); data(data&&); ~data(); @@ -81,9 +94,29 @@ namespace nana dragdrop(window source); ~dragdrop(); + /// Condition of dragging + /*** + * The preciate function is called when press mouse button on the source window, it returns true to indicate the start of dragging. If the predicate is not set, it always start to drag. + * @param predicate_fn A predicate function to be set. + */ void condition(std::function predicate_fn); + + /// Transferred data + /** + * Set a data generator. When drag begins, it is called to generate a data object for transferring. + * @param generator It returns the data for transferring. + */ void prepare_data(std::function generator); - void drop_finished(std::function finish_fn); + + /// Drop handler + /** + * The drop handler is called when the drop operation is completed. There are 3 parameters for the handler + * dropped Indicates whether the data is accepted by a target window. + * executed_action Indicates the action returned by target window. Ignore if dropped is false. + * data_transferred The data object which is generated by the generator. + * @param finish_fn The drop handling function. + */ + void drop_finished(std::function finish_fn); private: implementation* const impl_; }; diff --git a/source/detail/platform_spec_posix.cpp b/source/detail/platform_spec_posix.cpp index f03f0b09..f607e9a3 100644 --- a/source/detail/platform_spec_posix.cpp +++ b/source/detail/platform_spec_posix.cpp @@ -513,6 +513,8 @@ namespace detail atombase_.xdnd_position = ::XInternAtom(display_, "XdndPosition", False); atombase_.xdnd_status = ::XInternAtom(display_, "XdndStatus", False); atombase_.xdnd_action_copy = ::XInternAtom(display_, "XdndActionCopy", False); + atombase_.xdnd_action_move = ::XInternAtom(display_, "XdndActionMove", False); + atombase_.xdnd_action_link = ::XInternAtom(display_, "XdndActionLink", False); atombase_.xdnd_drop = ::XInternAtom(display_, "XdndDrop", False); atombase_.xdnd_selection = ::XInternAtom(display_, "XdndSelection", False); atombase_.xdnd_typelist = ::XInternAtom(display_, "XdndTypeList", False); diff --git a/source/detail/posix/platform_spec.hpp b/source/detail/posix/platform_spec.hpp index 0cf4b086..84c1c24e 100644 --- a/source/detail/posix/platform_spec.hpp +++ b/source/detail/posix/platform_spec.hpp @@ -159,6 +159,8 @@ namespace detail Atom xdnd_position; Atom xdnd_status; Atom xdnd_action_copy; + Atom xdnd_action_move; + Atom xdnd_action_link; Atom xdnd_drop; Atom xdnd_selection; Atom xdnd_typelist; diff --git a/source/detail/posix/xdnd_protocol.hpp b/source/detail/posix/xdnd_protocol.hpp index ad101c56..1883633e 100644 --- a/source/detail/posix/xdnd_protocol.hpp +++ b/source/detail/posix/xdnd_protocol.hpp @@ -16,69 +16,26 @@ #include "platform_spec.hpp" #include -#include +#include "theme.hpp" #include +#include + +#define DEBUG_XDND_PROTOCOL + +#ifdef DEBUG_XDND_PROTOCOL #include //debug +#endif namespace nana{ namespace detail { - - class shared_icons - { - public: - shared_icons() - { - path_ = "/usr/share/icons/"; - ifs_.open(path_ + "default/index.theme"); - } - - std::string cursor(const std::string& name) - { - auto theme = _m_read("Icon Theme", "Inherits"); - - return path_ + theme + "/cursors/" + name; - } - private: - std::string _m_read(const std::string& category, const std::string& key) - { - ifs_.seekg(0, std::ios::beg); - - bool found_cat = false; - while(ifs_.good()) - { - std::string text; - std::getline(ifs_, text); - - if(0 == text.find('[')) - { - if(found_cat) - break; - - if(text.find(category + "]") != text.npos) - { - found_cat = true; - } - } - else if(found_cat && (text.find(key + "=") == 0)) - { - return text.substr(key.size() + 1); - } - } - - return {}; - } - private: - std::string path_; - std::ifstream ifs_; - }; - struct xdnd_data { + Atom requested_action; std::vector files; }; @@ -100,31 +57,40 @@ namespace nana{ auto disp = spec_.open_display(); detail::platform_scope_guard lock; ::XSetSelectionOwner(disp, spec_.atombase().xdnd_selection, source, CurrentTime); - std::cout<<"XSetSelectionOwner "<(xclient.data.l[0]); bool is_accepted_by_target = (xclient.data.l[1] & 1); - std::cout<<"XdndStatus: Accepted="< mvout_table_; struct cursor_rep { + Cursor dnd_copy{ 0 }; Cursor dnd_move{ 0 }; Cursor dnd_none{ 0 }; }cursor_; diff --git a/source/gui/dragdrop.cpp b/source/gui/dragdrop.cpp index d6266e69..2c2d394a 100644 --- a/source/gui/dragdrop.cpp +++ b/source/gui/dragdrop.cpp @@ -39,17 +39,31 @@ namespace nana { struct dragdrop_data { + dnd_action requested_action; std::vector files; - }; #ifdef NANA_X11 - xdnd_data to_xdnd_data(const dragdrop_data& data) - { - xdnd_data xdata; - xdata.files = data.files; - return xdata; - } + xdnd_data to_xdnd_data() const noexcept + { + auto & atombase = nana::detail::platform_spec::instance().atombase(); + xdnd_data xdata; + xdata.requested_action = atombase.xdnd_action_copy; + + switch(requested_action) + { + case dnd_action::copy: + xdata.requested_action = atombase.xdnd_action_copy; break; + case dnd_action::move: + xdata.requested_action = atombase.xdnd_action_move; break; + case dnd_action::link: + xdata.requested_action = atombase.xdnd_action_link; break; + } + + xdata.files = files; + return xdata; + } #endif + }; } @@ -744,7 +758,7 @@ namespace nana } } - bool dragdrop(window drag_wd, dropdata_type* dropdata) + bool dragdrop(window drag_wd, dropdata_type* dropdata, dnd_action* executed_action) { auto i = table_.find(API::root(drag_wd)); if ((!dropdata) && table_.end() == i) @@ -764,6 +778,19 @@ namespace nana delete drop_src; + if (executed_action) + { + switch (result_effect) + { + case DROPEFFECT_COPY: + *executed_action = dnd_action::copy; break; + case DROPEFFECT_MOVE: + *executed_action = dnd_action::move; break; + case DROPEFFECT_LINK: + *executed_action = dnd_action::link; break; + } + } + return (DROPEFFECT_NONE != result_effect); #elif defined(NANA_X11) auto& atombase = _m_spec().atombase(); @@ -780,12 +807,14 @@ namespace nana hovered_.window_handle = nullptr; hovered_.native_wd = 0; - window target_wd = 0; + + if(executed_action) + *executed_action = dropdata->data()->requested_action; if(ddrop->simple_mode()) { - _m_spec().msg_dispatch([this, ddrop, drag_wd, native_source, &target_wd, &atombase](const detail::msg_packet_tag& msg_pkt) mutable{ + _m_spec().msg_dispatch([this, ddrop, drag_wd, native_source, &atombase](const detail::msg_packet_tag& msg_pkt) mutable{ if(detail::msg_packet_tag::pkt_family::xevent == msg_pkt.kind) { auto const disp = _m_spec().open_display(); @@ -793,35 +822,7 @@ namespace nana { auto pos = API::cursor_position(); auto native_cur_wd = reinterpret_cast(detail::native_interface::find_window(pos.x, pos.y)); -#if 0 - const char* icon = nullptr; - if(hovered_.native_wd != native_cur_wd) - { - if(hovered_.native_wd) - { - _m_free_cursor(); - ::XUndefineCursor(disp, hovered_.native_wd); - } - _m_client_msg(native_cur_wd, native_source, 1, atombase.xdnd_enter, atombase.text_uri_list, XA_STRING); - hovered_.native_wd = native_cur_wd; - - if(!ddrop->simple_mode()) - icon = "dnd-move"; - } - - if(ddrop->simple_mode()) - { - auto cur_wd = API::find_window(API::cursor_position()); - if(hovered_.window_handle != cur_wd) - { - hovered_.window_handle = cur_wd; - - icon = (((drag_wd == cur_wd) || ddrop->has(drag_wd, cur_wd)) ? "dnd-move" : "dnd-none"); - } - } - -#else const char* icon = nullptr; if(hovered_.native_wd != native_cur_wd) { @@ -835,23 +836,19 @@ namespace nana hovered_.native_wd = native_cur_wd; } - if(ddrop->simple_mode()) + + auto cur_wd = API::find_window(API::cursor_position()); + + std::cout<<" Hovered="<data()); + auto data = dropdata->data()->to_xdnd_data(); API::set_capture(drag_wd, true); nana::detail::xdnd_protocol xdnd_proto{native_source}; //Not simple mode - _m_spec().msg_dispatch([this, ddrop, &data, drag_wd, xdnd_proto, native_source, &target_wd, &atombase](const detail::msg_packet_tag& msg_pkt) mutable{ + _m_spec().msg_dispatch([this, ddrop, &data, drag_wd, &xdnd_proto, native_source, &atombase](const detail::msg_packet_tag& msg_pkt) mutable{ if(detail::msg_packet_tag::pkt_family::xevent == msg_pkt.kind) { auto const disp = _m_spec().open_display(); @@ -891,7 +889,7 @@ namespace nana auto pos = API::cursor_position(); auto native_cur_wd = reinterpret_cast(detail::native_interface::find_window(pos.x, pos.y)); - xdnd_proto.mouse_move(native_cur_wd, pos); + xdnd_proto.mouse_move(native_cur_wd, pos, data.requested_action); } else if(ClientMessage == msg_pkt.u.xevent.type) { @@ -911,10 +909,12 @@ namespace nana std::cout<<"ButtonRelease"< dropdata{new dragdrop_service::dropdata_type}; - auto has_dropped = dragdrop_service::instance().dragdrop(arg.window_handle, dropdata.get()); + auto has_dropped = dragdrop_service::instance().dragdrop(arg.window_handle, dropdata.get(), nullptr); real_wd->other.dnd_state = dragdrop_status::not_ready; impl_->dragging = false; @@ -1125,7 +1143,7 @@ namespace nana dragdrop_session * ddrop{nullptr}; std::function predicate; std::function generator; - std::function drop_finished; + std::function drop_finished; struct event_handlers { @@ -1143,28 +1161,18 @@ namespace nana void make_drop() { + if (!generator) + return; + auto transf_data = generator(); dragdrop_service::dropdata_type dropdata; dropdata.assign(*transf_data.real_data_); -/* //deprecated -#ifdef NANA_WINDOWS - drop_source drop_src{ source_handle }; - DWORD result_effect = DROPEFFECT_NONE; - auto status = ::DoDragDrop(&dropdata, &drop_src, DROPEFFECT_COPY | DROPEFFECT_MOVE, &result_effect); - if (DROPEFFECT_NONE == result_effect) - { - } - - if (drop_finished) - drop_finished(DROPEFFECT_NONE != result_effect); -#else -#endif -*/ - auto has_dropped = dragdrop_service::instance().dragdrop(source_handle, &dropdata); + dnd_action executed_action; + auto has_dropped = dragdrop_service::instance().dragdrop(source_handle, &dropdata, &executed_action); if(drop_finished) - drop_finished(has_dropped); + drop_finished(has_dropped, executed_action, transf_data); } }; @@ -1240,15 +1248,16 @@ namespace nana impl_->generator = generator; } - void dragdrop::drop_finished(std::function finish_fn) + void dragdrop::drop_finished(std::function finish_fn) { impl_->drop_finished = finish_fn; } - dragdrop::data::data(): + dragdrop::data::data(dnd_action requested_action): real_data_(new detail::dragdrop_data) { + real_data_->requested_action = requested_action; } dragdrop::data::~data() From bed829fa26a666044eb6d66d333dea91e3e57ca3 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sat, 29 Dec 2018 06:38:46 +0800 Subject: [PATCH 10/12] fix bug that line alorithm wrongly draws a line when fade_rate is zero --- source/gui/widgets/skeletons/text_editor.cpp | 2 +- source/paint/detail/image_process_provider.cpp | 2 +- .../nana => source}/paint/detail/image_processor.hpp | 12 ++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) rename {include/nana => source}/paint/detail/image_processor.hpp (98%) diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index 72d26a2e..6a5251b4 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -2002,7 +2002,7 @@ namespace nana { auto fgcolor = scheme_->foreground.get_color(); if (!API::window_enabled(window_)) - fgcolor.blend(bgcolor, 0.5); // do nothing !!! should be replace with fgcolor = fgcolor.blend(bgcolor, 0.5); <\code> or removed + fgcolor = fgcolor.blend(bgcolor, 0.5); //Thank to besh81 for getting the fgcolor to be changed if (API::widget_borderless(window_)) graph_.rectangle(false, bgcolor); diff --git a/source/paint/detail/image_process_provider.cpp b/source/paint/detail/image_process_provider.cpp index 414d68dc..89324e04 100644 --- a/source/paint/detail/image_process_provider.cpp +++ b/source/paint/detail/image_process_provider.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include "image_processor.hpp" namespace nana { diff --git a/include/nana/paint/detail/image_processor.hpp b/source/paint/detail/image_processor.hpp similarity index 98% rename from include/nana/paint/detail/image_processor.hpp rename to source/paint/detail/image_processor.hpp index 1a412a2e..5e7e3548 100644 --- a/include/nana/paint/detail/image_processor.hpp +++ b/source/paint/detail/image_processor.hpp @@ -1,7 +1,7 @@ /* * Image Processor Algorithm Implementation * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -15,8 +15,8 @@ #ifndef NANA_PAINT_DETAIL_IMAGE_PROCESSOR_HPP #define NANA_PAINT_DETAIL_IMAGE_PROCESSOR_HPP -#include "../image_process_interface.hpp" #include +#include #include #include @@ -421,15 +421,19 @@ namespace detail { virtual void process(paint::pixel_buffer & pixbuf, const nana::point& pos_beg, const nana::point& pos_end, const ::nana::color& clr, double fade_rate) const { + //Return if it is completely transparent + if (fade_rate <= 0) + return; + auto rgb_color = clr.px_color().value; const std::size_t bytes_pl = pixbuf.bytes_per_line(); unsigned char * fade_table = nullptr; std::unique_ptr autoptr; nana::pixel_argb_t rgb_imd = {}; - if(fade_rate != 0.0) + if(fade_rate < 1) { - autoptr = detail::alloc_fade_table(1 - fade_rate); + autoptr = detail::alloc_fade_table(1.0 - fade_rate); fade_table = autoptr.get(); rgb_imd.value = rgb_color; rgb_imd = detail::fade_color_intermedia(rgb_imd, fade_table); From 345d65f6c9abe38c43daf90aad4ac63f81cd05a9 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sat, 29 Dec 2018 07:08:49 +0800 Subject: [PATCH 11/12] add caption background mode for group --- include/nana/gui/widgets/group.hpp | 10 ++++++- source/gui/widgets/group.cpp | 48 ++++++++++++++++++++++++------ 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/include/nana/gui/widgets/group.hpp b/include/nana/gui/widgets/group.hpp index ba48928b..e0fdfc3b 100644 --- a/include/nana/gui/widgets/group.hpp +++ b/include/nana/gui/widgets/group.hpp @@ -42,6 +42,13 @@ namespace nana{ using field_reference = place::field_reference; constexpr static const std::size_t npos = static_cast(-1); + enum class background_mode + { + none, + transparent, + blending + }; + /// The default construction group(); @@ -66,7 +73,8 @@ namespace nana{ checkbox& add_option(::std::string); /// Modifies the alignment of the title - void caption_align(align position); + group& caption_align(align position); + group& caption_background_mode(background_mode mode); /// Enables/disables the radio mode which is single selection group& radio_mode(bool); diff --git a/source/gui/widgets/group.cpp b/source/gui/widgets/group.cpp index 6d697a62..d85d81a9 100644 --- a/source/gui/widgets/group.cpp +++ b/source/gui/widgets/group.cpp @@ -36,6 +36,7 @@ namespace nana{ { label caption; align caption_align{ align::left }; + background_mode caption_mode{ background_mode::blending }; place place_content; unsigned gap{2}; std::string usr_div_str; @@ -154,7 +155,7 @@ namespace nana{ return *impl_->options.back(); } - void group::caption_align(align position) + group& group::caption_align(align position) { if (position != impl_->caption_align) { @@ -163,6 +164,32 @@ namespace nana{ impl_->place_content.collocate(); API::refresh_window(*this); } + return *this; + } + + group& group::caption_background_mode(background_mode mode) + { + if (mode != impl_->caption_mode) + { + impl_->caption_mode = mode; + switch (mode) + { + case background_mode::none: + impl_->caption.bgcolor(this->bgcolor()); + impl_->caption.transparent(false); + break; + case background_mode::blending: + impl_->caption.transparent(true); + impl_->caption.bgcolor(API::bgcolor(this->parent()).blend(colors::black, 0.025)); + break; + case background_mode::transparent: + impl_->caption.transparent(true); + impl_->caption.bgcolor(API::bgcolor(this->parent()).blend(colors::black, 0.025)); + break; + } + API::refresh_window(*this); + } + return *this; } group& group::radio_mode(bool enable) @@ -289,17 +316,20 @@ namespace nana{ ), 3, 3, this->scheme().border, true, this->bgcolor()); - auto opt_r = API::window_rectangle(impl_->caption); - if (opt_r) + if (background_mode::blending == impl_->caption_mode) { - rectangle grad_r{ opt_r->position(), nana::size{ opt_r->width + 4, static_cast(top_round_line - opt_r->y) } }; + auto opt_r = API::window_rectangle(impl_->caption); + if (opt_r) + { + rectangle grad_r{ opt_r->position(), nana::size{ opt_r->width + 4, static_cast(top_round_line - opt_r->y) } }; - grad_r.y += top_round_line*2 / 3; - grad_r.x -= 2; + grad_r.y += top_round_line * 2 / 3; + grad_r.x -= 2; - graph.gradual_rectangle(grad_r, - API::bgcolor(this->parent()), this->bgcolor(), true - ); + graph.gradual_rectangle(grad_r, + API::bgcolor(this->parent()), this->bgcolor(), true + ); + } } }); } From f488df3e4c3046de19f351883bf557f64bfa7c35 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Thu, 17 Jan 2019 07:10:16 +0800 Subject: [PATCH 12/12] add support of refreshing a draw_through form --- source/gui/detail/native_window_interface.cpp | 17 +++++++++-------- source/gui/detail/window_manager.cpp | 6 ++++++ source/gui/programming_interface.cpp | 1 - 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/source/gui/detail/native_window_interface.cpp b/source/gui/detail/native_window_interface.cpp index 8d3dd9c8..fcf7f695 100644 --- a/source/gui/detail/native_window_interface.cpp +++ b/source/gui/detail/native_window_interface.cpp @@ -848,12 +848,17 @@ namespace nana{ #endif } - void native_interface::refresh_window(native_window_type wd) + void native_interface::refresh_window(native_window_type native_wd) { #if defined(NANA_WINDOWS) - ::InvalidateRect(reinterpret_cast(wd), nullptr, true); + auto wd = reinterpret_cast(native_wd); + RECT r; + ::GetClientRect(wd, &r); + ::InvalidateRect(wd, &r, FALSE); #elif defined(NANA_X11) - static_cast(wd); //eliminate unused parameter compiler warning. + Display * disp = restrict::spec.open_display(); + ::XClearArea(disp, reinterpret_cast(native_wd), 0, 0, 1, 1, true); + ::XFlush(disp); #endif } @@ -1110,14 +1115,10 @@ namespace nana{ if(owner && (owner != reinterpret_cast(restrict::spec.root_window()))) { auto origin = window_position(owner); -#if 0 - x += origin.x; - y += origin.y; -#else + auto owner_extents = window_frame_extents(owner); x += origin.x + owner_extents.left; y += origin.y + owner_extents.top; -#endif } ::XMoveResizeWindow(disp, reinterpret_cast(wd), x, y, r.width, r.height); diff --git a/source/gui/detail/window_manager.cpp b/source/gui/detail/window_manager.cpp index 9d8ebd65..c9184053 100644 --- a/source/gui/detail/window_manager.cpp +++ b/source/gui/detail/window_manager.cpp @@ -1091,6 +1091,12 @@ namespace detail std::lock_guard lock(mutex_); if (impl_->wd_register.available(wd) == false) return false; + if ((wd->other.category == category::flags::root) && wd->is_draw_through()) + { + native_interface::refresh_window(wd->root); + return true; + } + if (wd->displayed()) { using paint_operation = window_layer::paint_operation; diff --git a/source/gui/programming_interface.cpp b/source/gui/programming_interface.cpp index 1f3ac8c9..9791d2fd 100644 --- a/source/gui/programming_interface.cpp +++ b/source/gui/programming_interface.cpp @@ -962,7 +962,6 @@ namespace API restrict::wd_manager().update(reinterpret_cast(wd), false, true); } - void window_caption(window wd, const std::string& title_utf8) { throw_not_utf8(title_utf8);