Add a callback for the tree view node label.

Initial implementation, which is not finished yet, but off to the FOSDEM
now, will proceed there.
This commit is contained in:
Mark de Wever 2010-02-05 10:33:41 +00:00
parent 255973be38
commit 42487a44cd
2 changed files with 40 additions and 14 deletions

View file

@ -47,6 +47,7 @@ ttree_view::tnode::tnode(const std::string& id
, children_()
, node_definitions_(node_definitions)
, icon_(NULL)
, label_(NULL)
{
set_parent(parent_widget);
grid_.set_parent(this);
@ -74,24 +75,20 @@ ttree_view::tnode::tnode(const std::string& id
if(parent_ && parent_->icon_) {
parent_->icon_->set_visible(twidget::VISIBLE);
}
/*
twidget* w = find_widget<twidget>(
twidget& widget = find_widget<twidget>(
&grid_
, "tree_view_node_label"
, false
, false); {
assert(w);
w->connect_signal<event::LEFT_BUTTON_CLICK>(
boost::bind(&ttree_view::tnode::
signal_handler_left_button_click
, this, _2));
, false);
label_ = dynamic_cast<tselectable_*>(&widget);
if(label_) {
widget.connect_signal<event::LEFT_BUTTON_CLICK>(
boost::bind(&ttree_view::tnode::
signal_handler_label_left_button_click
, this, _2, _3, _4)
, event::tdispatcher::front_child);
}
*/
// init_grid(&grid_, data);
return;
}
@ -349,6 +346,26 @@ void ttree_view::tnode::signal_handler_left_button_click(
, parent_widget_->get_size());
}
void ttree_view::tnode::signal_handler_label_left_button_click(
const event::tevent event
, bool& handled
, bool& halt)
{
DBG_GUI_E << LOG_NODE_HEADER << ' ' << event << ".\n";
assert(label_);
if(label_->get_value()) {
// Forbid deselecting
halt = handled = true;
} else {
// Deselect current item
//
// TODO implement
}
}
void ttree_view::tnode::init_grid(tgrid* grid
, const std::map<std::string /* widget id */, string_map>& data)
{

View file

@ -23,6 +23,7 @@
namespace gui2 {
class tselectable_;
class ttoggle_button;
class ttree_view
@ -128,6 +129,8 @@ public:
ttoggle_button* icon_;
tselectable_* label_;
/**
* "Inherited" from twidget.
*
@ -156,8 +159,14 @@ public:
void impl_draw_children(surface& frame_buffer);
// FIXME rename to icon
void signal_handler_left_button_click(const event::tevent event);
void signal_handler_label_left_button_click(
const event::tevent event
, bool& handled
, bool& halt);
void init_grid(tgrid* grid
, const std::map<
std::string /* widget id */, string_map>& data);