refine code
fix bug that listbox may throw std::runtime when the modal is enabled fix bug that textbox attachs a wrong event angent
This commit is contained in:
@@ -402,7 +402,7 @@ namespace nana
|
||||
root = agrparent->root;
|
||||
root_graph = agrparent->root_graph;
|
||||
index = static_cast<unsigned>(agrparent->children.size());
|
||||
agrparent->children.push_back(this);
|
||||
agrparent->children.emplace_back(this);
|
||||
}
|
||||
|
||||
predef_cursor = cursor::arrow;
|
||||
|
||||
@@ -600,7 +600,7 @@ namespace nana
|
||||
{
|
||||
root = wd->root;
|
||||
if (roots.cend() == std::find(roots.cbegin(), roots.cend(), root))
|
||||
roots.push_back(root);
|
||||
roots.emplace_back(root);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -338,7 +338,7 @@ namespace nana
|
||||
for (auto p : data_impl_->draws)
|
||||
{
|
||||
if(p->diehard())
|
||||
then.push_back(p);
|
||||
then.emplace_back(p);
|
||||
else
|
||||
delete p;
|
||||
}
|
||||
@@ -351,7 +351,7 @@ namespace nana
|
||||
if(f)
|
||||
{
|
||||
auto p = new dynamic_drawing::user_draw_function(std::move(f), diehard);
|
||||
data_impl_->draws.push_back(p);
|
||||
data_impl_->draws.emplace_back(p);
|
||||
return (diehard ? p : nullptr);
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* The Store for the Storage Of Elements
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -11,35 +11,53 @@
|
||||
*/
|
||||
#include <nana/gui/detail/element_store.hpp>
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
//class element_store
|
||||
element_store::data::data()
|
||||
: fast_ptr(nullptr)
|
||||
|
||||
struct element_store::data
|
||||
{
|
||||
cloneable_element entity;
|
||||
::nana::element::element_interface * fast_ptr{ nullptr };
|
||||
};
|
||||
|
||||
struct element_store::implementation
|
||||
{
|
||||
std::map<std::string, data> table;
|
||||
};
|
||||
|
||||
element_store::element_store()
|
||||
: impl_(new implementation)
|
||||
{}
|
||||
|
||||
//Empty destructor for instance of impl
|
||||
element_store::~element_store()
|
||||
{}
|
||||
|
||||
nana::element::element_interface * const * element_store::bground(const std::string& name)
|
||||
{
|
||||
element_interface * const * addr = &(bground_.table[name].fast_ptr);
|
||||
element_interface * const * addr = &(impl_->table[name].fast_ptr);
|
||||
return addr;
|
||||
}
|
||||
|
||||
void element_store::bground(const std::string& name, const pat::cloneable<element_interface>& rhs)
|
||||
{
|
||||
auto & store = bground_.table[name];
|
||||
auto & store = impl_->table[name];
|
||||
|
||||
store.object = rhs;
|
||||
store.fast_ptr = store.object.get();
|
||||
store.entity = rhs;
|
||||
store.fast_ptr = store.entity.get();
|
||||
}
|
||||
|
||||
void element_store::bground(const std::string& name, pat::cloneable<element_interface>&& rv)
|
||||
{
|
||||
auto & store = bground_.table[name];
|
||||
auto & store = impl_->table[name];
|
||||
|
||||
store.object = std::move(rv);
|
||||
store.fast_ptr = store.object.get();
|
||||
store.entity = std::move(rv);
|
||||
store.fast_ptr = store.entity.get();
|
||||
}
|
||||
}//end namespace detail
|
||||
}
|
||||
|
||||
@@ -221,8 +221,8 @@ namespace nana
|
||||
continue;
|
||||
|
||||
core_window_t * term = ((i + 1 != layers_rend) ? *(i + 1) : wd);
|
||||
r.x = wd->pos_root.x - pre->pos_root.x;
|
||||
r.y = wd->pos_root.y - pre->pos_root.y;
|
||||
r.position(wd->pos_root - pre->pos_root);
|
||||
|
||||
for (auto child : pre->children)
|
||||
{
|
||||
if (child->index >= term->index)
|
||||
@@ -253,7 +253,7 @@ namespace nana
|
||||
if (child->visible && overlap(r_of_wd, rectangle{ child->pos_owner, child->dimension }, ovlp))
|
||||
{
|
||||
if (category::flags::lite_widget != child->other.category)
|
||||
glass_buffer.bitblt(nana::rectangle{ ovlp.x - wd->pos_owner.x, ovlp.y - wd->pos_owner.y, ovlp.width, ovlp.height }, child->drawer.graphics, nana::point(ovlp.x - child->pos_owner.x, ovlp.y - child->pos_owner.y));
|
||||
glass_buffer.bitblt(nana::rectangle{ ovlp.x - wd->pos_owner.x, ovlp.y - wd->pos_owner.y, ovlp.width, ovlp.height }, child->drawer.graphics, {ovlp.position() - child->pos_owner});
|
||||
|
||||
ovlp.x += wd->pos_root.x;
|
||||
ovlp.y += wd->pos_root.y;
|
||||
|
||||
@@ -23,6 +23,12 @@
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
||||
#if defined(STD_THREAD_NOT_SUPPORTED)
|
||||
#include <nana/std_mutex.hpp>
|
||||
#else
|
||||
#include <mutex>
|
||||
#endif
|
||||
|
||||
namespace nana
|
||||
{
|
||||
|
||||
@@ -36,9 +42,7 @@ namespace detail
|
||||
Key first;
|
||||
Value second;
|
||||
|
||||
key_value_rep()
|
||||
: first{}, second{}
|
||||
{}
|
||||
key_value_rep() = default;
|
||||
|
||||
key_value_rep(const Key& k)
|
||||
: first(k), second{}
|
||||
@@ -69,19 +73,9 @@ namespace detail
|
||||
return table_.end();
|
||||
}
|
||||
|
||||
iterator erase(iterator pos)
|
||||
std::vector<key_value_rep>& table()
|
||||
{
|
||||
return table_.erase(pos);
|
||||
}
|
||||
|
||||
iterator begin()
|
||||
{
|
||||
return table_.begin();
|
||||
}
|
||||
|
||||
iterator end()
|
||||
{
|
||||
return table_.end();
|
||||
return table_;
|
||||
}
|
||||
private:
|
||||
std::vector<key_value_rep> table_;
|
||||
@@ -109,27 +103,50 @@ namespace detail
|
||||
//end struct wdm_private_impl
|
||||
|
||||
//class revertible_mutex
|
||||
window_manager::revertible_mutex::revertible_mutex()
|
||||
struct thread_refcount
|
||||
{
|
||||
thr_.tid = 0;
|
||||
thr_.refcnt = 0;
|
||||
unsigned tid;
|
||||
std::size_t ref;
|
||||
};
|
||||
|
||||
struct window_manager::revertible_mutex::implementation
|
||||
{
|
||||
std::recursive_mutex mutex;
|
||||
|
||||
thread_refcount thread;
|
||||
std::vector<thread_refcount> invoke_stack;
|
||||
};
|
||||
|
||||
window_manager::revertible_mutex::revertible_mutex()
|
||||
: impl_(new implementation)
|
||||
{
|
||||
impl_->thread.tid = 0;
|
||||
impl_->thread.ref = 0;
|
||||
}
|
||||
|
||||
window_manager::revertible_mutex::~revertible_mutex()
|
||||
{
|
||||
delete impl_;
|
||||
}
|
||||
|
||||
void window_manager::revertible_mutex::lock()
|
||||
{
|
||||
std::recursive_mutex::lock();
|
||||
if(0 == thr_.tid)
|
||||
thr_.tid = nana::system::this_thread_id();
|
||||
++thr_.refcnt;
|
||||
impl_->mutex.lock();
|
||||
|
||||
if(0 == impl_->thread.tid)
|
||||
impl_->thread.tid = nana::system::this_thread_id();
|
||||
|
||||
++(impl_->thread.ref);
|
||||
}
|
||||
|
||||
bool window_manager::revertible_mutex::try_lock()
|
||||
{
|
||||
if(std::recursive_mutex::try_lock())
|
||||
if(impl_->mutex.try_lock())
|
||||
{
|
||||
if(0 == thr_.tid)
|
||||
thr_.tid = nana::system::this_thread_id();
|
||||
++thr_.refcnt;
|
||||
if (0 == impl_->thread.tid)
|
||||
impl_->thread.tid = nana::system::this_thread_id();
|
||||
|
||||
++(impl_->thread.ref);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -137,44 +154,45 @@ namespace detail
|
||||
|
||||
void window_manager::revertible_mutex::unlock()
|
||||
{
|
||||
if(thr_.tid == nana::system::this_thread_id())
|
||||
if(0 == --thr_.refcnt)
|
||||
thr_.tid = 0;
|
||||
std::recursive_mutex::unlock();
|
||||
if(impl_->thread.tid == nana::system::this_thread_id())
|
||||
if(0 == --(impl_->thread.ref))
|
||||
impl_->thread.tid = 0;
|
||||
|
||||
impl_->mutex.unlock();
|
||||
}
|
||||
|
||||
void window_manager::revertible_mutex::revert()
|
||||
{
|
||||
if(thr_.refcnt && (thr_.tid == nana::system::this_thread_id()))
|
||||
if(impl_->thread.ref && (impl_->thread.tid == nana::system::this_thread_id()))
|
||||
{
|
||||
std::size_t cnt = thr_.refcnt;
|
||||
std::size_t cnt = impl_->thread.ref;
|
||||
|
||||
stack_.push_back(thr_);
|
||||
thr_.tid = 0;
|
||||
thr_.refcnt = 0;
|
||||
impl_->invoke_stack.push_back(impl_->thread);
|
||||
impl_->thread.tid = 0;
|
||||
impl_->thread.ref = 0;
|
||||
|
||||
for(std::size_t i = 0; i < cnt; ++i)
|
||||
std::recursive_mutex::unlock();
|
||||
for (std::size_t i = 0; i < cnt; ++i)
|
||||
impl_->mutex.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void window_manager::revertible_mutex::forward()
|
||||
{
|
||||
std::recursive_mutex::lock();
|
||||
if(stack_.size())
|
||||
impl_->mutex.lock();
|
||||
if(impl_->invoke_stack.size())
|
||||
{
|
||||
auto thr = stack_.back();
|
||||
auto thr = impl_->invoke_stack.back();
|
||||
if(thr.tid == nana::system::this_thread_id())
|
||||
{
|
||||
stack_.pop_back();
|
||||
for(std::size_t i = 0; i < thr.refcnt; ++i)
|
||||
std::recursive_mutex::lock();
|
||||
thr_ = thr;
|
||||
impl_->invoke_stack.pop_back();
|
||||
for (std::size_t i = 0; i < thr.ref; ++i)
|
||||
impl_->mutex.lock();
|
||||
impl_->thread = thr;
|
||||
}
|
||||
else
|
||||
throw std::runtime_error("Nana.GUI: The forward is not matched.");
|
||||
}
|
||||
std::recursive_mutex::unlock();
|
||||
impl_->mutex.unlock();
|
||||
}
|
||||
//end class revertible_mutex
|
||||
|
||||
@@ -254,23 +272,13 @@ namespace detail
|
||||
return (impl_->wd_register.available(a) && impl_->wd_register.available(b));
|
||||
}
|
||||
|
||||
bool window_manager::available(native_window_type wd)
|
||||
{
|
||||
if(wd)
|
||||
{
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
return (impl_->misc_register.find(wd) != nullptr);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
window_manager::core_window_t* window_manager::create_root(core_window_t* owner, bool nested, rectangle r, const appearance& app, widget* wdg)
|
||||
{
|
||||
native_window_type native = nullptr;
|
||||
if (owner)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
|
||||
if (impl_->wd_register.available(owner))
|
||||
{
|
||||
@@ -306,11 +314,10 @@ namespace detail
|
||||
wd->title = native_interface::window_caption(result.native_handle);
|
||||
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
|
||||
//create Root graphics Buffer and manage it
|
||||
root_misc misc(wd, result.width, result.height);
|
||||
auto* value = impl_->misc_register.insert(result.native_handle, misc);
|
||||
auto* value = impl_->misc_register.insert(result.native_handle, root_misc(wd, result.width, result.height));
|
||||
|
||||
wd->bind_native_window(result.native_handle, result.width, result.height, result.extra_width, result.extra_height, value->root_graph);
|
||||
impl_->wd_register.insert(wd, wd->thread_id);
|
||||
@@ -331,7 +338,7 @@ namespace detail
|
||||
window_manager::core_window_t* window_manager::create_frame(core_window_t* parent, const rectangle& r, widget* wdg)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
|
||||
if (impl_->wd_register.available(parent) == false) return nullptr;
|
||||
|
||||
@@ -350,7 +357,7 @@ namespace detail
|
||||
if(frame)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if(category::flags::frame == frame->other.category)
|
||||
frame->other.attribute.frame->attach.push_back(wd);
|
||||
return true;
|
||||
@@ -363,7 +370,7 @@ namespace detail
|
||||
if(frame)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if(category::flags::frame == frame->other.category)
|
||||
{
|
||||
if (impl_->wd_register.available(wd) && (category::flags::root == wd->other.category) && wd->root != frame->root)
|
||||
@@ -380,7 +387,7 @@ namespace detail
|
||||
window_manager::core_window_t* window_manager::create_widget(core_window_t* parent, const rectangle& r, bool is_lite, widget* wdg)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (impl_->wd_register.available(parent) == false)
|
||||
throw std::invalid_argument("invalid parent/owner handle");
|
||||
|
||||
@@ -401,7 +408,7 @@ namespace detail
|
||||
void window_manager::close(core_window_t *wd)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (impl_->wd_register.available(wd) == false) return;
|
||||
|
||||
if (wd->flags.destroying)
|
||||
@@ -443,7 +450,7 @@ namespace detail
|
||||
void window_manager::destroy(core_window_t* wd)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (impl_->wd_register.available(wd) == false) return;
|
||||
|
||||
rectangle update_area(wd->pos_owner, wd->dimension);
|
||||
@@ -467,7 +474,7 @@ namespace detail
|
||||
void window_manager::destroy_handle(core_window_t* wd)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (impl_->wd_register.available(wd) == false) return;
|
||||
|
||||
#ifndef WIDGET_FRAME_DEPRECATED
|
||||
@@ -491,7 +498,7 @@ namespace detail
|
||||
{
|
||||
if(!big_icon.empty() || !small_icon.empty())
|
||||
{
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (impl_->wd_register.available(wd))
|
||||
{
|
||||
if(category::flags::root == wd->other.category)
|
||||
@@ -505,7 +512,7 @@ namespace detail
|
||||
bool window_manager::show(core_window_t* wd, bool visible)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (!impl_->wd_register.available(wd))
|
||||
return false;
|
||||
|
||||
@@ -548,7 +555,7 @@ namespace detail
|
||||
if((false == attr_.capture.ignore_children) || (nullptr == attr_.capture.window) || (attr_.capture.window->root != root))
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
auto rrt = root_runtime(root);
|
||||
point pos{ x, y };
|
||||
if (rrt && _m_effective(rrt->window, pos))
|
||||
@@ -561,7 +568,7 @@ namespace detail
|
||||
bool window_manager::move(core_window_t* wd, int x, int y, bool passive)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (impl_->wd_register.available(wd))
|
||||
{
|
||||
if (category::flags::root != wd->other.category)
|
||||
@@ -606,7 +613,7 @@ namespace detail
|
||||
bool window_manager::move(core_window_t* wd, const rectangle& r)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (!impl_->wd_register.available(wd))
|
||||
return false;
|
||||
|
||||
@@ -680,7 +687,7 @@ namespace detail
|
||||
bool window_manager::size(core_window_t* wd, nana::size sz, bool passive, bool ask_update)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (!impl_->wd_register.available(wd))
|
||||
return false;
|
||||
|
||||
@@ -767,7 +774,7 @@ namespace detail
|
||||
if(cache.first == wd) return cache.second;
|
||||
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
|
||||
auto rrt = root_runtime(wd);
|
||||
if(rrt)
|
||||
@@ -783,7 +790,7 @@ namespace detail
|
||||
void window_manager::map(core_window_t* wd, bool forced, const rectangle* update_area)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (impl_->wd_register.available(wd) && !wd->is_draw_through())
|
||||
{
|
||||
auto parent = wd->parent;
|
||||
@@ -805,7 +812,7 @@ namespace detail
|
||||
bool window_manager::update(core_window_t* wd, bool redraw, bool forced, const rectangle* update_area)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (impl_->wd_register.available(wd) == false) return false;
|
||||
|
||||
if (wd->displayed())
|
||||
@@ -837,7 +844,7 @@ namespace detail
|
||||
void window_manager::refresh_tree(core_window_t* wd)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
|
||||
//It's not worthy to redraw if visible is false
|
||||
if (impl_->wd_register.available(wd) && wd->displayed())
|
||||
@@ -850,7 +857,7 @@ namespace detail
|
||||
bool window_manager::do_lazy_refresh(core_window_t* wd, bool force_copy_to_screen, bool refresh_tree)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
|
||||
if (false == impl_->wd_register.available(wd))
|
||||
return false;
|
||||
@@ -888,7 +895,7 @@ namespace detail
|
||||
bool window_manager::get_graphics(core_window_t* wd, nana::paint::graphics& result)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (!impl_->wd_register.available(wd))
|
||||
return false;
|
||||
|
||||
@@ -901,7 +908,7 @@ namespace detail
|
||||
bool window_manager::get_visual_rectangle(core_window_t* wd, nana::rectangle& r)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
return (impl_->wd_register.available(wd) ?
|
||||
window_layer::read_visual_rectangle(wd, r) :
|
||||
false);
|
||||
@@ -909,7 +916,7 @@ namespace detail
|
||||
|
||||
std::vector<window_manager::core_window_t*> window_manager::get_children(core_window_t* wd) const
|
||||
{
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (impl_->wd_register.available(wd))
|
||||
return wd->children;
|
||||
return{};
|
||||
@@ -918,7 +925,7 @@ namespace detail
|
||||
bool window_manager::set_parent(core_window_t* wd, core_window_t* newpa)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (!impl_->wd_register.available(wd))
|
||||
return false;
|
||||
|
||||
@@ -945,7 +952,7 @@ namespace detail
|
||||
window_manager::core_window_t* window_manager::set_focus(core_window_t* wd, bool root_has_been_focused, arg_focus::reason reason)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
|
||||
if (!impl_->wd_register.available(wd))
|
||||
return nullptr;
|
||||
@@ -1051,7 +1058,7 @@ namespace detail
|
||||
if(wd != attr_.capture.window)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
|
||||
if (impl_->wd_register.available(wd))
|
||||
{
|
||||
@@ -1112,7 +1119,7 @@ namespace detail
|
||||
void window_manager::enable_tabstop(core_window_t* wd)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (impl_->wd_register.available(wd) && (detail::tab_type::none == wd->flags.tab))
|
||||
{
|
||||
wd->root_widget->other.attribute.root->tabstop.push_back(wd);
|
||||
@@ -1156,7 +1163,7 @@ namespace detail
|
||||
auto window_manager::tabstop(core_window_t* wd, bool forward) const -> core_window_t*
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (!impl_->wd_register.available(wd))
|
||||
return nullptr;
|
||||
|
||||
@@ -1198,7 +1205,7 @@ namespace detail
|
||||
bool window_manager::enable_effects_bground(core_window_t* wd, bool enabled)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (impl_->wd_register.available(wd))
|
||||
return window_layer::enable_effects_bground(wd, enabled);
|
||||
|
||||
@@ -1208,7 +1215,7 @@ namespace detail
|
||||
bool window_manager::calc_window_point(core_window_t* wd, nana::point& pos)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (impl_->wd_register.available(wd))
|
||||
{
|
||||
if(native_interface::calc_window_point(wd->root, pos))
|
||||
@@ -1220,7 +1227,7 @@ namespace detail
|
||||
return false;
|
||||
}
|
||||
|
||||
root_misc* window_manager::root_runtime(native_window_type native_wd) const
|
||||
root_misc* window_manager::root_runtime(native_window native_wd) const
|
||||
{
|
||||
return impl_->misc_register.find(native_wd);
|
||||
}
|
||||
@@ -1228,7 +1235,7 @@ namespace detail
|
||||
bool window_manager::register_shortkey(core_window_t* wd, unsigned long key)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (impl_->wd_register.available(wd))
|
||||
{
|
||||
auto object = root_runtime(wd->root);
|
||||
@@ -1241,7 +1248,7 @@ namespace detail
|
||||
void window_manager::unregister_shortkey(core_window_t* wd, bool with_children)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (impl_->wd_register.available(wd) == false) return;
|
||||
|
||||
auto root_rt = root_runtime(wd->root);
|
||||
@@ -1261,7 +1268,7 @@ namespace detail
|
||||
std::vector<std::pair<core_window_t*, unsigned long>> result;
|
||||
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (impl_->wd_register.available(wd))
|
||||
{
|
||||
auto root_rt = root_runtime(wd->root);
|
||||
@@ -1290,7 +1297,7 @@ namespace detail
|
||||
if(native_window)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
auto object = root_runtime(native_window);
|
||||
if(object)
|
||||
return reinterpret_cast<core_window_t*>(object->shortkeys.find(key));
|
||||
@@ -1302,7 +1309,7 @@ namespace detail
|
||||
{
|
||||
if (fn)
|
||||
{
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
if (!available(wd))
|
||||
return;
|
||||
|
||||
@@ -1312,21 +1319,21 @@ namespace detail
|
||||
|
||||
void window_manager::call_safe_place(unsigned thread_id)
|
||||
{
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
std::lock_guard<mutex_type> lock(mutex_);
|
||||
|
||||
for (auto i = impl_->safe_place.begin(); i != impl_->safe_place.end();)
|
||||
auto& safe_place = impl_->safe_place.table();
|
||||
for (auto i = safe_place.begin(); i != safe_place.end();)
|
||||
{
|
||||
if (i->first->thread_id == thread_id)
|
||||
{
|
||||
for (auto & fn : i->second)
|
||||
fn();
|
||||
|
||||
i = impl_->safe_place.erase(i);
|
||||
i = safe_place.erase(i);
|
||||
}
|
||||
else
|
||||
++i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool check_tree(basic_window* wd, basic_window* const cond)
|
||||
|
||||
@@ -159,7 +159,7 @@ namespace nana
|
||||
}
|
||||
});
|
||||
|
||||
triggers_.push_back(tg);
|
||||
triggers_.emplace_back(tg);
|
||||
}
|
||||
private:
|
||||
static void _m_check_restrict_area(nana::point & pos, const nana::size & size, const nana::rectangle& restr_area)
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include <nana/gui/detail/element_store.hpp>
|
||||
#include <nana/paint/image.hpp>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#if defined(STD_THREAD_NOT_SUPPORTED)
|
||||
#include <nana/std_mutex.hpp>
|
||||
@@ -599,7 +598,6 @@ namespace nana
|
||||
{
|
||||
using element_type = ElementInterface;
|
||||
using factory_interface = pat::cloneable<element::detail::factory_abstract>;
|
||||
|
||||
public:
|
||||
~element_object()
|
||||
{
|
||||
@@ -1156,46 +1154,48 @@ namespace nana
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct bground::implementation
|
||||
{
|
||||
draw_method * method{ nullptr };
|
||||
|
||||
bool vert{ false };
|
||||
rectangle valid_area;
|
||||
std::vector<element_state> states;
|
||||
std::map<element_state, element_state> join;
|
||||
|
||||
bool stretch_all{ true };
|
||||
unsigned left{ 0 }, top{ 0 }, right{ 0 }, bottom{ 0 };
|
||||
};
|
||||
|
||||
|
||||
bground::bground()
|
||||
: method_(nullptr),
|
||||
vertical_(false),
|
||||
stretch_all_(true),
|
||||
left_(0), top_(0), right_(0), bottom_(0)
|
||||
: impl_{ new implementation }
|
||||
{
|
||||
reset_states();
|
||||
}
|
||||
|
||||
bground::bground(const bground& rhs)
|
||||
: method_(rhs.method_ ? rhs.method_->clone() : nullptr),
|
||||
vertical_(rhs.vertical_),
|
||||
valid_area_(rhs.valid_area_),
|
||||
states_(rhs.states_),
|
||||
join_(rhs.join_),
|
||||
stretch_all_(rhs.stretch_all_),
|
||||
left_(rhs.left_), top_(rhs.top_), right_(rhs.right_), bottom_(rhs.bottom_)
|
||||
: impl_{ new implementation }
|
||||
{
|
||||
if (impl_->method)
|
||||
impl_->method = impl_->method->clone();
|
||||
}
|
||||
|
||||
bground::~bground()
|
||||
{
|
||||
delete method_;
|
||||
delete impl_->method;
|
||||
}
|
||||
|
||||
bground& bground::operator=(const bground& rhs)
|
||||
{
|
||||
if (this != &rhs)
|
||||
{
|
||||
delete method_;
|
||||
method_ = (rhs.method_ ? rhs.method_->clone() : nullptr);
|
||||
vertical_ = rhs.vertical_;
|
||||
valid_area_ = rhs.valid_area_;
|
||||
states_ = rhs.states_;
|
||||
join_ = rhs.join_;
|
||||
stretch_all_ = rhs.stretch_all_;
|
||||
left_ = rhs.left_;
|
||||
top_ = rhs.top_;
|
||||
right_ = rhs.right_;
|
||||
bottom_ = rhs.bottom_;
|
||||
delete impl_->method;
|
||||
|
||||
impl_.reset(new implementation(*rhs.impl_));
|
||||
if (impl_->method)
|
||||
impl_->method = impl_->method->clone();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -1203,106 +1203,110 @@ namespace nana
|
||||
//Set a picture for the background
|
||||
bground& bground::image(const paint::image& img, bool vertical, const nana::rectangle& valid_area)
|
||||
{
|
||||
delete method_;
|
||||
method_ = new draw_image(img);
|
||||
vertical_ = vertical;
|
||||
delete impl_->method;
|
||||
impl_->method = new draw_image(img);
|
||||
impl_->vert = vertical;
|
||||
|
||||
if (valid_area.width && valid_area.height)
|
||||
valid_area_ = valid_area;
|
||||
impl_->valid_area = valid_area;
|
||||
else
|
||||
valid_area_ = nana::rectangle(img.size());
|
||||
impl_->valid_area = nana::rectangle(img.size());
|
||||
return *this;
|
||||
}
|
||||
|
||||
bground& bground::image(const paint::graphics& graph, bool vertical, const nana::rectangle& valid_area)
|
||||
{
|
||||
delete method_;
|
||||
method_ = new draw_graph(graph);
|
||||
vertical_ = vertical;
|
||||
delete impl_->method;
|
||||
impl_->method = new draw_graph(graph);
|
||||
impl_->vert = vertical;
|
||||
|
||||
if (valid_area.width && valid_area.height)
|
||||
valid_area_ = valid_area;
|
||||
impl_->valid_area = valid_area;
|
||||
else
|
||||
valid_area_ = nana::rectangle(graph.size());
|
||||
impl_->valid_area = nana::rectangle(graph.size());
|
||||
return *this;
|
||||
}
|
||||
|
||||
//Set the state sequence of the background picture.
|
||||
void bground::states(const std::vector<element_state> & s)
|
||||
{
|
||||
states_ = s;
|
||||
impl_->states = s;
|
||||
}
|
||||
|
||||
void bground::states(std::vector<element_state> && s)
|
||||
{
|
||||
states_ = std::move(s);
|
||||
impl_->states = std::move(s);
|
||||
}
|
||||
|
||||
void bground::reset_states()
|
||||
{
|
||||
states_.clear();
|
||||
states_.push_back(element_state::normal);
|
||||
states_.push_back(element_state::hovered);
|
||||
states_.push_back(element_state::focus_normal);
|
||||
states_.push_back(element_state::focus_hovered);
|
||||
states_.push_back(element_state::pressed);
|
||||
states_.push_back(element_state::disabled);
|
||||
join_.clear();
|
||||
auto & st = impl_->states;
|
||||
|
||||
st.clear();
|
||||
st.push_back(element_state::normal);
|
||||
st.push_back(element_state::hovered);
|
||||
st.push_back(element_state::focus_normal);
|
||||
st.push_back(element_state::focus_hovered);
|
||||
st.push_back(element_state::pressed);
|
||||
st.push_back(element_state::disabled);
|
||||
impl_->join.clear();
|
||||
}
|
||||
|
||||
void bground::join(element_state target, element_state joiner)
|
||||
{
|
||||
join_[joiner] = target;
|
||||
impl_->join[joiner] = target;
|
||||
}
|
||||
|
||||
void bground::stretch_parts(unsigned left, unsigned top, unsigned right, unsigned bottom)
|
||||
{
|
||||
left_ = left;
|
||||
top_ = top;
|
||||
right_ = right;
|
||||
bottom_ = bottom;
|
||||
impl_->left = left;
|
||||
impl_->right = right;
|
||||
impl_->top = top;
|
||||
impl_->bottom = bottom;
|
||||
|
||||
stretch_all_ = !(left || right || top || bottom);
|
||||
impl_->stretch_all = !(left || right || top || bottom);
|
||||
}
|
||||
|
||||
//Implement the methods of bground_interface.
|
||||
bool bground::draw(graph_reference dst, const ::nana::color&, const ::nana::color&, const nana::rectangle& to_r, element_state state)
|
||||
{
|
||||
if (nullptr == method_)
|
||||
const auto method = impl_->method;
|
||||
|
||||
if (nullptr == method)
|
||||
return false;
|
||||
|
||||
auto mi = join_.find(state);
|
||||
if (mi != join_.end())
|
||||
auto mi = impl_->join.find(state);
|
||||
if (mi != impl_->join.end())
|
||||
state = mi->second;
|
||||
|
||||
std::size_t pos = 0;
|
||||
for (; pos < states_.size(); ++pos)
|
||||
for (; pos < impl_->states.size(); ++pos)
|
||||
{
|
||||
if (states_[pos] == state)
|
||||
if (impl_->states[pos] == state)
|
||||
break;
|
||||
}
|
||||
|
||||
if (pos == states_.size())
|
||||
if (pos == impl_->states.size())
|
||||
return false;
|
||||
|
||||
nana::rectangle from_r = valid_area_;
|
||||
if (vertical_)
|
||||
nana::rectangle from_r = impl_->valid_area;
|
||||
if (impl_->vert)
|
||||
{
|
||||
from_r.height /= static_cast<unsigned>(states_.size());
|
||||
from_r.height /= static_cast<unsigned>(impl_->states.size());
|
||||
from_r.y += static_cast<int>(from_r.height * pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
from_r.width /= static_cast<unsigned>(states_.size());
|
||||
from_r.width /= static_cast<unsigned>(impl_->states.size());
|
||||
from_r.x += static_cast<int>(from_r.width * pos);
|
||||
}
|
||||
|
||||
if (stretch_all_)
|
||||
if (impl_->stretch_all)
|
||||
{
|
||||
if (from_r.width == to_r.width && from_r.height == to_r.height)
|
||||
method_->paste(from_r, dst, to_r.position());
|
||||
method->paste(from_r, dst, to_r.position());
|
||||
else
|
||||
method_->stretch(from_r, dst, to_r);
|
||||
method->stretch(from_r, dst, to_r);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1311,118 +1315,123 @@ namespace nana
|
||||
auto perf_from_r = from_r;
|
||||
auto perf_to_r = to_r;
|
||||
|
||||
if (left_ + right_ < to_r.width)
|
||||
const auto left = impl_->left;
|
||||
const auto right = impl_->right;
|
||||
const auto top = impl_->top;
|
||||
const auto bottom = impl_->bottom;
|
||||
|
||||
if (left + right < to_r.width)
|
||||
{
|
||||
nana::rectangle src_r = from_r;
|
||||
src_r.y += static_cast<int>(top_);
|
||||
src_r.height -= top_ + bottom_;
|
||||
src_r.y += static_cast<int>(top);
|
||||
src_r.height -= top + bottom;
|
||||
|
||||
nana::rectangle dst_r = to_r;
|
||||
dst_r.y += static_cast<int>(top_);
|
||||
dst_r.height -= top_ + bottom_;
|
||||
dst_r.y += static_cast<int>(top);
|
||||
dst_r.height -= top + bottom;
|
||||
|
||||
if (left_)
|
||||
if (left)
|
||||
{
|
||||
src_r.width = left_;
|
||||
dst_r.width = left_;
|
||||
src_r.width = left;
|
||||
dst_r.width = left;
|
||||
|
||||
method_->stretch(src_r, dst, dst_r);
|
||||
method->stretch(src_r, dst, dst_r);
|
||||
|
||||
perf_from_r.x += static_cast<int>(left_);
|
||||
perf_from_r.width -= left_;
|
||||
perf_to_r.x += static_cast<int>(left_);
|
||||
perf_to_r.width -= left_;
|
||||
perf_from_r.x += static_cast<int>(left);
|
||||
perf_from_r.width -= left;
|
||||
perf_to_r.x += static_cast<int>(left);
|
||||
perf_to_r.width -= left;
|
||||
}
|
||||
|
||||
if (right_)
|
||||
if (right)
|
||||
{
|
||||
src_r.x += (static_cast<int>(from_r.width) - static_cast<int>(right_));
|
||||
src_r.width = right_;
|
||||
src_r.x += (static_cast<int>(from_r.width) - static_cast<int>(right));
|
||||
src_r.width = right;
|
||||
|
||||
dst_r.x += (static_cast<int>(to_r.width) - static_cast<int>(right_));
|
||||
dst_r.width = right_;
|
||||
dst_r.x += (static_cast<int>(to_r.width) - static_cast<int>(right));
|
||||
dst_r.width = right;
|
||||
|
||||
method_->stretch(src_r, dst, dst_r);
|
||||
method->stretch(src_r, dst, dst_r);
|
||||
|
||||
perf_from_r.width -= right_;
|
||||
perf_to_r.width -= right_;
|
||||
perf_from_r.width -= right;
|
||||
perf_to_r.width -= right;
|
||||
}
|
||||
}
|
||||
|
||||
if (top_ + bottom_ < to_r.height)
|
||||
if (top + bottom < to_r.height)
|
||||
{
|
||||
nana::rectangle src_r = from_r;
|
||||
src_r.x += static_cast<int>(left_);
|
||||
src_r.width -= left_ + right_;
|
||||
src_r.x += static_cast<int>(left);
|
||||
src_r.width -= left + right;
|
||||
|
||||
nana::rectangle dst_r = to_r;
|
||||
dst_r.x += static_cast<int>(left_);
|
||||
dst_r.width -= left_ + right_;
|
||||
dst_r.x += static_cast<int>(left);
|
||||
dst_r.width -= left + right;
|
||||
|
||||
if (top_)
|
||||
if (top)
|
||||
{
|
||||
src_r.height = top_;
|
||||
dst_r.height = top_;
|
||||
src_r.height = top;
|
||||
dst_r.height = top;
|
||||
|
||||
method_->stretch(src_r, dst, dst_r);
|
||||
method->stretch(src_r, dst, dst_r);
|
||||
|
||||
perf_from_r.y += static_cast<int>(top_);
|
||||
perf_to_r.y += static_cast<int>(top_);
|
||||
perf_from_r.y += static_cast<int>(top);
|
||||
perf_to_r.y += static_cast<int>(top);
|
||||
}
|
||||
|
||||
if (bottom_)
|
||||
if (bottom)
|
||||
{
|
||||
src_r.y += static_cast<int>(from_r.height - bottom_);
|
||||
src_r.height = bottom_;
|
||||
src_r.y += static_cast<int>(from_r.height - bottom);
|
||||
src_r.height = bottom;
|
||||
|
||||
dst_r.y += static_cast<int>(to_r.height - bottom_);
|
||||
dst_r.height = bottom_;
|
||||
dst_r.y += static_cast<int>(to_r.height - bottom);
|
||||
dst_r.height = bottom;
|
||||
|
||||
method_->stretch(src_r, dst, dst_r);
|
||||
method->stretch(src_r, dst, dst_r);
|
||||
}
|
||||
|
||||
perf_from_r.height -= (top_ + bottom_);
|
||||
perf_to_r.height -= (top_ + bottom_);
|
||||
perf_from_r.height -= (top + bottom);
|
||||
perf_to_r.height -= (top + bottom);
|
||||
}
|
||||
|
||||
if (left_)
|
||||
if (left)
|
||||
{
|
||||
nana::rectangle src_r = from_r;
|
||||
src_r.width = left_;
|
||||
if (top_)
|
||||
src_r.width = left;
|
||||
if (top)
|
||||
{
|
||||
src_r.height = top_;
|
||||
method_->paste(src_r, dst, to_r.position());
|
||||
src_r.height = top;
|
||||
method->paste(src_r, dst, to_r.position());
|
||||
}
|
||||
if (bottom_)
|
||||
if (bottom)
|
||||
{
|
||||
src_r.y += static_cast<int>(from_r.height) - static_cast<int>(bottom_);
|
||||
src_r.height = bottom_;
|
||||
method_->paste(src_r, dst, nana::point(to_r.x, to_r.y + static_cast<int>(to_r.height - bottom_)));
|
||||
src_r.y += static_cast<int>(from_r.height) - static_cast<int>(bottom);
|
||||
src_r.height = bottom;
|
||||
method->paste(src_r, dst, nana::point(to_r.x, to_r.y + static_cast<int>(to_r.height - bottom)));
|
||||
}
|
||||
}
|
||||
|
||||
if (right_)
|
||||
if (right)
|
||||
{
|
||||
const int to_x = to_r.x + int(to_r.width - right_);
|
||||
const int to_x = to_r.x + int(to_r.width - right);
|
||||
|
||||
nana::rectangle src_r = from_r;
|
||||
src_r.x += static_cast<int>(src_r.width) - static_cast<int>(right_);
|
||||
src_r.width = right_;
|
||||
if (top_)
|
||||
src_r.x += static_cast<int>(src_r.width) - static_cast<int>(right);
|
||||
src_r.width = right;
|
||||
if (top)
|
||||
{
|
||||
src_r.height = top_;
|
||||
method_->paste(src_r, dst, nana::point(to_x, to_r.y));
|
||||
src_r.height = top;
|
||||
method->paste(src_r, dst, nana::point(to_x, to_r.y));
|
||||
}
|
||||
if (bottom_)
|
||||
if (bottom)
|
||||
{
|
||||
src_r.y += (static_cast<int>(from_r.height) - static_cast<int>(bottom_));
|
||||
src_r.height = bottom_;
|
||||
method_->paste(src_r, dst, nana::point(to_x, to_r.y + int(to_r.height - bottom_)));
|
||||
src_r.y += (static_cast<int>(from_r.height) - static_cast<int>(bottom));
|
||||
src_r.height = bottom;
|
||||
method->paste(src_r, dst, nana::point(to_x, to_r.y + int(to_r.height - bottom)));
|
||||
}
|
||||
}
|
||||
|
||||
method_->stretch(perf_from_r, dst, perf_to_r);
|
||||
method->stretch(perf_from_r, dst, perf_to_r);
|
||||
return true;
|
||||
}
|
||||
//end class bground
|
||||
|
||||
@@ -661,13 +661,14 @@ namespace nana
|
||||
//This is a splitter, it only checks when it is being displayed
|
||||
if (dsp)
|
||||
{
|
||||
//Left field of splitterbar
|
||||
auto left = this->previous();
|
||||
if (left && !left->display)
|
||||
left->set_display(true);
|
||||
|
||||
auto right = div_next;
|
||||
if (right && !right->display)
|
||||
right->set_display(true);
|
||||
//Right field of splitterbar
|
||||
if (div_next && !div_next->display)
|
||||
div_next->set_display(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace API
|
||||
{
|
||||
if (iwd->effect.edge_nimbus == effects::edge_nimbus::none)
|
||||
{
|
||||
cont.push_back(basic_window::edge_nimbus_action{ iwd, false});
|
||||
cont.emplace_back(basic_window::edge_nimbus_action{ iwd, false});
|
||||
}
|
||||
iwd->effect.edge_nimbus = static_cast<effects::edge_nimbus>(static_cast<unsigned>(en) | static_cast<unsigned>(iwd->effect.edge_nimbus));
|
||||
}
|
||||
@@ -365,7 +365,7 @@ namespace API
|
||||
}
|
||||
|
||||
if (!exists)
|
||||
roots.push_back(root);
|
||||
roots.emplace_back(root);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ namespace API
|
||||
}
|
||||
|
||||
if (!exists)
|
||||
roots.push_back(root);
|
||||
roots.emplace_back(root);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,8 +47,7 @@ namespace nana
|
||||
|
||||
friend class timer_core;
|
||||
|
||||
timer_driver()
|
||||
{}
|
||||
timer_driver() = default;
|
||||
public:
|
||||
static timer_driver& instance()
|
||||
{
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace nana
|
||||
typedef widget_object<category::root_tag, drawer> base_type;
|
||||
public:
|
||||
tip_form()
|
||||
: base_type(nana::rectangle(), appear::bald<appear::floating>()),
|
||||
: base_type(nullptr, false, rectangle(), appear::bald<appear::floating>()),
|
||||
duration_(0)
|
||||
{
|
||||
API::take_active(this->handle(), false, nullptr);
|
||||
|
||||
@@ -285,8 +285,7 @@ namespace nana{ namespace drawerbase
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
ui_container_.push_back(el);
|
||||
ui_container_.emplace_back(el);
|
||||
}
|
||||
|
||||
std::size_t radio_group::checked() const
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace nana
|
||||
editor_->show_caret(enb);
|
||||
if (!enb)
|
||||
{
|
||||
editor_->ext_renderer().background = [this](graph_reference graph, const ::nana::rectangle&, const ::nana::color&)
|
||||
editor_->customized_renderers().background = [this](graph_reference graph, const ::nana::rectangle&, const ::nana::color&)
|
||||
{
|
||||
auto clr_from = colors::button_face_shadow_start;
|
||||
auto clr_to = colors::button_face_shadow_end;
|
||||
@@ -190,7 +190,7 @@ namespace nana
|
||||
};
|
||||
}
|
||||
else
|
||||
editor_->ext_renderer().background = nullptr;
|
||||
editor_->customized_renderers().background = nullptr;
|
||||
|
||||
editor_->enable_background(enb);
|
||||
editor_->enable_background_counterpart(!enb);
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include <nana/gui/widgets/float_listbox.hpp>
|
||||
#include <nana/gui/widgets/scroll.hpp>
|
||||
|
||||
#include <nana/gui/layout_utility.hpp>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
namespace drawerbase{
|
||||
@@ -66,35 +68,7 @@ namespace nana
|
||||
unsigned vpix = (r.height - 4);
|
||||
if(item->image())
|
||||
{
|
||||
nana::size imgsz = item->image().size();
|
||||
if(imgsz.width > image_pixels_)
|
||||
{
|
||||
unsigned new_h = image_pixels_ * imgsz.height / imgsz.width;
|
||||
if(new_h > vpix)
|
||||
{
|
||||
imgsz.width = vpix * imgsz.width / imgsz.height;
|
||||
imgsz.height = vpix;
|
||||
}
|
||||
else
|
||||
{
|
||||
imgsz.width = image_pixels_;
|
||||
imgsz.height = new_h;
|
||||
}
|
||||
}
|
||||
else if(imgsz.height > vpix)
|
||||
{
|
||||
unsigned new_w = vpix * imgsz.width / imgsz.height;
|
||||
if(new_w > image_pixels_)
|
||||
{
|
||||
imgsz.height = image_pixels_ * imgsz.height / imgsz.width;
|
||||
imgsz.width = image_pixels_;
|
||||
}
|
||||
else
|
||||
{
|
||||
imgsz.height = vpix;
|
||||
imgsz.width = new_w;
|
||||
}
|
||||
}
|
||||
auto imgsz = nana::fit_zoom(item->image().size(), {image_pixels_, vpix});
|
||||
|
||||
nana::point to_pos(x, r.y + 2);
|
||||
to_pos.x += (image_pixels_ - imgsz.width) / 2;
|
||||
|
||||
@@ -206,15 +206,13 @@ namespace nana
|
||||
{
|
||||
if(fbp->target.size() || fbp->url.size())
|
||||
{
|
||||
traceable tr;
|
||||
traceable_.emplace_back();
|
||||
auto & tr = traceable_.back();
|
||||
tr.r.x = x;
|
||||
tr.r.y = y;
|
||||
tr.r.width = sz.width;
|
||||
tr.r.height = sz.height;
|
||||
tr.r.dimension(sz);
|
||||
tr.target = fbp->target;
|
||||
tr.url = fbp->url;
|
||||
|
||||
traceable_.push_back(tr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,7 +329,7 @@ namespace nana
|
||||
px.pixels = def_line_pixels;
|
||||
px.x_base = 0;
|
||||
|
||||
rs.pixels.push_back(px);
|
||||
rs.pixels.emplace_back(px);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -374,7 +372,7 @@ namespace nana
|
||||
if(max_ascent < as) max_ascent = as;
|
||||
if(max_descent < ds) max_descent = ds;
|
||||
if(max_px < sz.height) max_px = sz.height;
|
||||
line_values.push_back(i);
|
||||
line_values.emplace_back(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -393,13 +391,13 @@ namespace nana
|
||||
px.baseline = max_ascent;
|
||||
px.values.swap(line_values);
|
||||
|
||||
rs.pixels.push_back(px);
|
||||
rs.pixels.emplace_back(px);
|
||||
|
||||
w = sz.width;
|
||||
max_px = sz.height;
|
||||
max_ascent = as;
|
||||
max_descent = ds;
|
||||
line_values.push_back(i);
|
||||
line_values.emplace_back(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -409,9 +407,9 @@ namespace nana
|
||||
px.pixels = sz.height;
|
||||
px.baseline = as;
|
||||
|
||||
px.values.push_back(i);
|
||||
px.values.emplace_back(i);
|
||||
|
||||
rs.pixels.push_back(px);
|
||||
rs.pixels.emplace_back(px);
|
||||
max_px = 0;
|
||||
max_ascent = max_descent = 0;
|
||||
}
|
||||
@@ -432,7 +430,7 @@ namespace nana
|
||||
px.pixels = max_px;
|
||||
px.baseline = max_ascent;
|
||||
px.values.swap(line_values);
|
||||
rs.pixels.push_back(px);
|
||||
rs.pixels.emplace_back(px);
|
||||
}
|
||||
return total_w;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <nana/system/dataexch.hpp>
|
||||
#include <cassert>
|
||||
#include <mutex>
|
||||
#include <map>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
@@ -972,6 +973,7 @@ namespace nana
|
||||
|
||||
if (catobj.model_ptr)
|
||||
{
|
||||
throw_if_immutable_model(catobj.model_ptr.get());
|
||||
auto container = catobj.model_ptr->container();
|
||||
std::size_t item_index;
|
||||
//
|
||||
@@ -1249,28 +1251,17 @@ namespace nana
|
||||
return n;
|
||||
}
|
||||
|
||||
std::vector<cell>& get_cells(category_t * cat, std::size_t pos) const
|
||||
std::vector<cell> get_cells(category_t * cat, std::size_t pos) const
|
||||
{
|
||||
if (!cat)
|
||||
throw std::out_of_range("nana::listbox: category is null");
|
||||
|
||||
if (cat->model_ptr)
|
||||
throw std::runtime_error("nana::listbox disallow to get item cells, because there are model cells");
|
||||
return cat->model_ptr->container()->to_cells(pos);
|
||||
|
||||
return *(cat->items.at(pos).cells);
|
||||
}
|
||||
|
||||
std::vector<cell> get_model_cells(category_t* cat, std::size_t pos) const
|
||||
{
|
||||
if (!cat)
|
||||
throw std::out_of_range("nana::listbox: category is null");
|
||||
|
||||
if (!(cat->model_ptr))
|
||||
throw std::runtime_error("nana::listbox: the category hasn't a model");
|
||||
|
||||
return cat->model_ptr->container()->to_cells(pos);
|
||||
}
|
||||
|
||||
void text(category_t* cat, size_type pos, size_type col, cell&& cl, size_type columns)
|
||||
{
|
||||
if ((col < columns) && (pos < cat->items.size()))
|
||||
@@ -2868,8 +2859,8 @@ namespace nana
|
||||
return *this;
|
||||
}
|
||||
|
||||
iresolver::iresolver(const std::vector<cell>& cl)
|
||||
: cells_(cl)
|
||||
iresolver::iresolver(std::vector<cell> cl)
|
||||
: cells_(std::move(cl))
|
||||
{}
|
||||
|
||||
iresolver& iresolver::operator>>(cell& cl)
|
||||
@@ -4565,14 +4556,6 @@ namespace nana
|
||||
|
||||
std::string item_proxy::text(size_type col) const
|
||||
{
|
||||
if (cat_->model_ptr)
|
||||
{
|
||||
auto cells = cat_->model_ptr->container()->to_cells(pos_.item);
|
||||
if (col < cells.size())
|
||||
return cells[col].text;
|
||||
|
||||
return{};
|
||||
}
|
||||
return ess_->lister.get_cells(cat_, pos_.item).at(col).text;
|
||||
}
|
||||
|
||||
@@ -4692,7 +4675,7 @@ namespace nana
|
||||
return pos_;
|
||||
}
|
||||
|
||||
auto item_proxy::_m_cells() const -> std::vector<cell>&
|
||||
auto item_proxy::_m_cells() const -> std::vector<cell>
|
||||
{
|
||||
return ess_->lister.get_cells(cat_, pos_.item);
|
||||
}
|
||||
@@ -5027,9 +5010,24 @@ namespace nana
|
||||
|
||||
internal_scope_guard lock;
|
||||
|
||||
cat_->sorted.push_back(cat_->items.size());
|
||||
cells.resize(columns());
|
||||
cat_->items.emplace_back(std::move(cells));
|
||||
if (cat_->model_ptr)
|
||||
{
|
||||
es_lister::throw_if_immutable_model(cat_->model_ptr.get());
|
||||
|
||||
auto container = cat_->model_ptr->container();
|
||||
|
||||
auto item_index = container->size();
|
||||
cat_->items.emplace_back();
|
||||
container->emplace_back();
|
||||
|
||||
container->assign(item_index, cells);
|
||||
}
|
||||
else
|
||||
{
|
||||
cat_->sorted.push_back(cat_->items.size());
|
||||
cells.resize(columns());
|
||||
cat_->items.emplace_back(std::move(cells));
|
||||
}
|
||||
|
||||
assign_colors_for_last(ess_, cat_);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <nana/gui/wvl.hpp>
|
||||
#include <nana/paint/text_renderer.hpp>
|
||||
#include <cctype> //introduces tolower
|
||||
#include <map>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
||||
|
||||
#include <nana/gui/widgets/slider.hpp>
|
||||
#include <nana/paint/pixel_buffer.hpp>
|
||||
#include <cstring> //memcpy
|
||||
|
||||
namespace nana
|
||||
@@ -645,7 +646,6 @@ namespace nana
|
||||
{
|
||||
adorn.bound.x = static_cast<int>(attr_.adorn_pos + attr_.slider.border_weight + bar.area.y);
|
||||
adorn.bound.y = static_cast<int>(graph.height()) - static_cast<int>(attr_.slider.border_weight + bar.area.y);
|
||||
//adorn.bound.x =
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -65,7 +65,6 @@ namespace drawerbase {
|
||||
{
|
||||
auto wd = wdg.handle();
|
||||
widget_ = &wdg;
|
||||
evt_agent_.reset(new event_agent(static_cast<::nana::textbox&>(wdg), editor_->text_position()));
|
||||
|
||||
auto scheme = API::dev::get_scheme(wdg);
|
||||
|
||||
@@ -73,6 +72,8 @@ namespace drawerbase {
|
||||
editor_->textbase().set_event_agent(evt_agent_.get());
|
||||
editor_->set_event(evt_agent_.get());
|
||||
|
||||
evt_agent_.reset(new event_agent(static_cast<::nana::textbox&>(wdg), editor_->text_position()));
|
||||
|
||||
_m_text_area(graph.width(), graph.height());
|
||||
|
||||
API::tabstop(wd);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <nana/gui/layout_utility.hpp>
|
||||
#include <nana/system/platform.hpp>
|
||||
#include <stdexcept>
|
||||
#include <map>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user