X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/3e385dbab78eb0336e82855d829a76a111514a38..a02bffd9a0cca7a49b5bc2c87a3b0293b91aba8b:/tests/GUI/dndwindow.cc?ds=sidebyside diff --git a/tests/GUI/dndwindow.cc b/tests/GUI/dndwindow.cc index e365208..daa5939 100644 --- a/tests/GUI/dndwindow.cc +++ b/tests/GUI/dndwindow.cc @@ -19,6 +19,8 @@ #include "dndwindow.h" #include <iostream> +Glib::RefPtr<Gdk::Pixbuf> ico_canio, ico_y, ico_codo; + DnDWindow::DnDWindow() : m_Button_Canio("Drag Canio\n"), m_Button_Y("Drop Y\n"), @@ -26,6 +28,10 @@ DnDWindow::DnDWindow() { set_title("Editor"); + ico_canio = Gdk::Pixbuf::create_from_file("canio.png"); + ico_y = Gdk::Pixbuf::create_from_file("y.png"); + ico_codo = Gdk::Pixbuf::create_from_file("codo.png"); + add(m_HBox); m_HBox.pack_start(m_VBox); @@ -80,6 +86,23 @@ void DnDWindow::on_item_button_down() std::cout << "boton abajo" << std::endl; } +void DnDWindow::on_canio_drag_begin(const Glib::RefPtr<Gdk::DragContext> &context) +{ + context->set_icon(ico_canio, 0, 0); //ico_canio->get_width(), ico_canio->get_height()); +} + +void DnDWindow::on_y_drag_begin(const Glib::RefPtr<Gdk::DragContext> &context) +{ + context->set_icon(ico_y, 0, 0); //ico_canio->get_width(), ico_canio->get_height()); +} + +void DnDWindow::on_codo_drag_begin(const Glib::RefPtr<Gdk::DragContext> &context) +{ + context->set_icon(ico_codo, 0, 0); //ico_canio->get_width(), ico_canio->get_height()); +} + + + void DnDWindow::on_canio_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint, guint) { @@ -117,8 +140,10 @@ void DnDWindow::on_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragCon /* Ajusto coordenada x e y para que caigan en un lugar de una cuadricula de * 32x32 */ int i,j; - i = x/32; - j = y/32; + // el +1 es para evitar un bug cuando se selecciona muy cerce de la + // separacion de 2 cuadritos + i = (x+1)/32; + j = (y+1)/32; m_WorkPlace.put(*a, i*32, j*32); a->show(); //listaItems.push_back(a); @@ -127,24 +152,3 @@ void DnDWindow::on_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragCon context->drag_finish(false, false, time); } -void DnDWindow::on_canio_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context) -{ - Glib::RefPtr<Gdk::Pixbuf> image; - image = Gdk::Pixbuf::create_from_file("canio.png"); - context->set_icon(image, image->get_width() / 2, image->get_height() / 4); -} - -void DnDWindow::on_y_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context) -{ - Glib::RefPtr<Gdk::Pixbuf> image; - image = Gdk::Pixbuf::create_from_file("y.png"); - context->set_icon(image, image->get_width() / 4, image->get_height() / 4); -} - -void DnDWindow::on_codo_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context) -{ - Glib::RefPtr<Gdk::Pixbuf> image; - image = Gdk::Pixbuf::create_from_file("codo.png"); - context->set_icon(image, 0, 0);//image->get_width() / 2, image->get_height() / 2); -} -