Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
cnjinhao committed Aug 27, 2015
2 parents 75bd84f + 5c6c0dd commit faa7404
Show file tree
Hide file tree
Showing 13 changed files with 515 additions and 49 deletions.
2 changes: 1 addition & 1 deletion include/nana/gui/detail/drawer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <vector>
#include "general_events.hpp"
#include <nana/paint/graphics.hpp>
#include <nana/paint/image.hpp>
//#include <nana/paint/image.hpp> //deprecated
#include <functional>

namespace nana
Expand Down
8 changes: 4 additions & 4 deletions include/nana/gui/widgets/listbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ namespace nana
public:
trigger();
~trigger();
essence_t& essence();
//essence_t& essence(); //deprecated
essence_t& essence() const;
void draw();
private:
Expand Down Expand Up @@ -618,15 +618,15 @@ By \a clicking on one header the list get \a reordered, first up, and then down
{
typedef typename nana::detail::type_escape<Key>::type key_t;
nana::key<key_t, std::less<key_t> > key(kv);
_m_ease_key(&key);
_m_erase_key(&key);
}

template<typename Key>
void erase_key(Key&& kv)
{
typedef typename nana::detail::type_escape<Key>::type key_t;
nana::key<key_t, std::less<key_t> > key(std::move(kv));
_m_ease_key(&key);
_m_erase_key(&key);
}

bool sortable() const;
Expand Down Expand Up @@ -661,7 +661,7 @@ By \a clicking on one header the list get \a reordered, first up, and then down
drawerbase::listbox::essence_t & _m_ess() const;
nana::any* _m_anyobj(size_type cat, size_type index, bool allocate_if_empty) const;
drawerbase::listbox::category_t* _m_at_key(std::shared_ptr<nana::detail::key_interface>);
void _m_ease_key(nana::detail::key_interface*);
void _m_erase_key(nana::detail::key_interface*);
};

namespace dev
Expand Down
47 changes: 47 additions & 0 deletions include/nana/gui/widgets/tabbar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,51 @@ namespace nana
std::unique_ptr<drawerbase::tabbar::event_agent<value_type, drawerbase::tabbar::trigger> > evt_agent_;
};
}//end namespace nana


namespace nana
{
namespace ng
{
namespace drawerbase
{
namespace tabbar_lite
{
class model;

class driver
: public drawer_trigger
{
public:
driver();
~driver();

model* get_model();
private:
//Overrides drawer_trigger's method
void attached(widget_reference, graph_reference) override;
void refresh(graph_reference) override;
void mouse_move(graph_reference, const arg_mouse&) override;
void mouse_leave(graph_reference, const arg_mouse&) override;
void mouse_down(graph_reference, const arg_mouse&) override;
private:
model* const model_;
};
}
}//end namespace drawerbase

class tabbar_lite
: public widget_object<category::widget_tag, drawerbase::tabbar_lite::driver>
{
public:
tabbar_lite() = default;
tabbar_lite(window, bool visible = true, const::nana::rectangle& = {});


void push_back(std::string text, ::nana::any par = {});
void push_front(std::string text, ::nana::any par = {});
};
}
}

#endif
2 changes: 1 addition & 1 deletion include/nana/gui/widgets/widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace nana
: nana::noncopyable, nana::nonmovable
{
friend class detail::widget_notifier_interface;
class notifier;
class inner_widget_notifier;
typedef void(*dummy_bool_type)(widget* (*)(const widget&));
public:
virtual ~widget() = default;
Expand Down
4 changes: 3 additions & 1 deletion include/nana/paint/graphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ namespace nana
::nana::size glyph_extent_size(const char_t*, std::size_t length, std::size_t begin, std::size_t end) const;
::nana::size glyph_extent_size(const string&, std::size_t length, std::size_t begin, std::size_t end) const;
bool glyph_pixels(const char_t *, std::size_t length, unsigned* pxbuf) const;
::nana::size bidi_extent_size(const string&) const;
::nana::size bidi_extent_size(const std::wstring&) const;
::nana::size bidi_extent_size(const std::string&) const;

bool text_metrics(unsigned & ascent, unsigned& descent, unsigned& internal_leading) const;

Expand Down Expand Up @@ -139,6 +140,7 @@ namespace nana
void set_text_color(const ::nana::color&);

unsigned bidi_string(const nana::point&, const char_t *, std::size_t len);
unsigned bidi_string(const point& pos, const char*, std::size_t len);

void blend(const ::nana::rectangle& r, const ::nana::color&, double fade_rate);

Expand Down
53 changes: 42 additions & 11 deletions source/gui/detail/bedrock_pi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ namespace nana
auto retain = wd->together.events_ptr;
auto evts_ptr = retain.get();

//enable refreshing flag, this is a RAII class for exception-safe
flag_guard fguard(this, wd);

switch (evt_code)
{
Expand All @@ -199,8 +197,11 @@ namespace nana
auto arg = dynamic_cast<const arg_click*>(&event_arg);
if (nullptr == arg)
return;

wd->drawer.click(*arg);
{
//enable refreshing flag, this is a RAII class for exception-safe
flag_guard fguard(this, wd);
wd->drawer.click(*arg);
}
if (!draw_only)
evts_ptr->click.emit(*arg);
}
Expand Down Expand Up @@ -249,7 +250,11 @@ namespace nana
throw std::runtime_error("Invalid mouse event code");
}

