From: Good Guy Date: Thu, 9 Apr 2020 01:17:36 +0000 (-0600) Subject: dragcheckbox rework, boxblur create can grab X-Git-Tag: 2020-04~20 X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=c8ada3e79b5bf9b8282bdcc8fe858f24c6ac0715;p=goodguy%2Fcinelerra.git dragcheckbox rework, boxblur create can grab --- diff --git a/cinelerra-5.1/cinelerra/dragcheckbox.C b/cinelerra-5.1/cinelerra/dragcheckbox.C index c2e1f5d4..8f699bdb 100644 --- a/cinelerra-5.1/cinelerra/dragcheckbox.C +++ b/cinelerra-5.1/cinelerra/dragcheckbox.C @@ -84,6 +84,14 @@ void DragCheckBox::drag_deactivate() dragging = 0; } +int DragCheckBox::handle_ungrab() +{ + drag_deactivate(); + update(*value = 0); + update_gui(); + return 1; +} + int DragCheckBox::check_pending() { if( pending && !grab_event_count() ) { diff --git a/cinelerra-5.1/cinelerra/dragcheckbox.h b/cinelerra-5.1/cinelerra/dragcheckbox.h index f11fca5d..d14da97c 100644 --- a/cinelerra-5.1/cinelerra/dragcheckbox.h +++ b/cinelerra-5.1/cinelerra/dragcheckbox.h @@ -26,6 +26,7 @@ public: int handle_event(); int grab_event(XEvent *event); + int handle_ungrab(); MWindow *mwindow; int grabbed, dragging, pending; diff --git a/cinelerra-5.1/cinelerra/trackcanvas.C b/cinelerra-5.1/cinelerra/trackcanvas.C index 96726f68..fc31969d 100644 --- a/cinelerra-5.1/cinelerra/trackcanvas.C +++ b/cinelerra-5.1/cinelerra/trackcanvas.C @@ -2785,9 +2785,9 @@ static int is_linear(FloatAuto *prev, FloatAuto *next) { if( !prev || !next ) return 1; if( prev->curve_mode == FloatAuto::LINEAR ) return 1; - int64_t ipos, opos; - if( !(ipos = prev->get_control_in_position()) && - !(opos = prev->get_control_out_position()) ) return 1; + int64_t ipos = prev->get_control_in_position(); + int64_t opos = prev->get_control_out_position(); + if( !ipos && !opos ) return 1; if( !ipos || !opos ) return 0; float ival = prev->get_control_in_value(); float oval = prev->get_control_out_value(); @@ -3716,43 +3716,6 @@ int TrackCanvas::draw_hairline(Auto *auto_keyframe, int color, int show) return 0; } -void TrackCanvas::draw_bline(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap) -{ -// Short lines are all overhead to hw or sw setup, use bresenhams - if( y1 > y2 ) { - int tx = x1; x1 = x2; x2 = tx; - int ty = y1; y1 = y2; y2 = ty; - } - - int x = x1, y = y1; - int dx = x2-x1, dy = y2-y1; - int dx2 = 2*dx, dy2 = 2*dy; - if( dx < 0 ) dx = -dx; - int r = dx > dy ? dx : dy, n = r; - int dir = 0; - if( dx2 < 0 ) dir += 1; - if( dy >= dx ) { - if( dx2 >= 0 ) do { /* +Y, +X */ - draw_pixel(x, y++, pixmap); - if( (r -= dx2) < 0 ) { r += dy2; ++x; } - } while( --n >= 0 ); - else do { /* +Y, -X */ - draw_pixel(x, y++, pixmap); - if( (r += dx2) < 0 ) { r += dy2; --x; } - } while( --n >= 0 ); - } - else { - if( dx2 >= 0 ) do { /* +X, +Y */ - draw_pixel(x++, y, pixmap); - if( (r -= dy2) < 0 ) { r += dx2; ++y; } - } while( --n >= 0 ); - else do { /* -X, +Y */ - draw_pixel(x--, y, pixmap); - if( (r -= dy2) < 0 ) { r -= dx2; ++y; } - } while( --n >= 0 ); - } -} - void TrackCanvas::draw_overlays() { int new_cursor, update_cursor, rerender; diff --git a/cinelerra-5.1/cinelerra/trackcanvas.h b/cinelerra-5.1/cinelerra/trackcanvas.h index 490b67b1..4b9c4eba 100644 --- a/cinelerra-5.1/cinelerra/trackcanvas.h +++ b/cinelerra-5.1/cinelerra/trackcanvas.h @@ -71,7 +71,6 @@ public: void draw_highlighting(); void draw_keyframe_reticle(); int draw_hairline(Auto *auto_keyframe, int color, int show); - void draw_bline(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap=0); // User can either call draw or draw_overlays to copy a fresh // canvas and just draw the overlays over it diff --git a/cinelerra-5.1/guicast/bcwindowbase.C b/cinelerra-5.1/guicast/bcwindowbase.C index a2cccd2c..137b6790 100644 --- a/cinelerra-5.1/guicast/bcwindowbase.C +++ b/cinelerra-5.1/guicast/bcwindowbase.C @@ -3415,14 +3415,25 @@ void BC_WindowBase::close(int return_value) int BC_WindowBase::grab(BC_WindowBase *window) { - if( window->active_grab && this != window->active_grab ) return 0; - window->active_grab = this; - this->grab_active = window; - return 1; + int ret = 1; + if( window->active_grab ) { + int locked = get_window_lock(); + if( locked ) unlock_window(); + BC_WindowBase *active_grab = window->active_grab; + active_grab->lock_window("BC_WindowBase::grab(BC_WindowBase"); + ret = active_grab->handle_ungrab(); + active_grab->unlock_window(); + if( locked ) lock_window("BC_WindowBase::grab(BC_WindowBase"); + } + if( ret ) { + window->active_grab = this; + this->grab_active = window; + } + return ret; } int BC_WindowBase::ungrab(BC_WindowBase *window) { - if( window->active_grab && this != window->active_grab ) return 0; + if( this != window->active_grab ) return 0; window->active_grab = 0; this->grab_active = 0; return 1; diff --git a/cinelerra-5.1/guicast/bcwindowbase.h b/cinelerra-5.1/guicast/bcwindowbase.h index 6ce2128d..d02a357e 100644 --- a/cinelerra-5.1/guicast/bcwindowbase.h +++ b/cinelerra-5.1/guicast/bcwindowbase.h @@ -216,7 +216,9 @@ public: virtual int selection_clear_event() { return 0; } // Only if opengl is enabled virtual int expose_event() { return 0; }; + virtual int handle_ungrab() { return 0; }; virtual int grab_event(XEvent *event) { return 0; }; + virtual void create_objects() { return; }; static void init_resources(float scale); @@ -426,7 +428,9 @@ public: int draw_single_text(int draw, int font, int x, int y, const wchr_t *text, int length = -1, BC_Pixmap *pixmap = 0); void draw_center_text(int x, int y, const char *text, int length = -1); + void draw_pix(int x, int y, BC_Pixmap *pixmap = 0); void draw_line(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap = 0); + void draw_bline(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap = 0); void draw_polygon(ArrayList *x, ArrayList *y, BC_Pixmap *pixmap = 0); void fill_polygon(ArrayList *x, ArrayList *y, BC_Pixmap *pixmap = 0); void draw_rectangle(int x, int y, int w, int h); diff --git a/cinelerra-5.1/guicast/bcwindowdraw.C b/cinelerra-5.1/guicast/bcwindowdraw.C index eb35b63e..73b3d034 100644 --- a/cinelerra-5.1/guicast/bcwindowdraw.C +++ b/cinelerra-5.1/guicast/bcwindowdraw.C @@ -388,11 +388,18 @@ void BC_WindowBase::draw_center_text(int x, int y, const char *text, int length) draw_text(x, y, text, length); } +void BC_WindowBase::draw_pix(int x, int y, BC_Pixmap *pixmap) +{ // draw_pixel, no BT test + XDrawPoint(top_level->display, + pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap, + top_level->gc, x, y); +} + void BC_WindowBase::draw_line(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap) { BT // Some X drivers can't draw 0 length lines if( x1 == x2 && y1 == y2 ) { - draw_pixel(x1, y1, pixmap); + draw_pix(x1, y1, pixmap); } else { XDrawLine(top_level->display, @@ -401,6 +408,43 @@ void BC_WindowBase::draw_line(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap) } } +void BC_WindowBase::draw_bline(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap) +{ BT +// Short lines are all overhead to hw or sw setup, use bresenhams + if( y1 > y2 ) { + int tx = x1; x1 = x2; x2 = tx; + int ty = y1; y1 = y2; y2 = ty; + } + + int x = x1, y = y1; + int dx = x2-x1, dy = y2-y1; + int dx2 = 2*dx, dy2 = 2*dy; + if( dx < 0 ) dx = -dx; + int r = dx > dy ? dx : dy, n = r; + int dir = 0; + if( dx2 < 0 ) dir += 1; + if( dy >= dx ) { + if( dx2 >= 0 ) do { /* +Y, +X */ + draw_pix(x, y++, pixmap); + if( (r -= dx2) < 0 ) { r += dy2; ++x; } + } while( --n >= 0 ); + else do { /* +Y, -X */ + draw_pix(x, y++, pixmap); + if( (r += dx2) < 0 ) { r += dy2; --x; } + } while( --n >= 0 ); + } + else { + if( dx2 >= 0 ) do { /* +X, +Y */ + draw_pix(x++, y, pixmap); + if( (r -= dy2) < 0 ) { r += dx2; ++y; } + } while( --n >= 0 ); + else do { /* -X, +Y */ + draw_pix(x--, y, pixmap); + if( (r -= dy2) < 0 ) { r -= dx2; ++y; } + } while( --n >= 0 ); + } +} + void BC_WindowBase::draw_polygon(ArrayList *x, ArrayList *y, BC_Pixmap *pixmap) { BT int npoints = MIN(x->total, y->total); diff --git a/cinelerra-5.1/plugins/boxblur/boxblur.C b/cinelerra-5.1/plugins/boxblur/boxblur.C index 6848798b..50da0599 100644 --- a/cinelerra-5.1/plugins/boxblur/boxblur.C +++ b/cinelerra-5.1/plugins/boxblur/boxblur.C @@ -279,6 +279,8 @@ void BoxBlurWindow::create_objects() add_subwindow(title = new BC_Title(x, y, _("Box Blur"), MEDIUMFONT_3D)); add_subwindow(drag = new BoxBlurDrag(this, plugin, t3, y)); drag->create_objects(); + if( plugin->config.drag && drag->drag_activate() ) + eprintf("drag enabled, but compositor already grabbed\n"); int x1 = get_w() - BoxBlurReset::calculate_w(this) - 2*margin; add_subwindow(reset = new BoxBlurReset(this, x1, y)); y += bmax(title->get_h(), drag->get_h()) + 2*margin; diff --git a/cinelerra-5.1/plugins/crikey/crikeywindow.C b/cinelerra-5.1/plugins/crikey/crikeywindow.C index 4295d6d3..d2d6c6ce 100644 --- a/cinelerra-5.1/plugins/crikey/crikeywindow.C +++ b/cinelerra-5.1/plugins/crikey/crikeywindow.C @@ -588,6 +588,17 @@ int CriKeyDrag::handle_event() gui->send_configure_change(); return 1; } +int CriKeyWindow::handle_ungrab() +{ + CWindowGUI *cwindow_gui = plugin->server->mwindow->cwindow->gui; + int ret = ungrab(cwindow_gui); + if( ret ) { + drag->update(0); + plugin->config.drag = 0; + send_configure_change(); + } + return ret; +} CriKeyNewPoint::CriKeyNewPoint(CriKeyWindow *gui, CriKey *plugin, int x, int y) : BC_GenericButton(x, y, xS(80), _("New")) diff --git a/cinelerra-5.1/plugins/crikey/crikeywindow.h b/cinelerra-5.1/plugins/crikey/crikeywindow.h index 3e897f80..644cdd24 100644 --- a/cinelerra-5.1/plugins/crikey/crikeywindow.h +++ b/cinelerra-5.1/plugins/crikey/crikeywindow.h @@ -204,6 +204,7 @@ public: void start_color_thread(); int grab_event(XEvent *event); int do_grab_event(XEvent *event); + int handle_ungrab();; void done_event(int result); void send_configure_change(); diff --git a/cinelerra-5.1/plugins/mandelcuda/mandelbrotwindow.C b/cinelerra-5.1/plugins/mandelcuda/mandelbrotwindow.C index 1808bc43..a2b12db9 100644 --- a/cinelerra-5.1/plugins/mandelcuda/mandelbrotwindow.C +++ b/cinelerra-5.1/plugins/mandelcuda/mandelbrotwindow.C @@ -173,6 +173,13 @@ int MandelbrotDrag::handle_event() gui->ungrab(cwindow_gui); return 1; } +int MandelbrotDrag::handle_ungrab() +{ + CWindowGUI *cwindow_gui = gui->plugin->server->mwindow->cwindow->gui; + int ret = gui->ungrab(cwindow_gui); + if( ret ) update(value = 0); + return ret; +} MandelbrotIsJulia::MandelbrotIsJulia(MandelbrotWindow *gui, int x, int y) : BC_CheckBox(x, y, gui->plugin->config.is_julia, _("Julia")) diff --git a/cinelerra-5.1/plugins/mandelcuda/mandelbrotwindow.h b/cinelerra-5.1/plugins/mandelcuda/mandelbrotwindow.h index 98208fce..be93a15b 100644 --- a/cinelerra-5.1/plugins/mandelcuda/mandelbrotwindow.h +++ b/cinelerra-5.1/plugins/mandelcuda/mandelbrotwindow.h @@ -56,6 +56,7 @@ public: MandelbrotDrag(MandelbrotWindow *gui, int x, int y); int handle_event(); + int handle_ungrab(); MandelbrotWindow *gui; }; diff --git a/cinelerra-5.1/plugins/nbodycuda/nbodywindow.C b/cinelerra-5.1/plugins/nbodycuda/nbodywindow.C index d5c2e9f9..546f9cbb 100644 --- a/cinelerra-5.1/plugins/nbodycuda/nbodywindow.C +++ b/cinelerra-5.1/plugins/nbodycuda/nbodywindow.C @@ -190,6 +190,13 @@ int N_BodyDrag::handle_event() gui->ungrab(cwindow_gui); return 1; } +int N_BodyDrag::handle_ungrab() +{ + CWindowGUI *cwindow_gui = gui->plugin->server->mwindow->cwindow->gui; + int ret = gui->ungrab(cwindow_gui); + if( ret ) update(value = 0); + return ret; +} N_BodySetMode::N_BodySetMode(N_BodyWindow *gui, int x, int y, const char *text) : BC_PopupTextBox(gui, 0, text, x, y, xS(100), yS(160)) diff --git a/cinelerra-5.1/plugins/nbodycuda/nbodywindow.h b/cinelerra-5.1/plugins/nbodycuda/nbodywindow.h index b4b04c0b..dd8a093f 100644 --- a/cinelerra-5.1/plugins/nbodycuda/nbodywindow.h +++ b/cinelerra-5.1/plugins/nbodycuda/nbodywindow.h @@ -41,6 +41,7 @@ public: N_BodyDrag(N_BodyWindow *gui, int x, int y); int handle_event(); + int handle_ungrab(); N_BodyWindow *gui; }; diff --git a/cinelerra-5.1/plugins/sketcher/sketcherwindow.C b/cinelerra-5.1/plugins/sketcher/sketcherwindow.C index d0c8ca24..22abb734 100644 --- a/cinelerra-5.1/plugins/sketcher/sketcherwindow.C +++ b/cinelerra-5.1/plugins/sketcher/sketcherwindow.C @@ -1299,6 +1299,17 @@ int SketcherDrag::handle_event() gui->send_configure_change(); return 1; } +int SketcherWindow::handle_ungrab() +{ + CWindowGUI *cwindow_gui = plugin->server->mwindow->cwindow->gui; + int ret = ungrab(cwindow_gui); + if( ret ) { + drag->update(0); + plugin->config.drag = 0; + send_configure_change(); + } + return ret; +} SketcherNewPoint::SketcherNewPoint(SketcherWindow *gui, Sketcher *plugin, int x, int y) : BC_GenericButton(x, y, xS(96), _("New")) diff --git a/cinelerra-5.1/plugins/sketcher/sketcherwindow.h b/cinelerra-5.1/plugins/sketcher/sketcherwindow.h index 3353ffac..a0a5e3ce 100644 --- a/cinelerra-5.1/plugins/sketcher/sketcherwindow.h +++ b/cinelerra-5.1/plugins/sketcher/sketcherwindow.h @@ -396,6 +396,7 @@ public: void update_gui(); int grab_event(XEvent *event); int do_grab_event(XEvent *event); + int handle_ungrab(); int grab_button_press(XEvent *event); int grab_cursor_motion(); void send_configure_change(); diff --git a/cinelerra-5.1/plugins/titler/titlerwindow.C b/cinelerra-5.1/plugins/titler/titlerwindow.C index c6db737b..de6d10cb 100644 --- a/cinelerra-5.1/plugins/titler/titlerwindow.C +++ b/cinelerra-5.1/plugins/titler/titlerwindow.C @@ -264,10 +264,8 @@ void TitleWindow::create_objects() add_tool(drag = new TitleDrag(client, this, x, y + yS(80))); drag->create_objects(); if( drag->get_w() > w1 ) w1 = drag->get_w(); - if( client->config.drag ) { - if( drag->drag_activate() ) - eprintf("drag enabled, but compositor already grabbed\n"); - } + if( client->config.drag && drag->drag_activate() ) + eprintf("drag enabled, but compositor already grabbed\n"); add_tool(alias = new TitleAlias(client, this, x, y+yS(110))); if( alias->get_w() > w1 ) w1 = drag->get_w(); diff --git a/cinelerra-5.1/plugins/tracer/tracerwindow.C b/cinelerra-5.1/plugins/tracer/tracerwindow.C index ccc04709..980da954 100644 --- a/cinelerra-5.1/plugins/tracer/tracerwindow.C +++ b/cinelerra-5.1/plugins/tracer/tracerwindow.C @@ -545,6 +545,18 @@ int TracerDrag::handle_event() gui->send_configure_change(); return 1; } +int TracerWindow::handle_ungrab() +{ + CWindowGUI *cwindow_gui = plugin->server->mwindow->cwindow->gui; + int ret = ungrab(cwindow_gui); + if( ret ) { + drag->update(0); + plugin->config.drag = 0; + send_configure_change(); + } + return ret; +} + TracerDraw::TracerDraw(TracerWindow *gui, int x, int y) : BC_CheckBox(x, y, gui->plugin->config.draw, _("Draw")) diff --git a/cinelerra-5.1/plugins/tracer/tracerwindow.h b/cinelerra-5.1/plugins/tracer/tracerwindow.h index 75532822..425885d4 100644 --- a/cinelerra-5.1/plugins/tracer/tracerwindow.h +++ b/cinelerra-5.1/plugins/tracer/tracerwindow.h @@ -231,6 +231,7 @@ public: void start_color_thread(); int grab_event(XEvent *event); int do_grab_event(XEvent *event); + int handle_ungrab(); void done_event(int result); void send_configure_change();