dragging = 0;
}
+int DragCheckBox::handle_ungrab()
+{
+ drag_deactivate();
+ update(*value = 0);
+ update_gui();
+ return 1;
+}
+
int DragCheckBox::check_pending()
{
if( pending && !grab_event_count() ) {
int handle_event();
int grab_event(XEvent *event);
+ int handle_ungrab();
MWindow *mwindow;
int grabbed, dragging, pending;
{
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();
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;
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
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;
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);
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<int> *x, ArrayList<int> *y, BC_Pixmap *pixmap = 0);
void fill_polygon(ArrayList<int> *x, ArrayList<int> *y, BC_Pixmap *pixmap = 0);
void draw_rectangle(int x, int y, int w, int h);
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,
}
}
+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<int> *x, ArrayList<int> *y, BC_Pixmap *pixmap)
{ BT
int npoints = MIN(x->total, y->total);
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;
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"))
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();
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"))
MandelbrotDrag(MandelbrotWindow *gui, int x, int y);
int handle_event();
+ int handle_ungrab();
MandelbrotWindow *gui;
};
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))
N_BodyDrag(N_BodyWindow *gui, int x, int y);
int handle_event();
+ int handle_ungrab();
N_BodyWindow *gui;
};
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"))
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();
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();
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"))
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();