(wd->drawer.*drawer_event_fn)(*arg);
{
//enable refreshing flag, this is a RAII class for exception-safe
flag_guard fguard(this, wd);
(wd->drawer.*drawer_event_fn)(*arg);
}

if (!draw_only)
evt_addr->emit(*arg);
Expand All @@ -260,7 +265,12 @@ namespace nana
auto arg = dynamic_cast<const arg_wheel*>(&event_arg);
if (arg)
{
wd->drawer.mouse_wheel(*arg);
{
//enable refreshing flag, this is a RAII class for exception-safe
flag_guard fguard(this, wd);
wd->drawer.mouse_wheel(*arg);
}

if (!draw_only)
evts_ptr->mouse_wheel.emit(*arg);
}
Expand Down Expand Up @@ -299,7 +309,12 @@ namespace nana
default:
throw std::runtime_error("Invalid keyboard event code");
}
(wd->drawer.*drawer_event_fn)(*arg);
{
//enable refreshing flag, this is a RAII class for exception-safe
flag_guard fguard(this, wd);
(wd->drawer.*drawer_event_fn)(*arg);
}

if (!draw_only)
evt_addr->emit(*arg);
break;
Expand All @@ -317,7 +332,11 @@ namespace nana
auto arg = dynamic_cast<const arg_focus*>(&event_arg);
if (arg)
{
wd->drawer.focus(*arg);
{
//enable refreshing flag, this is a RAII class for exception-safe
flag_guard fguard(this, wd);
wd->drawer.focus(*arg);
}
if (!draw_only)
evts_ptr->focus.emit(*arg);
}
Expand All @@ -328,7 +347,11 @@ namespace nana
auto arg = dynamic_cast<const arg_move*>(&event_arg);
if (arg)
{
wd->drawer.move(*arg);
{
//enable refreshing flag, this is a RAII class for exception-safe
flag_guard fguard(this, wd);
wd->drawer.move(*arg);
}
if (!draw_only)
evts_ptr->move.emit(*arg);
}
Expand All @@ -339,7 +362,11 @@ namespace nana
auto arg = dynamic_cast<const arg_resizing*>(&event_arg);
if (arg)
{
wd->drawer.resizing(*arg);
{
//enable refreshing flag, this is a RAII class for exception-safe
flag_guard fguard(this, wd);
wd->drawer.resizing(*arg);
}
if (!draw_only)
evts_ptr->resizing.emit(*arg);
}
Expand All @@ -350,7 +377,11 @@ namespace nana
auto arg = dynamic_cast<const arg_resized*>(&event_arg);
if (arg)
{
wd->drawer.resized(*arg);
{
//enable refreshing flag, this is a RAII class for exception-safe
flag_guard fguard(this, wd);
wd->drawer.resized(*arg);
}
if (!draw_only)
evts_ptr->resized.emit(*arg);
}
Expand Down
19 changes: 12 additions & 7 deletions source/gui/detail/window_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ namespace detail
std::lock_guard<decltype(mutex_)> lock(mutex_);
if (impl_->wd_register.available(wd) == false) return;

if (wd->flags.destroying)
return;

if(wd->other.category == category::root_tag::value)
{
auto &brock = bedrock::instance();
Expand All @@ -340,13 +343,15 @@ namespace detail
if(wd->flags.modal || (wd->owner == nullptr) || wd->owner->flags.take_active)
native_interface::activate_owner(wd->root);

//Close should detach the drawer and send destroy signal to widget object.
//Otherwise, when a widget object is been deleting in other thread by delete operator, the object will be destroyed
//before the window_manager destroyes the window, and then, window_manager detaches the
//non-existing drawer_trigger which is destroyed by destruction of widget. Crash!
wd->drawer.detached();

wd->widget_notifier->destroy();
if (!wd->flags.destroying)
{
//Close should detach the drawer and send destroy signal to widget object.
//Otherwise, when a widget object is been deleting in other thread by delete operator, the object will be destroyed
//before the window_manager destroyes the window, and then, window_manager detaches the
//non-existing drawer_trigger which is destroyed by destruction of widget. Crash!
wd->drawer.detached();
wd->widget_notifier->destroy();
}

native_interface::close_window(wd->root);
}
Expand Down
Loading

0 comments on commit faa7404

Please sign in to comment.