remove typedef-name core_window_t
remove get_color and get_text_color of the internal class drawable
This commit is contained in:
Jinhao
2019-06-30 11:56:16 +08:00
parent 01bd43f960
commit 363a80e935
13 changed files with 198 additions and 242 deletions

View File

@@ -282,7 +282,7 @@ namespace detail
paint::image default_icon_big;
paint::image default_icon_small;
lite_map<core_window_t*, std::vector<std::function<void()>>> safe_place;
lite_map<basic_window*, std::vector<std::function<void()>>> safe_place;
};
//end struct wdm_private_impl
@@ -455,7 +455,7 @@ namespace detail
delete impl_;
}
std::size_t window_manager::number_of_core_window() const
std::size_t window_manager::window_count() const
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -468,14 +468,14 @@ namespace detail
return mutex_;
}
void window_manager::all_handles(std::vector<core_window_t*> &v) const
void window_manager::all_handles(std::vector<basic_window*> &v) const
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
v = impl_->wd_register.queue();
}
void window_manager::event_filter(core_window_t* wd, bool is_make, event_code evtid)
void window_manager::event_filter(basic_window* wd, bool is_make, event_code evtid)
{
switch(evtid)
{
@@ -487,21 +487,21 @@ namespace detail
}
}
bool window_manager::available(core_window_t* wd)
bool window_manager::available(basic_window* wd)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
return impl_->wd_register.available(wd);
}
bool window_manager::available(core_window_t * a, core_window_t* b)
bool window_manager::available(basic_window * a, basic_window* b)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
return (impl_->wd_register.available(a) && impl_->wd_register.available(b));
}
window_manager::core_window_t* window_manager::create_root(core_window_t* owner, bool nested, rectangle r, const appearance& app, widget* wdg)
basic_window* window_manager::create_root(basic_window* owner, bool nested, rectangle r, const appearance& app, widget* wdg)
{
native_window_type native = nullptr;
if (owner)
@@ -525,7 +525,7 @@ namespace detail
auto result = native_interface::create_window(native, nested, r, app);
if (result.native_handle)
{
auto wd = new core_window_t(owner, widget_notifier_interface::get_notifier(wdg), (category::root_tag**)nullptr);
auto wd = new basic_window(owner, widget_notifier_interface::get_notifier(wdg), (category::root_tag**)nullptr);
if (nested)
{
wd->owner = nullptr;
@@ -553,7 +553,7 @@ namespace detail
return nullptr;
}
window_manager::core_window_t* window_manager::create_widget(core_window_t* parent, const rectangle& r, bool is_lite, widget* wdg)
basic_window* window_manager::create_widget(basic_window* parent, const rectangle& r, bool is_lite, widget* wdg)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -565,17 +565,17 @@ namespace detail
auto wdg_notifier = widget_notifier_interface::get_notifier(wdg);
core_window_t * wd;
basic_window * wd;
if (is_lite)
wd = new core_window_t(parent, std::move(wdg_notifier), r, (category::lite_widget_tag**)nullptr);
wd = new basic_window(parent, std::move(wdg_notifier), r, (category::lite_widget_tag**)nullptr);
else
wd = new core_window_t(parent, std::move(wdg_notifier), r, (category::widget_tag**)nullptr);
wd = new basic_window(parent, std::move(wdg_notifier), r, (category::widget_tag**)nullptr);
impl_->wd_register.insert(wd);
return wd;
}
void window_manager::close(core_window_t *wd)
void window_manager::close(basic_window *wd)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -617,7 +617,7 @@ namespace detail
//destroy
//@brief: Delete the window handle
void window_manager::destroy(core_window_t* wd)
void window_manager::destroy(basic_window* wd)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -641,7 +641,7 @@ namespace detail
update(parent, false, false, &update_area);
}
void window_manager::destroy_handle(core_window_t* wd)
void window_manager::destroy_handle(basic_window* wd)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -654,7 +654,7 @@ namespace detail
}
}
void window_manager::icon(core_window_t* wd, const paint::image& small_icon, const paint::image& big_icon)
void window_manager::icon(basic_window* wd, const paint::image& small_icon, const paint::image& big_icon)
{
if(!big_icon.empty() || !small_icon.empty())
{
@@ -677,7 +677,7 @@ namespace detail
//show
//@brief: show or hide a window
bool window_manager::show(core_window_t* wd, bool visible)
bool window_manager::show(basic_window* wd, bool visible)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -702,7 +702,7 @@ namespace detail
return true;
}
window_manager::core_window_t* window_manager::find_window(native_window_type root, const point& pos, bool ignore_captured)
basic_window* window_manager::find_window(native_window_type root, const point& pos, bool ignore_captured)
{
if (nullptr == root)
return nullptr;
@@ -740,7 +740,7 @@ namespace detail
}
//move the wnd and its all children window, x and y is a relatively coordinate for wnd's parent window
bool window_manager::move(core_window_t* wd, int x, int y, bool passive)
bool window_manager::move(basic_window* wd, int x, int y, bool passive)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -789,7 +789,7 @@ namespace detail
return false;
}
bool window_manager::move(core_window_t* wd, const rectangle& r)
bool window_manager::move(basic_window* wd, const rectangle& r)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -865,7 +865,7 @@ namespace detail
// e.g, when the size of window is changed by OS/user, the function should not resize the
// window again, otherwise, it causes an infinite loop, because when a root_widget is resized,
// window_manager will call the function.
bool window_manager::size(core_window_t* wd, nana::size sz, bool passive, bool ask_update)
bool window_manager::size(basic_window* wd, nana::size sz, bool passive, bool ask_update)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -903,7 +903,7 @@ namespace detail
if (wd->dimension == sz)
return false;
std::vector<core_window_t*> presence;
std::vector<basic_window*> presence;
if (wd->dimension.width < sz.width || wd->dimension.height < sz.height)
{
@@ -978,9 +978,9 @@ namespace detail
return true;
}
window_manager::core_window_t* window_manager::root(native_window_type wd) const
basic_window* window_manager::root(native_window_type wd) const
{
static std::pair<native_window_type, core_window_t*> cache;
static std::pair<native_window_type, basic_window*> cache;
if(cache.first == wd) return cache.second;
//Thread-Safe Required!
@@ -997,7 +997,7 @@ namespace detail
}
//Copy the root buffer that wnd specified into DeviceContext
void window_manager::map(core_window_t* wd, bool forced, const rectangle* update_area)
void window_manager::map(basic_window* wd, bool forced, const rectangle* update_area)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -1009,7 +1009,7 @@ namespace detail
//@brief: update is used for displaying the screen-off buffer.
// Because of a good efficiency, if it is called in an event procedure and the event procedure window is the
// same as update's, update would not map the screen-off buffer and just set the window for lazy refresh
bool window_manager::update(core_window_t* wd, bool redraw, bool forced, const rectangle* update_area)
bool window_manager::update(basic_window* wd, bool redraw, bool forced, const rectangle* update_area)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -1046,13 +1046,13 @@ namespace detail
else if (redraw)
window_layer::paint(wd, paint_operation::try_refresh, false);
if (wd->other.upd_state == core_window_t::update_state::lazy)
wd->other.upd_state = core_window_t::update_state::refreshed;
if (wd->other.upd_state == basic_window::update_state::lazy)
wd->other.upd_state = basic_window::update_state::refreshed;
}
return true;
}
void window_manager::update_requesters(core_window_t* root_wd)
void window_manager::update_requesters(basic_window* root_wd)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -1075,7 +1075,7 @@ namespace detail
}
void window_manager::refresh_tree(core_window_t* wd)
void window_manager::refresh_tree(basic_window* wd)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -1087,7 +1087,7 @@ namespace detail
//do_lazy_refresh
//@brief: defined a behavior of flush the screen
void window_manager::do_lazy_refresh(core_window_t* wd, bool force_copy_to_screen, bool refresh_tree)
void window_manager::do_lazy_refresh(basic_window* wd, bool force_copy_to_screen, bool refresh_tree)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -1101,11 +1101,11 @@ namespace detail
using paint_operation = window_layer::paint_operation;
if (wd->visible_parents())
{
if ((wd->other.upd_state == core_window_t::update_state::refreshed) || (wd->other.upd_state == core_window_t::update_state::request_refresh) || force_copy_to_screen)
if ((wd->other.upd_state == basic_window::update_state::refreshed) || (wd->other.upd_state == basic_window::update_state::request_refresh) || force_copy_to_screen)
{
if (!wd->try_lazy_update(wd->other.upd_state == core_window_t::update_state::request_refresh))
if (!wd->try_lazy_update(wd->other.upd_state == basic_window::update_state::request_refresh))
{
window_layer::paint(wd, (wd->other.upd_state == core_window_t::update_state::request_refresh ? paint_operation::try_refresh : paint_operation::have_refreshed), refresh_tree);
window_layer::paint(wd, (wd->other.upd_state == basic_window::update_state::request_refresh ? paint_operation::try_refresh : paint_operation::have_refreshed), refresh_tree);
this->map(wd, force_copy_to_screen);
}
}
@@ -1124,10 +1124,10 @@ namespace detail
window_layer::paint(wd, paint_operation::try_refresh, refresh_tree); //only refreshing if it has an invisible parent
}
wd->other.upd_state = core_window_t::update_state::none;
wd->other.upd_state = basic_window::update_state::none;
}
bool window_manager::set_parent(core_window_t* wd, core_window_t* newpa)
bool window_manager::set_parent(basic_window* wd, basic_window* newpa)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -1154,7 +1154,7 @@ namespace detail
//set_focus
//@brief: set a keyboard focus to a window. this may fire a focus event.
window_manager::core_window_t* window_manager::set_focus(core_window_t* wd, bool root_has_been_focused, arg_focus::reason reason)
basic_window* window_manager::set_focus(basic_window* wd, bool root_has_been_focused, arg_focus::reason reason)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -1218,7 +1218,7 @@ namespace detail
return prev_focus;
}
window_manager::core_window_t* window_manager::capture_redirect(core_window_t* wd)
basic_window* window_manager::capture_redirect(basic_window* wd)
{
if(attr_.capture.window && (attr_.capture.ignore_children == false) && (attr_.capture.window != wd))
{
@@ -1245,12 +1245,12 @@ namespace detail
return false;
}
window_manager::core_window_t * window_manager::capture_window() const
basic_window * window_manager::capture_window() const
{
return attr_.capture.window;
}
void window_manager::capture_window(core_window_t* wd, bool captured, bool ignore_children)
void window_manager::capture_window(basic_window* wd, bool captured, bool ignore_children)
{
if (!this->available(wd))
return;
@@ -1286,7 +1286,7 @@ namespace detail
wd->flags.captured = false;
if(attr_cap.size())
{
std::pair<core_window_t*, bool> last = attr_cap.back();
std::pair<basic_window*, bool> last = attr_cap.back();
attr_cap.pop_back();
if (impl_->wd_register.available(last.first))
@@ -1321,7 +1321,7 @@ namespace detail
// this method insert a window which catches an user TAB into a TAB window container
// the TAB window container is held by a wd's root widget. Not every widget has a TAB window container,
// the container is created while a first Tab Window is setting
void window_manager::enable_tabstop(core_window_t* wd)
void window_manager::enable_tabstop(basic_window* wd)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -1333,7 +1333,7 @@ namespace detail
}
// preconditions of get_tabstop: tabstop is not empty and at least one window is visible
window_manager::core_window_t* get_tabstop(window_manager::core_window_t* wd, bool forward)
basic_window* get_tabstop(basic_window* wd, bool forward)
{
auto & tabs = wd->root_widget->other.attribute.root->tabstop;
@@ -1348,7 +1348,7 @@ namespace detail
if (i != end)
{
++i;
window_manager::core_window_t* ts = (i != end ? (*i) : tabs.front());
basic_window* ts = (i != end ? (*i) : tabs.front());
return (ts != wd ? ts : 0);
}
else
@@ -1364,7 +1364,7 @@ namespace detail
return nullptr;
}
auto window_manager::tabstop(core_window_t* wd, bool forward) const -> core_window_t*
auto window_manager::tabstop(basic_window* wd, bool forward) const -> basic_window*
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -1408,7 +1408,7 @@ namespace detail
impl_->wd_register.delete_trash(tid);
}
bool window_manager::enable_effects_bground(core_window_t* wd, bool enabled)
bool window_manager::enable_effects_bground(basic_window* wd, bool enabled)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -1418,7 +1418,7 @@ namespace detail
return false;
}
bool window_manager::calc_window_point(core_window_t* wd, nana::point& pos)
bool window_manager::calc_window_point(basic_window* wd, nana::point& pos)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -1438,7 +1438,7 @@ namespace detail
return impl_->misc_register.find(native_wd);
}
bool window_manager::register_shortkey(core_window_t* wd, unsigned long key)
bool window_manager::register_shortkey(basic_window* wd, unsigned long key)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -1450,7 +1450,7 @@ namespace detail
return false;
}
void window_manager::unregister_shortkey(core_window_t* wd, bool with_children)
void window_manager::unregister_shortkey(basic_window* wd, bool with_children)
{
//Thread-Safe Required!
std::lock_guard<mutex_type> lock(mutex_);
@@ -1468,7 +1468,7 @@ namespace detail
}
}
window_manager::core_window_t* window_manager::find_shortkey(native_window_type native_window, unsigned long key)
basic_window* window_manager::find_shortkey(native_window_type native_window, unsigned long key)
{
if(native_window)
{
@@ -1481,7 +1481,7 @@ namespace detail
return nullptr;
}
void window_manager::set_safe_place(core_window_t* wd, std::function<void()>&& fn)
void window_manager::set_safe_place(basic_window* wd, std::function<void()>&& fn)
{
if (fn)
{
@@ -1523,7 +1523,7 @@ namespace detail
return false;
}
void window_manager::_m_disengage(core_window_t* wd, core_window_t* for_new)
void window_manager::_m_disengage(basic_window* wd, basic_window* for_new)
{
auto * const wdpa = wd->parent;
@@ -1537,7 +1537,7 @@ namespace detail
//Holds the shortkeys of wd and its children, and then
//register these shortkeys for establishing.
std::vector<std::pair<core_window_t*,unsigned long>> sk_holder;
std::vector<std::pair<basic_window*,unsigned long>> sk_holder;
if ((!established) || (pa_root_attr != root_attr))
{
@@ -1656,8 +1656,8 @@ namespace detail
auto delta_pos = wd->pos_root - for_new->pos_root;
std::function<void(core_window_t*, const nana::point&)> set_pos_root;
set_pos_root = [&set_pos_root](core_window_t* wd, const nana::point& delta_pos)
std::function<void(basic_window*, const nana::point&)> set_pos_root;
set_pos_root = [&set_pos_root](basic_window* wd, const nana::point& delta_pos)
{
for (auto child : wd->children)
{
@@ -1688,7 +1688,7 @@ namespace detail
}
}
void window_manager::_m_destroy(core_window_t* wd)
void window_manager::_m_destroy(basic_window* wd)
{
if(wd->flags.destroying) return;
@@ -1738,7 +1738,7 @@ namespace detail
wd->drawer.graphics.release();
}
void window_manager::_m_move_core(core_window_t* wd, const point& delta)
void window_manager::_m_move_core(basic_window* wd, const point& delta)
{
if(category::flags::root != wd->other.category) //A root widget always starts at (0, 0) and its children are not to be changed
{
@@ -1760,7 +1760,7 @@ namespace detail
}
}
void window_manager::_m_shortkeys(core_window_t* wd, bool with_children, std::vector<std::pair<core_window_t*, unsigned long>>& keys) const
void window_manager::_m_shortkeys(basic_window* wd, bool with_children, std::vector<std::pair<basic_window*, unsigned long>>& keys) const
{
if (impl_->wd_register.available(wd))
{
@@ -1785,7 +1785,7 @@ namespace detail
//_m_find
//@brief: find a window on root window through a given root coordinate.
// the given root coordinate must be in the rectangle of wnd.
window_manager::core_window_t* window_manager::_m_find(core_window_t* wd, const point& pos)
basic_window* window_manager::_m_find(basic_window* wd, const point& pos)
{
if(!wd->visible)
return nullptr;
@@ -1809,7 +1809,7 @@ namespace detail
}
//_m_effective, test if the window is a handle of window that specified by (root_x, root_y)
bool window_manager::_m_effective(core_window_t* wd, const point& root_pos)
bool window_manager::_m_effective(basic_window* wd, const point& root_pos)
{
if(wd == nullptr || false == wd->visible) return false;
return rectangle{ wd->pos_root, wd->dimension }.is_hit(root_pos);