From: Good Guy Date: Tue, 8 Oct 2019 16:00:28 +0000 (-0600) Subject: back by popular demand: load mode icons, tweak shapewipe layout X-Git-Tag: 2019-10~9 X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=72a88d4704507f72e05b380d9604d9eb3e7d5a89;p=goodguy%2Fcinelerra.git back by popular demand: load mode icons, tweak shapewipe layout --- diff --git a/cinelerra-5.1/cinelerra/loadfile.C b/cinelerra-5.1/cinelerra/loadfile.C index fff3b625..c65a9a28 100644 --- a/cinelerra-5.1/cinelerra/loadfile.C +++ b/cinelerra-5.1/cinelerra/loadfile.C @@ -183,11 +183,9 @@ void LoadFileWindow::create_objects() lock_window("LoadFileWindow::create_objects"); BC_FileBox::create_objects(); - int x = get_w() / 2 - - LoadMode::calculate_w(this, mwindow->theme) / 2; - int y = get_cancel_button()->get_y() - - LoadMode::calculate_h(this, mwindow->theme); - loadmode = new LoadMode(mwindow, this, x, y, &thread->load_mode, 0); + int x = get_w() / 2 - LoadMode::calculate_w(this, mwindow->theme) / 2; + int y = get_y_margin(); + loadmode = new LoadMode(mwindow, this, x, y, &thread->load_mode, 0, 1); loadmode->create_objects(); add_subwindow(load_file_apply = new LoadFileApply(this)); @@ -199,16 +197,15 @@ void LoadFileWindow::create_objects() int LoadFileWindow::resize_event(int w, int h) { draw_background(0, 0, w, h); - int x = w / 2 - 200; - int y = get_cancel_button()->get_y() - - LoadMode::calculate_h(this, mwindow->theme); + BC_FileBox::resize_event(w, h); + int x = w / 2 - LoadMode::calculate_w(this, mwindow->theme) / 2; + int y = get_y_margin(); loadmode->reposition_window(x, y); - x = (w - BC_GenericButton::calculate_w(this, _("Apply")))/2; y = h - BC_GenericButton::calculate_h() - 15; load_file_apply->reposition_window(x, y); - - return BC_FileBox::resize_event(w, h); + flush(); + return 1; } diff --git a/cinelerra-5.1/cinelerra/loadmode.C b/cinelerra-5.1/cinelerra/loadmode.C index b32292ea..04b35ee6 100644 --- a/cinelerra-5.1/cinelerra/loadmode.C +++ b/cinelerra-5.1/cinelerra/loadmode.C @@ -25,8 +25,19 @@ #include "mwindow.h" #include "theme.h" - // Must match macros +static const char *mode_images[] = +{ + "loadmode_none", + "loadmode_new", + "loadmode_newcat", + "loadmode_newtracks", + "loadmode_cat", + "loadmode_paste", + "loadmode_resource", + "loadmode_nested" +}; + static const char *mode_text[] = { N_("Insert nothing"), @@ -47,8 +58,28 @@ LoadModeItem::LoadModeItem(const char *text, int value) } -LoadMode::LoadMode(MWindow *mwindow, BC_WindowBase *window, - int x, int y, int *output, int use_nothing) +LoadModeToggle::LoadModeToggle(int x, int y, LoadMode *window, + int value, const char *images, const char *tooltip) + : BC_Toggle(x, y, window->mwindow->theme->get_image_set(images), + *window->output == value) +{ + this->window = window; + this->value = value; + set_tooltip(tooltip); +} + +int LoadModeToggle::handle_event() +{ + *window->output = value; + window->update(); + return 1; +} + + + +LoadMode::LoadMode(MWindow *mwindow, + BC_WindowBase *window, int x, int y, int *output, + int use_nothing, int use_nested, int line_wrap) { this->mwindow = mwindow; this->window = window; @@ -56,11 +87,9 @@ LoadMode::LoadMode(MWindow *mwindow, BC_WindowBase *window, this->y = y; this->output = output; this->use_nothing = use_nothing; - int mode = LOADMODE_NOTHING; - if(use_nothing) - load_modes.append(new LoadModeItem(_(mode_text[mode]), mode)); - while( ++mode < TOTAL_LOADMODES ) - load_modes.append(new LoadModeItem(_(mode_text[mode]), mode)); + this->use_nested = use_nested; + this->line_wrap = line_wrap; + for( int i=0; ivalue == *output ) + return load_modes[i]->get_text(); + } + return _("Unknown"); +} + +void LoadMode::load_mode_geometry(BC_WindowBase *gui, Theme *theme, + int use_nothing, int use_nested, int line_wrap, + int *pw, int *ph) +{ + int pad = 5; + const char *title_text = _("Insertion strategy:"); + int mw = BC_Title::calculate_w(gui, title_text); + int mh = BC_Title::calculate_h(gui, title_text); + int ix = mw + 2*pad, iy = 0, x1 = ix; + int ww = theme->loadmode_w + 24; + if( mw < ww ) mw = ww; + + for( int i=0; iget_image_set(mode_images[i]), 0, + &text_line, &w, &h, &toggle_x, &toggle_y, + &text_x, &text_y, &text_w, &text_h, 0, MEDIUMFONT); + if( line_wrap && ix+w > ww ) { ix = x1; iy += h+pad; } + if( (ix+=w) > mw ) mw = ix; + if( (h+=iy) > mh ) mh = h; + ix += pad; + } + + ix = 0; iy = mh+pad; + mh = iy + BC_TextBox::calculate_h(gui, MEDIUMFONT, 1, 1); + if( pw ) *pw = mw; + if( ph ) *ph = mh; } -int LoadMode::calculate_w(BC_WindowBase *gui, Theme *theme) +int LoadMode::calculate_w(BC_WindowBase *gui, Theme *theme, + int use_nothing, int use_nested, int line_wrap) { - return theme->loadmode_w + 24; + int result = 0; + load_mode_geometry(gui, theme, use_nothing, use_nested, line_wrap, + &result, 0); + return result; } -int LoadMode::calculate_h(BC_WindowBase *gui, Theme *theme) +int LoadMode::calculate_h(BC_WindowBase *gui, Theme *theme, + int use_nothing, int use_nested, int line_wrap) { - return BC_Title::calculate_h(gui, _("Insertion strategy:"), MEDIUMFONT) + - BC_TextBox::calculate_h(gui, MEDIUMFONT, 1, 1); + int result = 0; + load_mode_geometry(gui, theme, use_nothing, use_nested, line_wrap, + 0, &result); + return result; } -char* LoadMode::mode_to_text() +void LoadMode::create_objects() { - for(int i = 0; i < load_modes.total; i++) - { - if(load_modes.values[i]->value == *output) - return load_modes.values[i]->get_text(); + int pad = 5; + const char *title_text = _("Insertion strategy:"); + window->add_subwindow(title = new BC_Title(x, y, title_text)); + int mw = title->get_w(), mh = title->get_h(); + int ix = mw + 2*pad, iy = 0, x1 = ix; + int ww = mwindow->theme->loadmode_w + 24; + if( mw < ww ) mw = ww; + + for( int i=0; itheme->get_image_set(mode_images[i]), 0, + &text_line, &w, &h, &toggle_x, &toggle_y, + &text_x, &text_y, &text_w, &text_h, 0, MEDIUMFONT); + if( line_wrap && ix+w > ww ) { ix = x1; iy += h+pad; } + mode[i] = new LoadModeToggle(x+ix, y+iy, this, + i, mode_images[i], _(mode_text[i])); + window->add_subwindow(mode[i]); + if( (ix+=w) > mw ) mw = ix; + if( (h+=iy) > mh ) mh = h; + ix += pad; } - return _("Unknown"); + + ix = 0; iy = mh+pad; + const char *mode_text = mode_to_text(); + textbox = new BC_TextBox(x+ix, y+iy, + mwindow->theme->loadmode_w, 1, mode_text); + window->add_subwindow(textbox); + ix += textbox->get_w(); + listbox = new LoadModeListBox(window, this, x+ix, y+iy); + window->add_subwindow(listbox); + mh = iy + textbox->get_h(); } -int LoadMode::create_objects() +int LoadMode::reposition_window(int x, int y) { - int x = this->x, y = this->y; - char *default_text; - default_text = mode_to_text(); + this->x = x; this->y = y; + title->reposition_window(x, y); + int mw = title->get_w(), mh = title->get_h(); + int pad = 5; + int ix = mw + 2*pad, iy = 0, x1 = ix; + int ww = mwindow->theme->loadmode_w + 24; + if( mw < ww ) mw = ww; - window->add_subwindow(title = new BC_Title(x, y, _("Insertion strategy:"))); - y += title->get_h(); - window->add_subwindow(textbox = new BC_TextBox(x, y, - mwindow->theme->loadmode_w, 1, default_text)); - x += textbox->get_w(); - window->add_subwindow(listbox = new LoadModeListBox(window, this, x, y)); + for( int i=0; itheme->get_image_set(mode_images[i]), 0, + &text_line, &w, &h, &toggle_x, &toggle_y, + &text_x, &text_y, &text_w, &text_h, 0, MEDIUMFONT); + if( line_wrap && ix+w > ww ) { ix = x1; iy += h+pad; } + mode[i]->reposition_window(x+ix, y+iy); + if( (ix+=w) > mw ) mw = ix; + if( (h+=iy) > mh ) mh = h; + ix += pad; + } + ix = 0; iy = mh+pad; + textbox->reposition_window(x+ix, y+iy); + ix += textbox->get_w(); + listbox->reposition_window(x+ix, y+iy); return 0; } int LoadMode::get_h() { int result = 0; - result = MAX(result, title->get_h()); - result = MAX(result, textbox->get_h()); + load_mode_geometry(window, mwindow->theme, + use_nothing, use_nested, line_wrap, 0, &result); return result; } @@ -127,36 +252,26 @@ int LoadMode::get_y() return y; } -int LoadMode::reposition_window(int x, int y) +void LoadMode::update() { - this->x = x; - this->y = y; - title->reposition_window(x, y); - y += 20; - textbox->reposition_window(x, y); - x += textbox->get_w(); - listbox->reposition_window(x, - y, - mwindow->theme->loadmode_w); - return 0; + for( int i=0; iset_value(*output == i); + } + textbox->update(mode_to_text()); } +int LoadMode::set_line_wrap(int v) +{ + int ret = line_wrap; + line_wrap = v; + return ret; +} -LoadModeListBox::LoadModeListBox(BC_WindowBase *window, - LoadMode *loadmode, - int x, - int y) - : BC_ListBox(x, - y, - loadmode->mwindow->theme->loadmode_w, - 150, - LISTBOX_TEXT, - (ArrayList*)&loadmode->load_modes, - 0, - 0, - 1, - 0, - 1) +LoadModeListBox::LoadModeListBox(BC_WindowBase *window, LoadMode *loadmode, + int x, int y) + : BC_ListBox(x, y, loadmode->mwindow->theme->loadmode_w, 150, LISTBOX_TEXT, + (ArrayList*)&loadmode->load_modes, 0, 0, 1, 0, 1) { this->window = window; this->loadmode = loadmode; @@ -170,13 +285,9 @@ int LoadModeListBox::handle_event() { LoadModeItem *item = (LoadModeItem *)get_selection(0, 0); if( item ) { - loadmode->textbox->update(item->get_text()); *(loadmode->output) = item->value; + loadmode->update(); } return 1; } - - - - diff --git a/cinelerra-5.1/cinelerra/loadmode.h b/cinelerra-5.1/cinelerra/loadmode.h index 74745fea..2f358fca 100644 --- a/cinelerra-5.1/cinelerra/loadmode.h +++ b/cinelerra-5.1/cinelerra/loadmode.h @@ -27,8 +27,6 @@ #include "mwindow.inc" #include "theme.inc" -class LoadModeListBox; - class LoadModeItem : public BC_ListBoxItem { public: @@ -36,36 +34,48 @@ public: int value; }; +class LoadModeToggle : public BC_Toggle +{ +public: + LoadModeToggle(int x, int y, LoadMode *window, + int value, const char *images, const char *tooltip); + int handle_event(); + LoadMode *window; + int value; +}; + class LoadMode { public: LoadMode(MWindow *mwindow, - BC_WindowBase *window, - int x, - int y, - int *output, - int use_nothing); + BC_WindowBase *window, int x, int y, int *output, + int use_nothing=1, int use_nested=0, int line_wrap=0); ~LoadMode(); - - int create_objects(); + void create_objects(); int reposition_window(int x, int y); - static int calculate_w(BC_WindowBase *gui, Theme *theme); - static int calculate_h(BC_WindowBase *gui, Theme *theme); + static void load_mode_geometry(BC_WindowBase *gui, Theme *theme, + int use_nothing, int use_nested, int line_wrap, + int *pw, int *ph); + static int calculate_w(BC_WindowBase *gui, Theme *theme, + int use_nothing=1, int use_nested=0, int line_wrap=0); + static int calculate_h(BC_WindowBase *gui, Theme *theme, + int use_nothing=1, int use_nested=0, int line_wrap=0); int get_h(); int get_x(); int get_y(); - char* mode_to_text(); + const char *mode_to_text(); + void update(); + int set_line_wrap(int v); BC_Title *title; BC_TextBox *textbox; LoadModeListBox *listbox; MWindow *mwindow; BC_WindowBase *window; - int x; - int y; - int *output; - int use_nothing; + int x, y, *output; + int use_nothing, use_nested, line_wrap; + LoadModeToggle *mode[TOTAL_LOADMODES]; ArrayList load_modes; }; diff --git a/cinelerra-5.1/cinelerra/loadmode.inc b/cinelerra-5.1/cinelerra/loadmode.inc index bd4d78cb..d0b7aaee 100644 --- a/cinelerra-5.1/cinelerra/loadmode.inc +++ b/cinelerra-5.1/cinelerra/loadmode.inc @@ -22,7 +22,10 @@ #ifndef LOADMODE_INC #define LOADMODE_INC +class LoadModeItem; +class LoadModeToggle; class LoadMode; +class LoadModeListBox; // used in paste_edls to only add assets, not clips #define LOADMODE_ASSETSONLY -1 diff --git a/cinelerra-5.1/cinelerra/menueffects.C b/cinelerra-5.1/cinelerra/menueffects.C index 12ae34e1..d8dfdfab 100644 --- a/cinelerra-5.1/cinelerra/menueffects.C +++ b/cinelerra-5.1/cinelerra/menueffects.C @@ -630,7 +630,7 @@ void MenuEffectWindow::create_objects() format_tools->create_objects(x, y, asset->audio_data, asset->video_data, 0, 0, 0, 1, 0, 0, &menueffects->use_labels, 0); - loadmode = new LoadMode(mwindow, this, x, y, &menueffects->load_mode, 1); + loadmode = new LoadMode(mwindow, this, x, y, &menueffects->load_mode); loadmode->create_objects(); add_subwindow(new MenuEffectWindowOK(this)); diff --git a/cinelerra-5.1/cinelerra/recordgui.C b/cinelerra-5.1/cinelerra/recordgui.C index 9cc56e02..8386cfc6 100644 --- a/cinelerra-5.1/cinelerra/recordgui.C +++ b/cinelerra-5.1/cinelerra/recordgui.C @@ -404,8 +404,8 @@ void RecordGUI::create_objects() // Controls int loadmode_w = LoadMode::calculate_w(this, mwindow->theme); - load_mode = new LoadMode(mwindow, this, get_w() / 2 - loadmode_w / 2, y, - &record->load_mode, 1); + load_mode = new LoadMode(mwindow, this, + get_w() / 2 - loadmode_w / 2, y, &record->load_mode); load_mode->create_objects(); y += load_mode->get_h() + 5; diff --git a/cinelerra-5.1/cinelerra/render.C b/cinelerra-5.1/cinelerra/render.C index 5d4875fc..653ec559 100644 --- a/cinelerra-5.1/cinelerra/render.C +++ b/cinelerra-5.1/cinelerra/render.C @@ -1059,7 +1059,7 @@ void RenderWindow::create_objects() renderprofile->create_objects(); y += 70; - loadmode = new LoadMode(mwindow, this, x, y, &render->load_mode, 1); + loadmode = new LoadMode(mwindow, this, x, y, &render->load_mode); loadmode->create_objects(); add_subwindow(new BC_OKButton(this)); diff --git a/cinelerra-5.1/guicast/bcfilebox.C b/cinelerra-5.1/guicast/bcfilebox.C index f24a39e0..803f2fc4 100644 --- a/cinelerra-5.1/guicast/bcfilebox.C +++ b/cinelerra-5.1/guicast/bcfilebox.C @@ -546,6 +546,7 @@ BC_FileBox::BC_FileBox(int x, int y, const char *init_path, this->h_padding = h_padding; delete_thread = new BC_DeleteThread(this); rename_thread = 0; + y_margin = 0; } BC_FileBox::~BC_FileBox() @@ -679,7 +680,9 @@ void BC_FileBox::create_objects() add_subwindow(filter_text = new BC_FileBoxFilterText(x1, y, this)); add_subwindow(filter_popup = new BC_FileBoxFilterMenu(x1 + filter_text->get_w(), y, this)); + y += filter_text->get_h() + 10; } + y_margin = y; // listbox has to be active because refresh might be called from newfolder_thread listbox->activate(); @@ -781,6 +784,9 @@ int BC_FileBox::resize_event(int w, int h) set_w(w); set_h(h); get_resources()->filebox_w = get_w(); get_resources()->filebox_h = get_h(); + y_margin = filter_text ? + filter_text->get_y() + filter_text->get_h() + 10 : + textbox->get_y() + textbox->get_h() + 10 ; flush(); return 1; } @@ -1324,6 +1330,11 @@ void BC_FileBox::create_listbox(int x, int y, int mode) add_subwindow(listbox = new BC_FileBoxListBox(x, y, this)); } +int BC_FileBox::get_y_margin() +{ + return y_margin; +} + char* BC_FileBox::get_path(int selection) { if(selection == 0) diff --git a/cinelerra-5.1/guicast/bcfilebox.h b/cinelerra-5.1/guicast/bcfilebox.h index 115ac8b1..28d2deb2 100644 --- a/cinelerra-5.1/guicast/bcfilebox.h +++ b/cinelerra-5.1/guicast/bcfilebox.h @@ -286,6 +286,7 @@ public: char* get_newfolder_title(); char* get_rename_title(); char* get_delete_title(); + int get_y_margin(); void delete_files(); BC_Button* get_ok_button(); BC_Button* get_cancel_button(); @@ -358,7 +359,7 @@ private: BC_NewFolderThread *newfolder_thread; BC_RenameThread *rename_thread; BC_DeleteThread *delete_thread; - int h_padding; + int h_padding, y_margin; ArrayList recent_dirs; }; diff --git a/cinelerra-5.1/guicast/bclistbox.C b/cinelerra-5.1/guicast/bclistbox.C index ef29b0b6..a7cb8b87 100644 --- a/cinelerra-5.1/guicast/bclistbox.C +++ b/cinelerra-5.1/guicast/bclistbox.C @@ -551,9 +551,6 @@ int BC_ListBox::draw_button(int flush) // Draw the button for a popup listbox if( use_button && is_popup ) { int image_number = 0; - - draw_top_background(parent_window, 0, 0, w, h); - if( button_highlighted ) image_number = 1; if( current_operation == BUTTON_DN ) @@ -561,8 +558,9 @@ int BC_ListBox::draw_button(int flush) if( disabled ) image_number = 3; - pixmap->draw_pixmap(button_images[image_number], - 0, 0, w, h, 0, 0); + int iw = button_images[image_number]->get_w(); + int ih = button_images[image_number]->get_h(); + pixmap->draw_pixmap(button_images[image_number],0,0,iw,ih); flash(flush); } return 0; diff --git a/cinelerra-5.1/plugins/shapewipe/shapewipe.C b/cinelerra-5.1/plugins/shapewipe/shapewipe.C index 0cd3bbe0..7920b622 100644 --- a/cinelerra-5.1/plugins/shapewipe/shapewipe.C +++ b/cinelerra-5.1/plugins/shapewipe/shapewipe.C @@ -222,13 +222,6 @@ int ShapeWipeReset::handle_event() return 1; } -int ShapeWipeReset::calculate_w(ShapeWipeMain *client) -{ - VFrame **reset_images = client->get_theme()->get_image_set("reset_button"); - return reset_images[0]->get_w(); -} - - ShapeWipeShape::ShapeWipeShape(ShapeWipeMain *client, ShapeWipeWindow *window, int x, int y, int text_w, int list_h) @@ -280,15 +273,10 @@ void ShapeWipeWindow::create_objects() y += bar->get_h() + pad; add_subwindow(title = new BC_Title(x, y, _("Shape:"))); - int x1 = get_w()/5; - x = x1; - int tw = ww - x1 - ShapeWipeTumble::calculate_w() - pad - - BC_WindowBase::get_resources()->listbox_button[0]->get_w(); - shape_text = new ShapeWipeShape(plugin, this, x1, y, tw, 200); + int x1 = 85, x2 = 355, x3 = 386; + shape_text = new ShapeWipeShape(plugin, this, x1, y, x2-x1, 200); shape_text->create_objects(); - x += shape_text->get_w() + pad; - add_subwindow(new ShapeWipeTumble(plugin, - this, x, y)); + add_subwindow(new ShapeWipeTumble(plugin, this, x3, y)); y += shape_text->get_h() + pad; x = margin; @@ -298,10 +286,8 @@ void ShapeWipeWindow::create_objects() shape_feather->create_objects(); shape_feather->set_log_floatincrement(1); x += shape_feather->get_w() + 2*pad; - int sw = ww - ShapeWipeReset::calculate_w(plugin) - pad - x; - add_subwindow(shape_fslider = new ShapeWipeFSlider(plugin, this, x, y, sw)); - x += shape_fslider->get_w() + 2*pad; - add_subwindow(shape_reset = new ShapeWipeReset(plugin, this, x, y)); + add_subwindow(shape_fslider = new ShapeWipeFSlider(plugin, this, x, y, x2-x)); + add_subwindow(shape_reset = new ShapeWipeReset(plugin, this, x3, y)); y += shape_fslider->get_h() + pad; x = margin; diff --git a/cinelerra-5.1/plugins/shapewipe/shapewipe.h b/cinelerra-5.1/plugins/shapewipe/shapewipe.h index f9f67c59..b4fac85c 100644 --- a/cinelerra-5.1/plugins/shapewipe/shapewipe.h +++ b/cinelerra-5.1/plugins/shapewipe/shapewipe.h @@ -109,7 +109,6 @@ public: ShapeWipeReset(ShapeWipeMain *client, ShapeWipeWindow *window, int x, int y); int handle_event(); - static int calculate_w(ShapeWipeMain *client); ShapeWipeMain *client; ShapeWipeWindow *window; diff --git a/cinelerra-5.1/plugins/theme_blond_cv/blondcvtheme.C b/cinelerra-5.1/plugins/theme_blond_cv/blondcvtheme.C index 00cb8d76..7830a1d2 100644 --- a/cinelerra-5.1/plugins/theme_blond_cv/blondcvtheme.C +++ b/cinelerra-5.1/plugins/theme_blond_cv/blondcvtheme.C @@ -256,7 +256,7 @@ void BlondCVTheme::initialize() "ok_button"); resources->dirbox_margin = 50; - resources->filebox_margin = 101; + resources->filebox_margin = 120; resources->file_color = 0x000000; resources->directory_color = 0x0000ff; diff --git a/cinelerra-5.1/plugins/theme_blue_dot/bluedottheme.C b/cinelerra-5.1/plugins/theme_blue_dot/bluedottheme.C index 00892269..89cd2b94 100644 --- a/cinelerra-5.1/plugins/theme_blue_dot/bluedottheme.C +++ b/cinelerra-5.1/plugins/theme_blue_dot/bluedottheme.C @@ -172,7 +172,7 @@ void BlueDotTheme::initialize() resources->listbox_selected = BGREY; resources->dirbox_margin = 50; - resources->filebox_margin = 101; + resources->filebox_margin = 105; resources->file_color = 0x000000; resources->directory_color = DKBLUE; // COPIED FROM DEFAULT THEME <<4