mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 00:34:59 +01:00
initial commit of hand merging, plus getting "ancient" waf script to work correctly
This commit is contained in:
parent
1d8bac08c0
commit
aaea166135
244 changed files with 131902 additions and 7357 deletions
68
libs/canvas/test/gtk_drag.cc
Normal file
68
libs/canvas/test/gtk_drag.cc
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#include <iostream>
|
||||
#include <gtkmm.h>
|
||||
#include "canvas/canvas.h"
|
||||
#include "canvas/rectangle.h"
|
||||
#include "canvas/pixbuf.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ArdourCanvas;
|
||||
|
||||
Rectangle* rectangle = 0;
|
||||
|
||||
bool
|
||||
event (GdkEvent* ev)
|
||||
{
|
||||
static bool dragging = false;
|
||||
static Duple offset;
|
||||
|
||||
if (ev->type == GDK_BUTTON_PRESS) {
|
||||
GdkEventButton* b = reinterpret_cast<GdkEventButton*> (ev);
|
||||
if (b->button == 1) {
|
||||
dragging = true;
|
||||
offset = Duple (b->x, b->y) - rectangle->position ();
|
||||
rectangle->grab ();
|
||||
cout << "Dragging offset=" << offset << "\n";
|
||||
}
|
||||
} else if (ev->type == GDK_BUTTON_RELEASE) {
|
||||
GdkEventButton* b = reinterpret_cast<GdkEventButton*> (ev);
|
||||
cout << "Release.\n";
|
||||
if (b->button == 1) {
|
||||
dragging = false;
|
||||
rectangle->ungrab ();
|
||||
cout << "Drag complete.\n";
|
||||
}
|
||||
} else if (ev->type == GDK_MOTION_NOTIFY) {
|
||||
GdkEventMotion* m = reinterpret_cast<GdkEventMotion*> (ev);
|
||||
if (dragging) {
|
||||
rectangle->set_position (Duple (m->x, m->y) - offset);
|
||||
cout << "Move to " << (Duple (m->x, m->y) - offset) << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
Gtk::Main kit (argc, argv);
|
||||
|
||||
Gtk::Window window;
|
||||
window.set_title ("Hello world");
|
||||
window.set_size_request (768, 768);
|
||||
|
||||
Gtk::Adjustment hadj (0, 0, 1e3);
|
||||
Gtk::Adjustment vadj (0, 0, 1e3);
|
||||
GtkCanvasViewport viewport (hadj, vadj);
|
||||
GtkCanvas* canvas = viewport.canvas ();
|
||||
|
||||
rectangle = new Rectangle (canvas->root(), Rect (64, 64, 128, 128));
|
||||
rectangle->set_outline_color (0xff0000aa);
|
||||
rectangle->Event.connect (sigc::ptr_fun (event));
|
||||
|
||||
window.add (viewport);
|
||||
canvas->show ();
|
||||
window.show_all ();
|
||||
|
||||
Gtk::Main::run (window);
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue