refactoring

This commit is contained in:
Jinhao
2019-03-08 06:11:21 +08:00
parent 0a3fb34e09
commit 2abae1dd68
11 changed files with 106 additions and 189 deletions

View File

@@ -298,34 +298,16 @@ namespace nana
};
}
static std::function<void(arg_reference)> build_second(fn_type&& fn, void(fn_type::*)(arg_reference))
template<typename Tfn, typename Ret>
static std::function<void(arg_reference)> build_second(Tfn&& fn, Ret(fn_type::*)(arg_reference))
{
return std::move(fn);
return std::forward<Tfn>(fn);
}
static std::function<void(arg_reference)> build_second(fn_type&& fn, void(fn_type::*)(arg_reference) const)
template<typename Tfn, typename Ret>
static std::function<void(arg_reference)> build_second(Tfn&& fn, Ret(fn_type::*)(arg_reference)const)
{
return std::move(fn);
}
static std::function<void(arg_reference)> build_second(fn_type& fn, void(fn_type::*)(arg_reference))
{
return fn;
}
static std::function<void(arg_reference)> build_second(fn_type& fn, void(fn_type::*)(arg_reference) const)
{
return fn;
}
static std::function<void(arg_reference)> build_second(const fn_type& fn, void(fn_type::*)(arg_reference))
{
return fn;
}
static std::function<void(arg_reference)> build_second(const fn_type& fn, void(fn_type::*)(arg_reference) const)
{
return fn;
return std::forward<Tfn>(fn);
}
template<typename Tfn, typename Ret, typename Arg2>
@@ -421,7 +403,7 @@ namespace nana
typedef typename std::remove_reference<arg_reference>::type arg_type;
static_assert(std::is_convertible<arg_type, Arg2>::value, "The parameter type is not allowed, please check the function parameter type where you connected the event function.");
static std::function<void(arg_reference)> build(Ret(*fn)(Arg))
static std::function<void(arg_reference)> build(Ret(*fn)(Arg2))
{
return[fn](arg_reference arg){
fn(arg);

View File

@@ -118,10 +118,6 @@ namespace detail
void do_lazy_refresh(core_window_t*, bool force_copy_to_screen, bool refresh_tree = false);
void map_requester(core_window_t*);
bool get_graphics(core_window_t*, nana::paint::graphics&);
bool get_visual_rectangle(core_window_t*, nana::rectangle&);
std::vector<core_window_t*> get_children(core_window_t*) const;
bool set_parent(core_window_t* wd, core_window_t* new_parent);
core_window_t* set_focus(core_window_t*, bool root_has_been_focused, arg_focus::reason);
@@ -144,7 +140,6 @@ namespace detail
bool register_shortkey(core_window_t*, unsigned long key);
void unregister_shortkey(core_window_t*, bool with_children);
std::vector<std::pair<core_window_t*, unsigned long>> shortkeys(core_window_t*, bool with_children);
core_window_t* find_shortkey(native_window_type, unsigned long key);
@@ -154,6 +149,7 @@ namespace detail
void _m_disengage(core_window_t*, core_window_t* for_new);
void _m_destroy(core_window_t*);
void _m_move_core(core_window_t*, const point& delta);
void _m_shortkeys(core_window_t*, bool with_chlidren, std::vector<std::pair<core_window_t*, unsigned long>>& keys) const;
core_window_t* _m_find(core_window_t*, const point&);
static bool _m_effective(core_window_t*, const point& root_pos);
private:

View File

@@ -230,7 +230,6 @@ namespace API
window root(native_window_type); ///< Retrieves the native window of a Nana.GUI window.
void fullscreen(window, bool);
bool enabled_double_click(window, bool);
void close_window(window);
void show_window(window, bool show); ///< Sets a window visible state.
@@ -239,6 +238,7 @@ namespace API
bool visible(window);
window get_parent_window(window);
window get_owner_window(window);
bool set_parent_window(window, window new_parent);
template<typename Widget=::nana::widget>
@@ -435,6 +435,7 @@ namespace API
/// Sets the window active state. If a window active state is false, the window will not obtain the focus when a mouse clicks on it wich will be obteined by take_if_has_active_false.
void take_active(window, bool has_active, window take_if_has_active_false);
/// Copies the graphics of a specified to a new graphics object.
bool window_graphics(window, nana::paint::graphics&);
bool root_graphics(window, nana::paint::graphics&);
bool get_visual_rectangle(window, nana::rectangle&);

View File

@@ -136,13 +136,11 @@ namespace nana{ namespace widgets
void enable_background(bool);
void enable_background_counterpart(bool);
void undo_enabled(bool);
bool undo_enabled() const;
void undo_clear();
void undo_max_steps(std::size_t);
std::size_t undo_max_steps() const;
renderers& customized_renderers();
void clear_undo(); ///< same with undo_max_steps(0)
unsigned line_height() const;
unsigned screen_lines(bool completed_line = false) const;
@@ -203,12 +201,11 @@ namespace nana{ namespace widgets
void del();
void backspace(bool record_undo, bool perform_event);
void undo(bool reverse);
void set_undo_queue_length(std::size_t len);
void move_ns(bool to_north); //Moves up and down
void move_left();
void move_right();
const upoint& mouse_caret(const point& screen_pos, bool stay_in_view);
const upoint& caret() const;
const upoint& caret() const noexcept;
point caret_screen_pos() const;
bool scroll(bool upwards, bool vertical);
@@ -218,8 +215,8 @@ namespace nana{ namespace widgets
void mouse_pressed(const arg_mouse& arg);
bool select_word(const arg_mouse& arg);
skeletons::textbase<char_type>& textbase();
const skeletons::textbase<char_type>& textbase() const;
skeletons::textbase<char_type>& textbase() noexcept;
const skeletons::textbase<char_type>& textbase() const noexcept;
bool try_refresh();