Skip to content

Commit

Permalink
New dock interface. (Not finished yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
blackwarthog committed Oct 15, 2013
1 parent 363ac27 commit 4645696
Show file tree
Hide file tree
Showing 9 changed files with 271 additions and 507 deletions.
18 changes: 8 additions & 10 deletions synfig-studio/src/gui/docks/dockable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ Dockable::Dockable(const synfig::String& name,const synfig::String& local_name,G
header_box_.pack_end(*bttn_close,false,false);
bttn_close->show();
bttn_close->set_relief(Gtk::RELIEF_NONE);
bttn_close->signal_clicked().connect(sigc::mem_fun(*this,&Dockable::detach));
bttn_close->signal_clicked().connect(
sigc::bind(sigc::ptr_fun(&DockManager::remove_widget_by_pointer_recursive), this));
bttn_close->set_border_width(0);
dynamic_cast<Gtk::Misc*>(bttn_close->get_child())->set_padding(0,0);
}
Expand Down Expand Up @@ -183,7 +184,7 @@ Dockable::on_drag_end(const Glib::RefPtr<Gdk::DragContext>&/*context*/)
{
if(!dnd_success_)
{
detach();
DockManager::remove_widget_recursive(*this);
present();
}
}
Expand Down Expand Up @@ -303,13 +304,6 @@ Dockable::add_button(const Gtk::StockID& stock_id, const synfig::String& tooltip
}


void
Dockable::detach()
{
if(parent_)
parent_->remove(*this);
}

void
Dockable::present()
{
Expand All @@ -320,8 +314,12 @@ Dockable::present()
}
else
{
show();
DockBook* book = manage(new DockBook());
book->show();
book->add(*this);
DockDialog* dock_dialog(new DockDialog());
dock_dialog->get_dock_book().add(*this);
dock_dialog->add(*book);
/* //hack: always display composition selector on top of canvas browser
if(get_name()=="canvases")
dock_dialog->set_composition_selector(true);
Expand Down
2 changes: 0 additions & 2 deletions synfig-studio/src/gui/docks/dockable.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ class Dockable : public Gtk::Table

Gtk::ToolButton* add_button(const Gtk::StockID& stock_id, const synfig::String& tooltip=synfig::String());

void detach();

void present();

void attach_dnd_to(Gtk::Widget& widget);
Expand Down
71 changes: 69 additions & 2 deletions synfig-studio/src/gui/docks/dockbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,34 @@ DockBook::DockBook()
//set_extension_events(Gdk::EXTENSION_EVENTS_ALL);
set_show_tabs(true);
deleting_=false;

Gtk::Button *button_left = manage(new Gtk::Button());
Gtk::Button *button_right = manage(new Gtk::Button());
Gtk::Button *button_top = manage(new Gtk::Button());
Gtk::Button *button_bottom = manage(new Gtk::Button());

button_left->drag_dest_set(listTargets);
button_right->drag_dest_set(listTargets);
button_top->drag_dest_set(listTargets);
button_bottom->drag_dest_set(listTargets);

button_left->signal_drag_data_received().connect(
sigc::mem_fun(*this,&DockBook::drop_on_left));
button_right->signal_drag_data_received().connect(
sigc::mem_fun(*this,&DockBook::drop_on_right));
button_top->signal_drag_data_received().connect(
sigc::mem_fun(*this,&DockBook::drop_on_top));
button_bottom->signal_drag_data_received().connect(
sigc::mem_fun(*this,&DockBook::drop_on_bottom));

Gtk::Table *table = manage(new Gtk::Table(3, 3, true));
table->attach(*button_left, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL);
table->attach(*button_right, 2, 3, 1, 2, Gtk::FILL, Gtk::FILL);
table->attach(*button_top, 1, 2, 0, 1, Gtk::FILL, Gtk::FILL);
table->attach(*button_bottom, 1, 2, 2, 3, Gtk::FILL, Gtk::FILL);
table->show_all();

set_action_widget(table, Gtk::PACK_END);
}

DockBook::~DockBook()
Expand All @@ -85,6 +113,45 @@ DockBook::clear()
remove(static_cast<Dockable&>(*get_nth_page(get_n_pages()-1)));
}

void
DockBook::drop_on(bool vertical, bool first, const Glib::RefPtr<Gdk::DragContext>& context, const Gtk::SelectionData& selection_data, guint time)
{
if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
{
Dockable& dockable(**reinterpret_cast<Dockable**>(const_cast<guint8*>(selection_data.get_data())));
if (DockManager::add_dockable(*this, dockable, vertical, first))
{
context->drag_finish(true, false, time);
return;
}
}
context->drag_finish(false, false, time);
}

void
DockBook::drop_on_left(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time)
{
drop_on(false, true, context, selection_data, time);
}

void
DockBook::drop_on_right(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time)
{
drop_on(false, false, context, selection_data, time);
}

void
DockBook::drop_on_top(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time)
{
drop_on(true, true, context, selection_data, time);
}

void
DockBook::drop_on_bottom(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time)
{
drop_on(true, false, context, selection_data, time);
}

void
DockBook::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time)
{
Expand All @@ -104,7 +171,7 @@ DockBook::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, i
void
DockBook::add(Dockable& dockable, int position)
{
dockable.detach();
DockManager::remove_widget_recursive(dockable);

if(position==-1)
append_page(dockable, " ");
Expand Down Expand Up @@ -243,7 +310,7 @@ DockBook::tab_button_pressed(GdkEventButton* event, Dockable* dockable)

tabmenu->items().push_back(
Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-close"),
sigc::mem_fun(*dockable,&Dockable::detach)
sigc::bind(sigc::ptr_fun(&DockManager::remove_widget_by_pointer_recursive), this)
)
);

Expand Down
6 changes: 6 additions & 0 deletions synfig-studio/src/gui/docks/dockbook.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ class DockBook : public Gtk::Notebook
bool deleting_;

protected:
void drop_on(bool vertical, bool first, const Glib::RefPtr<Gdk::DragContext>& context, const Gtk::SelectionData& selection_data, guint time);
void drop_on_left(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time);
void drop_on_right(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time);
void drop_on_top(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time);
void drop_on_bottom(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time);

public:
DockBook();
~DockBook();
Expand Down
Loading

0 comments on commit 4645696

Please sign in to comment.