some improvements

improved resizing performance
removed frame widget
refactoring
This commit is contained in:
Jinhao
2019-02-16 00:55:02 +08:00
parent bbc39906c0
commit e89ee5d18b
25 changed files with 307 additions and 521 deletions

View File

@@ -1,7 +1,7 @@
/**
* Nana Configuration
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -25,10 +25,6 @@
#include "c++defines.hpp"
//This marco is defined since 1.4 and until 1.5 for deprecating frame widget.
//This marco and class frame will be removed in version 1.5
#define WIDGET_FRAME_DEPRECATED
//The following basic configurations are ignored when NANA_IGNORE_CONF is defined.
//The NANA_IGNORE_CONF may be specified by CMake generated makefile.
#ifndef NANA_IGNORE_CONF

View File

@@ -4,7 +4,7 @@
*
* Basis Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -80,17 +80,11 @@ namespace nana
widget = 0x1,
lite_widget = 0x3,
root = 0x5
#ifndef WIDGET_FRAME_DEPRECATED
,frame = 0x9
#endif
};
//wait for constexpr
struct widget_tag{ static const flags value = flags::widget; };
struct lite_widget_tag : public widget_tag{ static const flags value = flags::lite_widget; };
struct root_tag : public widget_tag{ static const flags value = flags::root; };
#ifndef WIDGET_FRAME_DEPRECATED
struct frame_tag : public widget_tag{ static const flags value = flags::frame; };
#endif
}// end namespace category
using native_window_type = detail::native_window_handle_impl*;

View File

@@ -1,7 +1,7 @@
/**
* A Basic Window Widget Definition
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -116,10 +116,6 @@ namespace detail
/// bind a native window and baisc_window
void bind_native_window(native_window_type, unsigned width, unsigned height, unsigned extra_width, unsigned extra_height, paint::graphics&);
#ifndef WIDGET_FRAME_DEPRECATED
void frame_window(native_window_type);
#endif
bool is_ancestor_of(const basic_window* wd) const;
bool visible_parents() const;
bool displayed() const;
@@ -180,7 +176,8 @@ namespace detail
bool ignore_mouse_focus : 1; ///< A flag indicates whether the widget accepts focus when clicking on it
bool space_click_enabled : 1; ///< A flag indicates whether enable mouse_down/click/mouse_up when pressing and releasing whitespace key.
bool draggable : 1;
unsigned Reserved :17;
bool ignore_child_mapping : 1;
unsigned Reserved :16;
unsigned char tab; ///< indicate a window that can receive the keyboard TAB
mouse_action action;
mouse_action action_before;
@@ -206,19 +203,8 @@ namespace detail
struct other_tag
{
#ifndef WIDGET_FRAME_DEPRECATED
struct attr_frame_tag
{
native_window_type container{nullptr};
std::vector<native_window_type> attach;
};
#endif
struct attr_root_tag
{
#ifndef WIDGET_FRAME_DEPRECATED
container frames; ///< initialization is null, it will be created while creating a frame widget. Refer to WindowManager::create_frame
#endif
container tabstop;
std::vector<edge_nimbus_action> effects_edge_nimbus;
basic_window* focus{nullptr};
@@ -237,12 +223,11 @@ namespace detail
update_state upd_state;
dragdrop_status dnd_state{ dragdrop_status::not_ready };
container mapping_requester; ///< Children which are ignored to mapping
union
{
attr_root_tag * root;
#ifndef WIDGET_FRAME_DEPRECATED
attr_frame_tag * frame;
#endif
}attribute;
other_tag(category::flags);

View File

@@ -1,38 +0,0 @@
#ifndef NANA_DETAIL_BEDROCK_PI_DATA_HPP
#define NANA_DETAIL_BEDROCK_PI_DATA_HPP
#include <nana/push_ignore_diagnostic>
#include <nana/gui/detail/bedrock.hpp>
#include "color_schemes.hpp"
#include "events_operation.hpp"
#include "window_manager.hpp"
#include <set>
namespace nana
{
namespace detail
{
struct bedrock::pi_data
{
color_schemes scheme;
events_operation evt_operation;
window_manager wd_manager;
std::set<core_window_t*> auto_form_set;
bool shortkey_occurred{ false };
struct menu_rep
{
core_window_t* taken_window{ nullptr };
bool delay_restore{ false };
native_window_type window{ nullptr };
native_window_type owner{ nullptr };
bool has_keyboard{ false };
}menu;
};
}
}
#include <nana/pop_ignore_diagnostic>
#endif

View File

@@ -1,7 +1,7 @@
/**
* Window Manager Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -83,12 +83,6 @@ namespace detail
core_window_t* create_root(core_window_t*, bool nested, rectangle, const appearance&, widget*);
core_window_t* create_widget(core_window_t*, const rectangle&, bool is_lite, widget*);
#ifndef WIDGET_FRAME_DEPRECATED
core_window_t* create_frame(core_window_t*, const rectangle&, widget*);
bool insert_frame(core_window_t* frame, native_window);
bool insert_frame(core_window_t* frame, core_window_t*);
#endif
void close(core_window_t*);
//destroy
@@ -122,6 +116,7 @@ namespace detail
void refresh_tree(core_window_t*);
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&);

View File

@@ -1,7 +1,7 @@
/*
* Nana GUI Programming Interface Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -95,9 +95,7 @@ namespace API
window create_window(window, bool nested, const rectangle&, const appearance&, widget* attached);
window create_widget(window, const rectangle&, widget* attached);
window create_lite_widget(window, const rectangle&, widget* attached);
#ifndef WIDGET_FRAME_DEPRECATED
window create_frame(window, const rectangle&, widget* attached);
#endif
paint::graphics* window_graphics(window);
void delay_restore(bool);
@@ -234,11 +232,6 @@ namespace API
void fullscreen(window, bool);
bool enabled_double_click(window, bool);
#ifndef WIDGET_FRAME_DEPRECATED
bool insert_frame(window frame, native_window_type);
native_window_type frame_container(window frame);
native_window_type frame_element(window frame, unsigned index);
#endif
void close_window(window);
void show_window(window, bool show); ///< Sets a window visible state.
void restore_window(window);

View File

@@ -1,56 +0,0 @@
/**
* A Frame Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* @file: nana/gui/widgets/frame.hpp
*
* @brief A frame provides a way to contain the platform window in a stdex GUI Window
*/
#ifndef NANA_GUI_WIDGET_FRAME_HPP
#define NANA_GUI_WIDGET_FRAME_HPP
#include "widget.hpp"
#ifndef WIDGET_FRAME_DEPRECATED
namespace nana
{
/**
\brief Container for system native windows. Provides an approach to
display a control that is not written with Nana.GUI in a Nana.GUI window.
Notes:
1. nana::native_window_type is a type of system handle of windows.
2. all the children windows of a nana::frame is topmost to Nana.GUI windows.
3. a simple example. Displaying a Windows Edit Control.
nana::frame frame(parent, 0, 0 200, 100);
HWND frame_handle = reinterpret_cast<HWND>(frame.container());
HWND edit = ::CreateWindowExW(WS_EX_CLIENTEDGE, L"EDIT", L"Test",
WS_CHILD | WS_VISIBLE | WS_BORDER, 0, 0, 200, 100,
frame_handle, 0, ::GetModuleHandle(0), 0);
if(edit)
frame.insert(edit);
*/
class frame: public widget_object<category::frame_tag, int, nana::general_events>
{
typedef widget_object<category::frame_tag, int> base_type;
public:
frame();
frame(window, bool visible);
frame(window, const rectangle& = rectangle(), bool visible = true);
bool insert(native_window_type); ///< Inserts a platform native window.
native_window_type element(unsigned index); ///< Returns the child window through index.
native_window_type container() const; ///< Returns the frame container native window handle.
};
}//end namespace nana
#endif
#endif

