X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fresizetrackthread.C;h=f2223b813480a906551520c059310e75f5d8a733;hp=f8e3de367561a23568d7089204a981b54cfd1d6b;hb=b104b77f5296719bd5e6de8472eb71542ddaedec;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1 diff --git a/cinelerra-5.1/cinelerra/resizetrackthread.C b/cinelerra-5.1/cinelerra/resizetrackthread.C index f8e3de36..f2223b81 100644 --- a/cinelerra-5.1/cinelerra/resizetrackthread.C +++ b/cinelerra-5.1/cinelerra/resizetrackthread.C @@ -68,7 +68,8 @@ void ResizeVTrackThread::start_window(int w, int h, int w1, int h1) } this->w = w; this->h = h; this->w1 = w1; this->h1 = h1; - w_scale = h_scale = 1; + w_scale = (float)w / w1; + h_scale = (float)h / h1; start(); } @@ -85,7 +86,7 @@ void ResizeVTrackThread::run() if(!result) { update(); } - +#ifdef GLx4 if(((w % 4) || (h % 4)) && mwindow->edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL) { @@ -93,23 +94,21 @@ void ResizeVTrackThread::run() _("This track's dimensions are not multiples of 4 so\n" "it can't be rendered by OpenGL.")); } +#endif } - - +#define RSZ_W xS(330) +#define RSZ_H yS(120) ResizeVTrackWindow::ResizeVTrackWindow(MWindow *mwindow, - ResizeVTrackThread *thread, - int x, - int y) - : BC_Window(_(PROGRAM_NAME ": Resize Track"), - x - 320 / 2, y - get_resources()->ok_images[0]->get_h() + 100 / 2, - 400, get_resources()->ok_images[0]->get_h() + 100, - 400, get_resources()->ok_images[0]->get_h() + 100, - 0, 0, 1) + ResizeVTrackThread *thread, int x, int y) + : BC_Window(_(PROGRAM_NAME ": Resize Track"), x-RSZ_W/2, y-RSZ_H/2, + RSZ_W, RSZ_H, RSZ_W, RSZ_H, 0, 0, 1) { this->mwindow = mwindow; this->thread = thread; +// *** CONTEXT_HELP *** + context_help_set_keyword("Track and Output Sizes"); } ResizeVTrackWindow::~ResizeVTrackWindow() @@ -118,32 +117,36 @@ ResizeVTrackWindow::~ResizeVTrackWindow() void ResizeVTrackWindow::create_objects() { + int xs5 = xS(5), xs10 = xS(10); + int ys10 = yS(10); lock_window("ResizeVTrackWindow::create_objects"); - int x = 10, y = 10; + int x = xs10, y = ys10; BC_Title *size_title = new BC_Title(x, y, _("Size:")); add_subwindow(size_title); int x1 = x + size_title->get_w(); - int y1 = y + size_title->get_h() + 10; + int y1 = y + size_title->get_h() + ys10; BC_Title *scale_title = new BC_Title(x, y1, _("Scale:")); add_subwindow(scale_title); int x2 = x + scale_title->get_w(); if( x2 > x1 ) x1 = x2; - x1 += 10; + x1 += ys10; add_subwindow(w = new ResizeVTrackWidth(this, thread, x1, y)); - x2 = x1 + w->get_w() + 5; + x2 = x1 + w->get_w() + xs5; BC_Title *xy = new BC_Title(x2, y, _("x")); add_subwindow(xy); - int x3 = x2 + xy->get_w() + 5; + int x3 = x2 + xy->get_w() + xs5; add_subwindow(h = new ResizeVTrackHeight(this, thread, x3, y)); - x = x3 + h->get_w() + 5; + x = x3 + h->get_w() + xs5; FrameSizePulldown *pulldown; add_subwindow(pulldown = new FrameSizePulldown(mwindow->theme, w, h, x, y)); - x += pulldown->get_w() + 5; + x += pulldown->get_w() + xs5; add_subwindow(new ResizeVTrackSwap(this, thread, x, y)); add_subwindow(w_scale = new ResizeVTrackScaleW(this, thread, x1, y1)); add_subwindow(new BC_Title(x2, y1, _("x"))); add_subwindow(h_scale = new ResizeVTrackScaleH(this, thread, x3, y1)); + x = x3 + h_scale->get_w() + xs5; + add_subwindow(reset = new ResizeReset(this, thread, x, y1)); add_subwindow(new BC_OKButton(this)); add_subwindow(new BC_CancelButton(this)); @@ -153,21 +156,15 @@ void ResizeVTrackWindow::create_objects() unlock_window(); } -void ResizeVTrackWindow::update(int changed_scale, - int changed_size, - int changed_all) +void ResizeVTrackWindow::update(int changed_scale, int changed_size) { -//printf("ResizeVTrackWindow::update %d %d %d\n", changed_scale, changed_size, changed_all); - if(changed_scale || changed_all) - { + if( changed_scale ) { thread->w = (int)(thread->w1 * thread->w_scale); w->update((int64_t)thread->w); thread->h = (int)(thread->h1 * thread->h_scale); h->update((int64_t)thread->h); } - else - if(changed_size || changed_all) - { + if( changed_size ) { thread->w_scale = thread->w1 ? (double)thread->w / thread->w1 : 1.; w_scale->update((float)thread->w_scale); thread->h_scale = thread->h1 ? (double)thread->h / thread->h1 : 1.; @@ -178,8 +175,6 @@ void ResizeVTrackWindow::update(int changed_scale, - - ResizeVTrackSwap::ResizeVTrackSwap(ResizeVTrackWindow *gui, ResizeVTrackThread *thread, int x, @@ -199,7 +194,7 @@ int ResizeVTrackSwap::handle_event() thread->h = w; gui->w->update((int64_t)h); gui->h->update((int64_t)w); - gui->update(0, 1, 0); + gui->update(0, 1); return 1; } @@ -212,7 +207,7 @@ ResizeVTrackWidth::ResizeVTrackWidth(ResizeVTrackWindow *gui, ResizeVTrackThread *thread, int x, int y) - : BC_TextBox(x, y, 90, 1, thread->w) + : BC_TextBox(x, y, xS(90), 1, thread->w) { this->gui = gui; this->thread = thread; @@ -220,7 +215,7 @@ ResizeVTrackWidth::ResizeVTrackWidth(ResizeVTrackWindow *gui, int ResizeVTrackWidth::handle_event() { thread->w = atol(get_text()); - gui->update(0, 1, 0); + gui->update(0, 1); return 1; } @@ -228,7 +223,7 @@ ResizeVTrackHeight::ResizeVTrackHeight(ResizeVTrackWindow *gui, ResizeVTrackThread *thread, int x, int y) - : BC_TextBox(x, y, 90, 1, thread->h) + : BC_TextBox(x, y, xS(90), 1, thread->h) { this->gui = gui; this->thread = thread; @@ -236,7 +231,7 @@ ResizeVTrackHeight::ResizeVTrackHeight(ResizeVTrackWindow *gui, int ResizeVTrackHeight::handle_event() { thread->h = atol(get_text()); - gui->update(0, 1, 0); + gui->update(0, 1); return 1; } @@ -245,7 +240,7 @@ ResizeVTrackScaleW::ResizeVTrackScaleW(ResizeVTrackWindow *gui, ResizeVTrackThread *thread, int x, int y) - : BC_TextBox(x, y, 90, 1, (float)thread->w_scale) + : BC_TextBox(x, y, xS(90), 1, (float)thread->w_scale) { this->gui = gui; this->thread = thread; @@ -253,7 +248,7 @@ ResizeVTrackScaleW::ResizeVTrackScaleW(ResizeVTrackWindow *gui, int ResizeVTrackScaleW::handle_event() { thread->w_scale = atof(get_text()); - gui->update(1, 0, 0); + gui->update(1, 0); return 1; } @@ -261,7 +256,7 @@ ResizeVTrackScaleH::ResizeVTrackScaleH(ResizeVTrackWindow *gui, ResizeVTrackThread *thread, int x, int y) - : BC_TextBox(x, y, 90, 1, (float)thread->h_scale) + : BC_TextBox(x, y, xS(90), 1, (float)thread->h_scale) { this->gui = gui; this->thread = thread; @@ -269,11 +264,28 @@ ResizeVTrackScaleH::ResizeVTrackScaleH(ResizeVTrackWindow *gui, int ResizeVTrackScaleH::handle_event() { thread->h_scale = atof(get_text()); - gui->update(1, 0, 0); + gui->update(1, 0); return 1; } +ResizeReset::ResizeReset(ResizeVTrackWindow *gui, + ResizeVTrackThread *thread, int x, int y) + : BC_Button(x, y, thread->mwindow->theme->get_image_set("reset_button")) +{ + this->gui = gui; + this->thread = thread; + set_tooltip(_("Reset")); +} +int ResizeReset::handle_event() +{ + thread->w = thread->w1; + thread->h = thread->h1; + thread->w_scale = 1; + thread->h_scale = 1; + gui->update(1, 1); + return 1; +} @@ -329,10 +341,12 @@ void ResizeAssetThread::update() char string[BCTEXTLEN]; asset->width = w; asset->height = h; + fwindow->lock_window("ResizeAssetThread::update"); sprintf(string, "%d", asset->width); fwindow->win_width->update(string); sprintf(string, "%d", asset->height); fwindow->win_height->update(string); + fwindow->unlock_window(); } ResizeAssetButton::ResizeAssetButton(AssetEditWindow *fwindow, int x, int y)