X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fsketcher%2Fsketcherwindow.C;h=f835d0072f3415026defdd0d8b870e4387b5c175;hp=08412fc8d1211929e6e6d834b5cfd432640a38a2;hb=d72d54c0e9d75486bb003e256630c77f77ce6368;hpb=ad498171bc20d8187dfa891da26d7b32a2ff0380 diff --git a/cinelerra-5.1/plugins/sketcher/sketcherwindow.C b/cinelerra-5.1/plugins/sketcher/sketcherwindow.C index 08412fc8..f835d007 100644 --- a/cinelerra-5.1/plugins/sketcher/sketcherwindow.C +++ b/cinelerra-5.1/plugins/sketcher/sketcherwindow.C @@ -79,7 +79,7 @@ int SketcherCurvePenItem::handle_event() } SketcherCurvePen::SketcherCurvePen(SketcherWindow *gui, int x, int y, int pen) - : BC_PopupMenu(x,y,72,_(cv_pen[pen])) + : BC_PopupMenu(x,y,100,_(cv_pen[pen])) { this->gui = gui; this->pen = pen; @@ -96,8 +96,9 @@ void SketcherCurvePen::update(int pen) } -SketcherCurveColor::SketcherCurveColor(SketcherWindow *gui, int x, int y, int w, int h) - : BC_Button(x, y, w, vframes) +SketcherCurveColor::SketcherCurveColor(SketcherWindow *gui, + int x, int y, int w, int h, int color, int alpha) + : ColorBoxButton(_("Curve Color"), x, y, w, h, color, alpha, 1) { this->gui = gui; this->color = CV_COLOR; @@ -113,103 +114,26 @@ SketcherCurveColor::~SketcherCurveColor() delete vframes[i]; } -void SketcherCurveColor::set_color(int color) +void SketcherCurveColor::handle_done_event(int result) { - this->color = color; - int r = (color>>16) & 0xff; - int g = (color>>8) & 0xff; - int b = (color>>0) & 0xff; - for( int i=0; i<3; ++i ) { - VFrame *vframe = vframes[i]; - int ww = vframe->get_w(), hh = vframe->get_h(); - uint8_t **rows = vframe->get_rows(); - int rr = r, gg = g, bb = b; - switch( i ) { - case BUTTON_UP: - break; - case BUTTON_UPHI: - if( (rr+=48) > 0xff ) rr = 0xff; - if( (gg+=48) > 0xff ) gg = 0xff; - if( (bb+=48) > 0xff ) bb = 0xff; - break; - case BUTTON_DOWNHI: - if( (rr-=48) < 0x00 ) rr = 0x00; - if( (gg-=48) < 0x00 ) gg = 0x00; - if( (bb-=48) < 0x00 ) bb = 0x00; - break; - } - for( int y=0; ystart_color_thread(this); - return 1; -} - -SketcherCurveColorPicker::SketcherCurveColorPicker(SketcherWindow *gui, SketcherCurveColor *color_button) - : ColorPicker(1, _("Color")) -{ - this->gui = gui; - this->color_button = color_button; - this->color = CV_COLOR; - color_update = new SketcherCurveColorThread(this); -} - -SketcherCurveColorPicker::~SketcherCurveColorPicker() -{ - delete color_update; -} - -void SketcherCurveColorPicker::start(int color) -{ - this->color = color; - int alpha = (~color>>24) & 0xff; - start_window(color & 0xffffff, alpha, 1); - color_update->start(); -} - -void SketcherCurveColorPicker::handle_done_event(int result) -{ - color_update->stop(); - gui->lock_window("SketcherCurveColorPicker::handle_done_event"); - if( result ) { color = orig_color | (~orig_alpha<<24); } - color_button->update_gui(color); - gui->unlock_window(); + if( result ) color = orig_color | (~orig_alpha<<24); SketcherConfig &config = gui->plugin->config; int ci = config.cv_selected; if( ci >= 0 && ci < config.curves.size() ) { SketcherCurve *cv = config.curves[ci]; cv->color = color; + gui->lock_window("SketcherCurveColor::handle_done_event"); gui->curve_list->update(ci); + gui->unlock_window(); gui->send_configure_change(); } } -int SketcherCurveColorPicker::handle_new_color(int color, int alpha) +int SketcherCurveColor::handle_new_color(int color, int alpha) { - this->color = color | (~alpha<<24); - color_update->update_lock->unlock(); - return 1; -} - -void SketcherCurveColorPicker::update_gui() -{ - gui->lock_window("SketcherCurveColorPicker::update_gui"); - color_button->update_gui(color); + color |= ~alpha<<24; this->color = color; + gui->lock_window("SketcherCurveColor::update_gui"); + update_gui(color); SketcherConfig &config = gui->plugin->config; int ci = config.cv_selected; if( ci >= 0 ) { @@ -219,46 +143,7 @@ void SketcherCurveColorPicker::update_gui() gui->send_configure_change(); } gui->unlock_window(); -} - -SketcherCurveColorThread::SketcherCurveColorThread(SketcherCurveColorPicker *color_picker) - : Thread(1, 0, 0) -{ - this->color_picker = color_picker; - this->update_lock = new Condition(0,"SketcherCurveColorThread::update_lock"); - done = 1; -} - -SketcherCurveColorThread::~SketcherCurveColorThread() -{ - stop(); - delete update_lock; -} - -void SketcherCurveColorThread::start() -{ - if( done ) { - done = 0; - Thread::start(); - } -} - -void SketcherCurveColorThread::stop() -{ - if( !done ) { - done = 1; - update_lock->unlock(); - join(); - } -} - -void SketcherCurveColorThread::run() -{ - while( !done ) { - update_lock->lock("SketcherCurveColorThread::run"); - if( done ) break; - color_picker->update_gui(); - } + return 1; } @@ -382,7 +267,7 @@ SketcherWindow::SketcherWindow(Sketcher *plugin) this->plugin = plugin; this->title_pen = 0; this->curve_pen = 0; this->title_color = 0; this->curve_color = 0; - this->color_picker = 0; this->drag = 0; + this->drag = 0; this->new_curve = 0; this->del_curve = 0; this->curve_up = 0; this->curve_dn = 0; this->title_x = 0; this->point_x = 0; @@ -410,7 +295,6 @@ SketcherWindow::~SketcherWindow() delete curve_width; delete point_x; delete point_y; - delete color_picker; } void SketcherWindow::create_objects() @@ -467,10 +351,9 @@ void SketcherWindow::create_objects() curve_pen = new SketcherCurvePen(this, x1, y, cv->pen); add_subwindow(curve_pen); dy = bmax(dy,curve_pen->get_h()); curve_pen->create_objects(); - curve_color = new SketcherCurveColor(this, x2, y, COLOR_W, COLOR_H); + curve_color = new SketcherCurveColor(this, x2, y, COLOR_W, COLOR_H, + cv->color&0xffffff, (~cv->color>>24)&0xff); add_subwindow(curve_color); dy = bmax(dy,curve_color->get_h()); - curve_color->set_color(cv->color); - curve_color->draw_face(); y += dy + margin; dy = 0; curve_list->update(ci); @@ -552,7 +435,7 @@ void SketcherWindow::create_objects() "Shift=\n" "None=\n" "Ctrl=\n" - "Alt=\n" + "Ctrl+Alt=\n" "Ctrl+Shift="))); dy = bmax(dy, notes0->get_h()); add_subwindow(notes1 = new BC_Title(x+100, y, _(" LMB\n" @@ -575,6 +458,12 @@ void SketcherWindow::create_objects() show_window(1); } +void SketcherWindow::done_event(int result) +{ + curve_color->close_picker(); + ungrab(plugin->server->mwindow->cwindow->gui); +} + void SketcherWindow::send_configure_change() { pending_config = 0; @@ -620,15 +509,16 @@ int SketcherWindow::do_grab_event(XEvent *event) CWindowGUI *cwindow_gui = mwindow->cwindow->gui; CWindowCanvas *canvas = cwindow_gui->canvas; int cx, cy; cwindow_gui->get_relative_cursor(cx, cy); - cx -= mwindow->theme->ccanvas_x; - cy -= mwindow->theme->ccanvas_y; + cx -= canvas->view_x; + cy -= canvas->view_y; if( !dragging ) { - if( cx < 0 || cx >= mwindow->theme->ccanvas_w || - cy < 0 || cy >= mwindow->theme->ccanvas_h ) + if( cx < 0 || cx >= canvas->view_w || + cy < 0 || cy >= canvas->view_h ) return 0; } + switch( event->type ) { case ButtonPress: if( dragging ) return 0; @@ -722,7 +612,7 @@ int SketcherWindow::grab_button_press(XEvent *event) point_list->update(pi); break; } - if( (state & AltMask) ) { // create new curve + if( (state & ControlMask) && (state & AltMask) ) { // create new curve ci = plugin->new_curve(cv->pen, cv->width, curve_color->color); curve_list->update(ci); point_list->update(-1); @@ -777,7 +667,7 @@ int SketcherWindow::grab_cursor_motion() return 1; } if( (state & Button1Mask) ) { - if( (state & ControlMask) ) { // drag selected point + if( (state & ControlMask) && !(state & AltMask) ) { // drag selected point SketcherPoint *pt = pi >= 0 && pi < points.size() ? points[pi] : 0; if( pt ) { point_list->set_point(pi, PT_X, pt->x = output_x); @@ -788,7 +678,7 @@ int SketcherWindow::grab_cursor_motion() } return 1; } - if( (state & AltMask) ) { // drag all curves + if( (state & ControlMask) && (state & AltMask) ) { // drag all curves int dx = round(output_x - last_x); int dy = round(output_y - last_y); for( int i=0; iconfig.cv_selected; - if( ci >= 0 && ci < plugin->config.curves.size() ) { - SketcherCurve *cv = plugin->config.curves[ci]; - color = cv->color; - } - color_picker->start(color); - lock_window("SketcherWindow::start_color_thread"); -} - SketcherCurveList::SketcherCurveList(SketcherWindow *gui, Sketcher *plugin, int x, int y) : BC_ListBox(x, y, 360, 130, LISTBOX_TEXT) @@ -903,6 +779,7 @@ int SketcherCurveList::handle_event() int SketcherCurveList::selection_changed() { + gui->curve_color->close_picker(); handle_event(); return 1; } @@ -1099,7 +976,7 @@ int SketcherPointTypeItem::handle_event() } SketcherPointType::SketcherPointType(SketcherWindow *gui, int x, int y, int arc) - : BC_PopupMenu(x,y,64,_(pt_type[arc])) + : BC_PopupMenu(x,y,100,_(pt_type[arc])) { this->gui = gui; this->type = arc;