View File

@@ -1,7 +1,7 @@
/**
* The fundamental widget class implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -499,72 +499,6 @@ namespace nana
std::unique_ptr<scheme_type> scheme_;
};//end class widget_object<root_tag>
#ifndef WIDGET_FRAME_DEPRECATED
/// Base class of all the classes defined as a frame window. \see nana::frame
template<typename Drawer, typename Events, typename Scheme>
class widget_object<category::frame_tag, Drawer, Events, Scheme>: public widget{};
/// Especialization. Base class of all the classes defined as a frame window. \see nana::frame
template<typename Events, typename Scheme>
class widget_object<category::frame_tag, int, Events, Scheme>: public detail::widget_base
{
protected:
typedef int drawer_trigger_t;
public:
using scheme_type = Scheme;
using event_type = Events;
widget_object()
: events_{ std::make_shared<Events>() }, scheme_{ API::dev::make_scheme<scheme_type>() }
{}
~widget_object()
{
API::close_window(handle());
}
event_type& events() const
{
return *events_;
}
bool create(window parent_wd, bool visible) ///< Creates a no-size (zero-size) widget. in a widget/root window specified by parent_wd.
{
return create(parent_wd, rectangle(), visible);
}
/// Creates in a widget/root window specified by parent_wd.
bool create(window parent_wd, const rectangle& r = rectangle(), bool visible = true)
{
if(parent_wd && this->empty())
{
handle_ = API::dev::create_frame(parent_wd, r, this);
API::dev::set_events(handle_, events_);
API::dev::set_scheme(handle_, scheme_.get());
API::show_window(handle_, visible);
this->_m_complete_creation();
}
return (this->empty() == false);
}
scheme_type& scheme() const
{
return *scheme_;
}
private:
virtual drawer_trigger* get_drawer_trigger()
{
return nullptr;
}
general_events& _m_get_general_events() const override
{
return *events_;
}
private:
std::shared_ptr<Events> events_;
std::unique_ptr<scheme_type> scheme_;
};//end class widget_object<category::frame_tag>
#endif
}//end namespace nana
#include <nana/pop_ignore_diagnostic>