From b77dbd97d927405c86a2a8ca0dd927bca3c70175 Mon Sep 17 00:00:00 2001 From: Good Guy Date: Thu, 5 Jan 2017 16:23:21 -0700 Subject: [PATCH] add alpha to bluebananna, add unicode Ctl/Shft/U textbox input, bluray presets --- cinelerra-5.1/cinelerra/bdcreate.C | 16 +- cinelerra-5.1/cinelerra/fileffmpeg.C | 46 ++ cinelerra-5.1/cinelerra/fileffmpeg.h | 2 + cinelerra-5.1/guicast/bctextbox.C | 430 +++++++++--------- cinelerra-5.1/guicast/bctextbox.h | 10 +- cinelerra-5.1/plugins/bluebanana/Makefile | 4 +- cinelerra-5.1/plugins/bluebanana/bluebanana.C | 4 + .../plugins/bluebanana/bluebananacolor.c | 20 + .../plugins/bluebanana/bluebananaconfig.C | 4 + .../plugins/bluebanana/bluebananaconfig.h | 2 + .../plugins/bluebanana/bluebananaengine.C | 30 +- .../plugins/bluebanana/bluebananawindow.C | 107 ++++- .../plugins/bluebanana/bluebananawindow.h | 8 +- 13 files changed, 432 insertions(+), 251 deletions(-) diff --git a/cinelerra-5.1/cinelerra/bdcreate.C b/cinelerra-5.1/cinelerra/bdcreate.C index de8042b3..57c207ba 100644 --- a/cinelerra-5.1/cinelerra/bdcreate.C +++ b/cinelerra-5.1/cinelerra/bdcreate.C @@ -46,14 +46,14 @@ static struct bd_format { { "1920x1080 24p", 1920,1080, 24., 1, ILACE_MODE_NOTINTERLACED }, { "1920x1080 25i", 1920,1080, 25., 1, ILACE_MODE_TOP_FIRST }, { "1920x1080 23.976p", 1920,1080, 23.976, 1, ILACE_MODE_NOTINTERLACED }, - { "1440x1080 29.97i", 1440,1080, 29.97, 0, ILACE_MODE_TOP_FIRST }, - { "1440x1080 25i", 1440,1080, 25., 0, ILACE_MODE_TOP_FIRST }, - { "1440x1080 24p", 1440,1080, 24., 0, ILACE_MODE_NOTINTERLACED }, - { "1440x1080 23.976p", 1440,1080, 23.976, 0, ILACE_MODE_NOTINTERLACED }, + { "1440x1080 29.97i", 1440,1080, 29.97, 1, ILACE_MODE_TOP_FIRST }, + { "1440x1080 25i", 1440,1080, 25., 1, ILACE_MODE_TOP_FIRST }, + { "1440x1080 24p", 1440,1080, 24., 1, ILACE_MODE_NOTINTERLACED }, + { "1440x1080 23.976p", 1440,1080, 23.976, 1, ILACE_MODE_NOTINTERLACED }, { "1280x720 59.94p", 1280,720, 59.94, 1, ILACE_MODE_NOTINTERLACED }, { "1280x720 50p", 1280,720, 50., 1, ILACE_MODE_NOTINTERLACED }, - { "1280x720 23.976p", 1280,720, 23.976, 1, ILACE_MODE_NOTINTERLACED }, { "1280x720 24p", 1280,720, 24., 1, ILACE_MODE_NOTINTERLACED }, + { "1280x720 23.976p", 1280,720, 23.976, 1, ILACE_MODE_NOTINTERLACED }, { "720x576 25p*", 720,576, 25., 0, ILACE_MODE_NOTINTERLACED }, { "720x576 25i", 720,576, 25., 0, ILACE_MODE_BOTTOM_FIRST }, { "720x480 29.97p*", 720,480, 29.97, 0, ILACE_MODE_NOTINTERLACED }, @@ -69,12 +69,12 @@ const double CreateBD_Thread::BD_WIDE_ASPECT_HEIGHT = 9.; const double CreateBD_Thread::BD_ASPECT_WIDTH = 4.; const double CreateBD_Thread::BD_ASPECT_HEIGHT = 3.; const double CreateBD_Thread::BD_FRAMERATE = 24000. / 1001.; -//const int CreateBD_Thread::BD_MAX_BITRATE = 40000000; -const int CreateBD_Thread::BD_MAX_BITRATE = 8000000; +const int CreateBD_Thread::BD_MAX_BITRATE = 40000000; +//const int CreateBD_Thread::BD_MAX_BITRATE = 8000000; const int CreateBD_Thread::BD_CHANNELS = 2; const int CreateBD_Thread::BD_WIDE_CHANNELS = 6; const double CreateBD_Thread::BD_SAMPLERATE = 48000; -const double CreateBD_Thread::BD_KAUDIO_RATE = 224; +const double CreateBD_Thread::BD_KAUDIO_RATE = 192; const int CreateBD_Thread::BD_INTERLACE_MODE = ILACE_MODE_NOTINTERLACED; CreateBD_MenuItem::CreateBD_MenuItem(MWindow *mwindow) diff --git a/cinelerra-5.1/cinelerra/fileffmpeg.C b/cinelerra-5.1/cinelerra/fileffmpeg.C index f3df7a2e..94205be8 100644 --- a/cinelerra-5.1/cinelerra/fileffmpeg.C +++ b/cinelerra-5.1/cinelerra/fileffmpeg.C @@ -59,6 +59,12 @@ void FFMpegConfigNum::create_objects() BC_TumbleTextBox::create_objects(); } +int FFMpegConfigNum::update_text(const char *text) +{ + BC_TumbleTextBox::update(text); + return handle_event(); +} + int FFMpegConfigNum::handle_event() { *output = atol(get_text()); @@ -343,6 +349,25 @@ int FileFFMPEG::get_best_colormodel(Asset *asset, int driver) return BC_RGB888; } + +int FileFFMPEG::get_ff_option(const char *nm, const char *options, char *value) +{ + for( const char *cp=options; *cp!=0; ) { + char line[BCTEXTLEN], *bp = line, *ep = bp+sizeof(line)-1; + while( bp < ep && *cp && *cp!='\n' ) *bp++ = *cp++; + if( *cp ) ++cp; + *bp = 0; + if( !line[0] || line[0] == '#' || line[0] == ';' ) continue; + char key[BCSTRLEN], val[BCTEXTLEN]; + if( FFMPEG::scan_option_line(line, key, val) ) continue; + if( !strcmp(key, nm) ) { + strcpy(value, val); + return 0; + } + } + return 1; +} + //====== FFMPEGConfigAudio::FFMPEGConfigAudio(BC_WindowBase *parent_window, Asset *asset) @@ -429,6 +454,10 @@ void FFMPEGConfigAudio::create_objects() add_subwindow(new BC_OKButton(this)); add_subwindow(new BC_CancelButton(this)); + char value[BCTEXTLEN]; + if( !FileFFMPEG::get_ff_option("cin_bitrate", asset->ff_audio_options, value) ) + bitrate->update_text(value); + show_window(1); bitrate->handle_event(); unlock_window(); @@ -469,6 +498,10 @@ int FFMPEGConfigAudioPopup::handle_event() FFMPEG::load_options(option_path, asset->ff_audio_options, sizeof(asset->ff_audio_options)); popup->audio_options->update(asset->ff_audio_options); + + char value[BCTEXTLEN]; + if( !FileFFMPEG::get_ff_option("cin_bitrate", asset->ff_audio_options, value) ) + popup->bitrate->update_text(value); return 1; } @@ -583,6 +616,12 @@ void FFMPEGConfigVideo::create_objects() add_subwindow(new BC_OKButton(this)); add_subwindow(new BC_CancelButton(this)); + char value[BCTEXTLEN]; + if( !FileFFMPEG::get_ff_option("cin_quality", asset->ff_video_options, value) ) + quality->update_text(value); + if( !FileFFMPEG::get_ff_option("cin_bitrate", asset->ff_video_options, value) ) + bitrate->update_text(value); + show_window(1); if( asset->ff_video_bitrate ) quality->disable(); @@ -626,6 +665,13 @@ int FFMPEGConfigVideoPopup::handle_event() FFMPEG::load_options(option_path, asset->ff_video_options, sizeof(asset->ff_video_options)); popup->video_options->update(asset->ff_video_options); + + char value[BCTEXTLEN]; + if( !FileFFMPEG::get_ff_option("cin_quality", asset->ff_video_options, value) ) { + popup->quality->update_text(value); + } + if( !FileFFMPEG::get_ff_option("cin_bitrate", asset->ff_video_options, value) ) + popup->bitrate->update_text(value); return 1; } diff --git a/cinelerra-5.1/cinelerra/fileffmpeg.h b/cinelerra-5.1/cinelerra/fileffmpeg.h index 8c80f663..a4aea297 100644 --- a/cinelerra-5.1/cinelerra/fileffmpeg.h +++ b/cinelerra-5.1/cinelerra/fileffmpeg.h @@ -38,6 +38,7 @@ public: int &width, int &height, char *title=0); int get_audio_for_video(int vstream, int astream, int64_t &channel_mask); static void get_info(char *path,char *text,int len); + static int get_ff_option(const char *nm, const char *options, char *value); int open_file(int rd,int wr); int get_index(IndexFile *index_file, MainProgressBar *progress_bar); int close_file(void); @@ -60,6 +61,7 @@ public: ~FFMpegConfigNum(); void create_objects(); + int update_text(const char *text); int handle_event(); int *output; BC_Window *window; diff --git a/cinelerra-5.1/guicast/bctextbox.C b/cinelerra-5.1/guicast/bctextbox.C index 5c79fdc6..f8777993 100644 --- a/cinelerra-5.1/guicast/bctextbox.C +++ b/cinelerra-5.1/guicast/bctextbox.C @@ -161,6 +161,7 @@ int BC_TextBox::reset_parameters(int rows, int has_border, int font, int size) text_selected = 0; word_selected = 0; line_selected = 0; + unicode_active = -1; text_x = 0; enabled = 1; highlighted = 0; @@ -733,14 +734,15 @@ void BC_TextBox::draw(int flush) if(k > top_margin-text_height && k < get_h()-bottom_margin) { // Draw highlighted region of row - if(highlight_letter2 > highlight_letter1 && - highlight_letter2 > row_begin && - highlight_letter1 <= row_end) { - if(active && enabled && get_has_focus()) - set_color(resources->text_highlight); - else - set_color(resources->text_inactive_highlight); - + if( highlight_letter2 > highlight_letter1 && + highlight_letter2 > row_begin && + highlight_letter1 <= row_end ) { + int color = active && enabled && get_has_focus() ? + resources->text_highlight : + resources->text_inactive_highlight; + if( unicode_active >= 0 ) + color ^= LTBLUE; + set_color(color); if(highlight_letter1 >= row_begin && highlight_letter1 <= row_end) highlight_x1 = positions[highlight_letter1]; @@ -1195,9 +1197,8 @@ int BC_TextBox::repeat_event(int64_t duration) void BC_TextBox::default_keypress(int &dispatch_event, int &result) { - if((top_level->get_keypress() == RETURN) || - (top_level->get_keypress() > 30 && top_level->get_keypress() <= 255)) - { + if( (top_level->get_keypress() == RETURN) || + (top_level->get_keypress() > 30 && top_level->get_keypress() <= 255)) { int len; wchar_t *temp_string = top_level->get_wkeystring(&len); if(top_level->get_keypress() == RETURN) { @@ -1224,99 +1225,137 @@ int BC_TextBox::keypress_event() int wtext_len = wtext_update(); last_keypress = get_keypress(); + + if( unicode_active >= 0 ) { + wchar_t wch = 0; + int wlen = -1; + switch( last_keypress ) { +//unicode active acitons + case ESC: { + unicode_active = -1; + result = 1; + wlen = 0; + break; } + case RETURN: { + for( int i=highlight_letter1+1; i 0) { + delete_selection(ibeam_letter - 1, ibeam_letter, wtext_len); + highlight_letter2 = --ibeam_letter; + if( highlight_letter1 >= highlight_letter2 ) + unicode_active = -1; + } + result = 1; + wlen = 0; + break; } + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': { + int n = nib(last_keypress); + wch = n < 10 ? '0'+n : 'A'+n-10; + result = 1; + wlen = 1; + break; } +//normal actions + case TAB: + case LEFTTAB: + break; +//ignored actions + default: + result = 1; + break; + } + if( wlen >= 0 ) { + insert_text(&wch, wlen); + find_ibeam(1); + if( unicode_active >= 0 ) + highlight_letter2 = ibeam_letter; + else + highlight_letter1 = highlight_letter2 = 0; + draw(1); + } + } + + if( !result ) { //printf("BC_TextBox::keypress_event %d %x\n", __LINE__, last_keypress) - switch(last_keypress) - { - case ESC: + switch(last_keypress) { + case ESC: { // Deactivate the suggestions - if(suggestions && suggestions_popup) - { + if(suggestions && suggestions_popup) { delete suggestions_popup; suggestions_popup = 0; result = 1; } - else - { + else { top_level->deactivate(); result = 0; } - break; - - - - + break; } - case RETURN: - if(rows == 1) - { + case RETURN: { + if( rows == 1 ) { top_level->deactivate(); dispatch_event = 1; result = 0; } - else - { + else { default_keypress(dispatch_event, result); } - break; - - + break; } // Handle like a default keypress - case TAB: + case TAB: { top_level->cycle_textboxes(1); result = 1; - break; - - + break; } - case LEFTTAB: + case LEFTTAB: { top_level->cycle_textboxes(-1); result = 1; - break; + break; } - case LEFT: - if(ibeam_letter > 0) - { + case LEFT: { + if(ibeam_letter > 0) { int old_ibeam_letter = ibeam_letter; // Single character - if(!ctrl_down()) - { + if(!ctrl_down()) { ibeam_letter--; } - else + else { // Word - { ibeam_letter--; while(ibeam_letter > 0 && isalnum(wtext[ibeam_letter - 1])) ibeam_letter--; } - // Extend selection - if(top_level->shift_down()) - { + if(top_level->shift_down()) { // Initialize highlighting - if(highlight_letter1 == highlight_letter2) - { + if(highlight_letter1 == highlight_letter2) { highlight_letter1 = ibeam_letter; highlight_letter2 = old_ibeam_letter; } - else + else if(highlight_letter1 == old_ibeam_letter) { // Extend left highlight - if(highlight_letter1 == old_ibeam_letter) - { highlight_letter1 = ibeam_letter; } - else + else if(highlight_letter2 == old_ibeam_letter) { // Shrink right highlight - if(highlight_letter2 == old_ibeam_letter) - { highlight_letter2 = ibeam_letter; } } - else - { + else { highlight_letter1 = highlight_letter2 = ibeam_letter; } @@ -1325,50 +1364,39 @@ int BC_TextBox::keypress_event() if(keypress_draw) draw(1); } result = 1; - break; + break; } - case RIGHT: - if(ibeam_letter < wtext_len) - { + case RIGHT: { + if(ibeam_letter < wtext_len) { int old_ibeam_letter = ibeam_letter; // Single character - if(!ctrl_down()) - { + if(!ctrl_down()) { ibeam_letter++; } - else + else { // Word - { - while(ibeam_letter < wtext_len && isalnum(wtext[ibeam_letter++])) - ; + while(ibeam_letter < wtext_len && isalnum(wtext[ibeam_letter++])); } // Extend selection - if(top_level->shift_down()) - { + if(top_level->shift_down()) { // Initialize highlighting - if(highlight_letter1 == highlight_letter2) - { + if(highlight_letter1 == highlight_letter2) { highlight_letter1 = old_ibeam_letter; highlight_letter2 = ibeam_letter; } - else + else if(highlight_letter1 == old_ibeam_letter) { // Shrink left highlight - if(highlight_letter1 == old_ibeam_letter) - { highlight_letter1 = ibeam_letter; } - else + else if(highlight_letter2 == old_ibeam_letter) { // Expand right highlight - if(highlight_letter2 == old_ibeam_letter) - { highlight_letter2 = ibeam_letter; } } - else - { + else { highlight_letter1 = highlight_letter2 = ibeam_letter; } @@ -1376,52 +1404,42 @@ int BC_TextBox::keypress_event() if(keypress_draw) draw(1); } result = 1; - break; + break; } - case UP: - if(suggestions && suggestions_popup) - { + case UP: { + if(suggestions && suggestions_popup) { // Pass to suggestions popup //printf("BC_TextBox::keypress_event %d\n", __LINE__); suggestions_popup->activate(1); suggestions_popup->keypress_event(); result = 1; } - else - if(ibeam_letter > 0) - { + else if(ibeam_letter > 0) { //printf("BC_TextBox::keypress_event 1 %d %d %d\n", ibeam_x, ibeam_y, ibeam_letter); int new_letter = get_cursor_letter2(ibeam_x + text_x, ibeam_y + text_y - text_height); //printf("BC_TextBox::keypress_event 2 %d %d %d\n", ibeam_x, ibeam_y, new_letter); // Extend selection - if(top_level->shift_down()) - { + if(top_level->shift_down()) { // Initialize highlighting - if(highlight_letter1 == highlight_letter2) - { + if(highlight_letter1 == highlight_letter2) { highlight_letter1 = new_letter; highlight_letter2 = ibeam_letter; } - else + else if(highlight_letter1 == ibeam_letter) { // Expand left highlight - if(highlight_letter1 == ibeam_letter) - { highlight_letter1 = new_letter; } - else + else if(highlight_letter2 == ibeam_letter) { // Shrink right highlight - if(highlight_letter2 == ibeam_letter) - { highlight_letter2 = new_letter; } } else highlight_letter1 = highlight_letter2 = new_letter; - if(highlight_letter1 > highlight_letter2) - { + if(highlight_letter1 > highlight_letter2) { int temp = highlight_letter1; highlight_letter1 = highlight_letter2; highlight_letter2 = temp; @@ -1432,41 +1450,33 @@ int BC_TextBox::keypress_event() if(keypress_draw) draw(1); } result = 1; - break; + break; } - case PGUP: - if(ibeam_letter > 0) - { + case PGUP: { + if(ibeam_letter > 0) { int new_letter = get_cursor_letter2(ibeam_x + text_x, ibeam_y + text_y - get_h()); // Extend selection - if(top_level->shift_down()) - { + if(top_level->shift_down()) { // Initialize highlighting - if(highlight_letter1 == highlight_letter2) - { + if(highlight_letter1 == highlight_letter2) { highlight_letter1 = new_letter; highlight_letter2 = ibeam_letter; } - else + else if(highlight_letter1 == ibeam_letter) { // Expand left highlight - if(highlight_letter1 == ibeam_letter) - { highlight_letter1 = new_letter; } - else + else if(highlight_letter2 == ibeam_letter) { // Shrink right highlight - if(highlight_letter2 == ibeam_letter) - { highlight_letter2 = new_letter; } } else highlight_letter1 = highlight_letter2 = new_letter; - if(highlight_letter1 > highlight_letter2) - { + if(highlight_letter1 > highlight_letter2) { int temp = highlight_letter1; highlight_letter1 = highlight_letter2; highlight_letter2 = temp; @@ -1477,15 +1487,14 @@ int BC_TextBox::keypress_event() if(keypress_draw) draw(1); } result = 1; - break; + break; } - case DOWN: + case DOWN: { // printf("BC_TextBox::keypress_event %d %p %p\n", // __LINE__, // suggestions, // suggestions_popup); - if(suggestions && suggestions_popup) - { + if(suggestions && suggestions_popup) { // Pass to suggestions popup suggestions_popup->activate(1); suggestions_popup->keypress_event(); @@ -1499,32 +1508,25 @@ int BC_TextBox::keypress_event() ibeam_y + text_y + text_height); //printf("BC_TextBox::keypress_event 10 %d\n", new_letter); - if(top_level->shift_down()) - { + if(top_level->shift_down()) { // Initialize highlighting - if(highlight_letter1 == highlight_letter2) - { + if(highlight_letter1 == highlight_letter2) { highlight_letter1 = new_letter; highlight_letter2 = ibeam_letter; } - else + else if(highlight_letter1 == ibeam_letter) { // Shrink left highlight - if(highlight_letter1 == ibeam_letter) - { highlight_letter1 = new_letter; } - else + else if(highlight_letter2 == ibeam_letter) { // Expand right highlight - if(highlight_letter2 == ibeam_letter) - { highlight_letter2 = new_letter; } } else highlight_letter1 = highlight_letter2 = new_letter; - if(highlight_letter1 > highlight_letter2) - { + if(highlight_letter1 > highlight_letter2) { int temp = highlight_letter1; highlight_letter1 = highlight_letter2; highlight_letter2 = temp; @@ -1537,57 +1539,47 @@ int BC_TextBox::keypress_event() //printf("BC_TextBox::keypress_event 20 %d\n", ibeam_letter); } result = 1; - break; + break; } - case PGDN: - { + case PGDN: { // Extend selection - int new_letter = get_cursor_letter2(ibeam_x + text_x, - ibeam_y + text_y + get_h()); + int new_letter = get_cursor_letter2(ibeam_x + text_x, + ibeam_y + text_y + get_h()); //printf("BC_TextBox::keypress_event 10 %d\n", new_letter); - if(top_level->shift_down()) - { + if(top_level->shift_down()) { // Initialize highlighting - if(highlight_letter1 == highlight_letter2) - { - highlight_letter1 = new_letter; - highlight_letter2 = ibeam_letter; - } - else + if(highlight_letter1 == highlight_letter2) { + highlight_letter1 = new_letter; + highlight_letter2 = ibeam_letter; + } + else if(highlight_letter1 == ibeam_letter) { // Shrink left highlight - if(highlight_letter1 == ibeam_letter) - { - highlight_letter1 = new_letter; - } - else + highlight_letter1 = new_letter; + } + else if(highlight_letter2 == ibeam_letter) { // Expand right highlight - if(highlight_letter2 == ibeam_letter) - { - highlight_letter2 = new_letter; - } + highlight_letter2 = new_letter; } - else - highlight_letter1 = highlight_letter2 = new_letter; + } + else + highlight_letter1 = highlight_letter2 = new_letter; - if(highlight_letter1 > highlight_letter2) - { - int temp = highlight_letter1; - highlight_letter1 = highlight_letter2; - highlight_letter2 = temp; - } - ibeam_letter = new_letter; + if(highlight_letter1 > highlight_letter2) { + int temp = highlight_letter1; + highlight_letter1 = highlight_letter2; + highlight_letter2 = temp; + } + ibeam_letter = new_letter; - find_ibeam(1); - if(keypress_draw) draw(1); + find_ibeam(1); + if(keypress_draw) draw(1); //printf("BC_TextBox::keypress_event 20 %d\n", ibeam_letter); - } result = 1; - break; + break; } - case END: - { + case END: { delete suggestions_popup; suggestions_popup = 0; @@ -1596,25 +1588,19 @@ int BC_TextBox::keypress_event() while(ibeam_letter < wtext_len && wtext[ibeam_letter] != '\n') ibeam_letter++; - if(top_level->shift_down()) - { + if(top_level->shift_down()) { // Begin selection - if(highlight_letter1 == highlight_letter2) - { + if(highlight_letter1 == highlight_letter2) { highlight_letter2 = ibeam_letter; highlight_letter1 = old_ibeam_letter; } - else + else if(highlight_letter1 == old_ibeam_letter) { // Shrink selection - if(highlight_letter1 == old_ibeam_letter) - { highlight_letter1 = highlight_letter2; highlight_letter2 = ibeam_letter; } - else + else if(highlight_letter2 == old_ibeam_letter) { // Extend selection - if(highlight_letter2 == old_ibeam_letter) - { highlight_letter2 = ibeam_letter; } } @@ -1624,11 +1610,9 @@ int BC_TextBox::keypress_event() find_ibeam(1); if(keypress_draw) draw(1); result = 1; - break; - } + break; } - case HOME: - { + case HOME: { delete suggestions_popup; suggestions_popup = 0; @@ -1665,26 +1649,21 @@ int BC_TextBox::keypress_event() find_ibeam(1); if(keypress_draw) draw(1); result = 1; - break; - } + break; } - case BACKSPACE: - if(suggestions_popup) - { + case BACKSPACE: { + if(suggestions_popup) { delete suggestions_popup; suggestions_popup = 0; } - if(highlight_letter1 == highlight_letter2) - { - if(ibeam_letter > 0) - { + if(highlight_letter1 == highlight_letter2) { + if(ibeam_letter > 0) { delete_selection(ibeam_letter - 1, ibeam_letter, wtext_len); ibeam_letter--; } } - else - { + else { delete_selection(highlight_letter1, highlight_letter2, wtext_len); highlight_letter2 = ibeam_letter = highlight_letter1; } @@ -1693,19 +1672,16 @@ int BC_TextBox::keypress_event() if(keypress_draw) draw(1); dispatch_event = 1; result = 1; - break; + break; } - case DELETE: + case DELETE: { //printf("BC_TextBox::keypress_event %d\n", __LINE__); - if(highlight_letter1 == highlight_letter2) - { - if(ibeam_letter < wtext_len) - { + if(highlight_letter1 == highlight_letter2) { + if(ibeam_letter < wtext_len) { delete_selection(ibeam_letter, ibeam_letter + 1, wtext_len); } } - else - { + else { delete_selection(highlight_letter1, highlight_letter2, wtext_len); highlight_letter2 = ibeam_letter = highlight_letter1; } @@ -1714,35 +1690,26 @@ int BC_TextBox::keypress_event() if(keypress_draw) draw(1); dispatch_event = 1; result = 1; - break; - + break; } - - default: - if(ctrl_down()) - { - if(get_keypress() == 'c' || get_keypress() == 'C') - { - if(highlight_letter1 != highlight_letter2) - { + default: { + if( ctrl_down() ) { + switch( get_keypress() ) { + case 'c': case 'C': { + if(highlight_letter1 != highlight_letter2) { copy_selection(SECONDARY_SELECTION); result = 1; } - } - else - if(get_keypress() == 'v' || get_keypress() == 'V') - { + break; } + case 'v': case 'V': { paste_selection(SECONDARY_SELECTION); find_ibeam(1); if(keypress_draw) draw(1); dispatch_event = 1; result = 1; - } - else - if(get_keypress() == 'x' || get_keypress() == 'X') - { - if(highlight_letter1 != highlight_letter2) - { + break; } + case 'x': case 'X': { + if(highlight_letter1 != highlight_letter2) { copy_selection(SECONDARY_SELECTION); delete_selection(highlight_letter1, highlight_letter2, wtext_len); highlight_letter2 = ibeam_letter = highlight_letter1; @@ -1752,23 +1719,36 @@ int BC_TextBox::keypress_event() if(keypress_draw) draw(1); dispatch_event = 1; result = 1; + break; } + case 'u': case 'U': { + if( shift_down() ) { + unicode_active = ibeam_letter; + wchar_t wkey = 'U'; + insert_text(&wkey, 1); + find_ibeam(1); + highlight_letter1 = unicode_active; + highlight_letter2 = ibeam_letter; + draw(1); + result = 1; + } + break; } } - break; } default_keypress(dispatch_event, result); - break; + break; } + } } if(result) skip_cursor->update(); if(dispatch_event && handle_event()) result = 1; + return result; } - int BC_TextBox::uses_text() { return 1; @@ -1791,14 +1771,12 @@ void BC_TextBox::insert_text(const wchar_t *wcp, int len) { if( len < 0 ) len = wcslen(wcp); int wtext_len = wtext_update(); - if(highlight_letter1 < highlight_letter2) - { + if( unicode_active < 0 && highlight_letter1 < highlight_letter2 ) { delete_selection(highlight_letter1, highlight_letter2, wtext_len); highlight_letter2 = ibeam_letter = highlight_letter1; wtext_len = wtext_update(); } - int i, j; for(i=wtext_len-1, j=wtext_len+len-1; i>=ibeam_letter; i--, j--) { if( j >= wsize ) continue; diff --git a/cinelerra-5.1/guicast/bctextbox.h b/cinelerra-5.1/guicast/bctextbox.h index 0f3f23ed..b7632ec5 100644 --- a/cinelerra-5.1/guicast/bctextbox.h +++ b/cinelerra-5.1/guicast/bctextbox.h @@ -40,6 +40,14 @@ class BC_ScrollTextBoxYScroll; class BC_TextBox : public BC_SubWindow { + static inline int nib(int ch) { + if( ch >= '0' && ch <= '9' ) ch -= '0'; + else if( ch >= 'A' && ch <= 'F' ) ch -= 'A'-10; + else if( ch >= 'a' && ch <= 'f' ) ch -= 'a'-10; + else ch = -1; + return ch; + } + char *text; wchar_t *wtext; public: @@ -169,7 +177,7 @@ private: // Top left of cursor relative to text int ibeam_x, ibeam_y; - int ibeam_letter; + int ibeam_letter, unicode_active; int highlight_letter1, highlight_letter2; int highlight_letter3, highlight_letter4; int text_x1, text_start, text_end; diff --git a/cinelerra-5.1/plugins/bluebanana/Makefile b/cinelerra-5.1/plugins/bluebanana/Makefile index 86880379..7db3ed5d 100644 --- a/cinelerra-5.1/plugins/bluebanana/Makefile +++ b/cinelerra-5.1/plugins/bluebanana/Makefile @@ -14,7 +14,7 @@ include ../../plugin_config $(OBJDIR)/bluebanana.o: bluebanana.C $(OBJDIR)/bluebananaconfig.o: bluebananaconfig.C $(OBJDIR)/bluebananaslider.o: bluebananaslider.C -$(OBJDIR)/bluebananawindow.o: bluebananawindow.C +$(OBJDIR)/bluebananawindow.o: bluebananawindow.C bluebananacolor.c $(OBJDIR)/bluebananalookups.o: bluebananalookups.C -$(OBJDIR)/bluebananaengine.o: bluebananaengine.C +$(OBJDIR)/bluebananaengine.o: bluebananaengine.C bluebananacolor.c diff --git a/cinelerra-5.1/plugins/bluebanana/bluebanana.C b/cinelerra-5.1/plugins/bluebanana/bluebanana.C index 64bd8161..9e1cc94d 100644 --- a/cinelerra-5.1/plugins/bluebanana/bluebanana.C +++ b/cinelerra-5.1/plugins/bluebanana/bluebanana.C @@ -186,6 +186,8 @@ void BluebananaMain::save_data(KeyFrame *keyframe){ output.tag.set_property("OPACITY_ADJUST_ACTIVE", config.Oadj_active); output.tag.set_property("OPACITY_ADJUST", config.Oadj_val); + output.tag.set_property("ALPHA_ADJUST_ACTIVE", config.Aadj_active); + output.tag.set_property("ALPHA_ADJUST", config.Aadj_val); output.append_tag(); output.append_newline(); @@ -326,6 +328,8 @@ void BluebananaMain::read_data(KeyFrame *keyframe){ config.Oadj_active = input.tag.get_property("OPACITY_ADJUST_ACTIVE", config.Oadj_active); config.Oadj_val = input.tag.get_property("OPACITY_ADJUST", config.Oadj_val); + config.Aadj_active = input.tag.get_property("ALPHA_ADJUST_ACTIVE", config.Aadj_active); + config.Aadj_val = input.tag.get_property("ALPHA_ADJUST", config.Aadj_val); } } diff --git a/cinelerra-5.1/plugins/bluebanana/bluebananacolor.c b/cinelerra-5.1/plugins/bluebanana/bluebananacolor.c index 0de216de..357518ae 100644 --- a/cinelerra-5.1/plugins/bluebanana/bluebananacolor.c +++ b/cinelerra-5.1/plugins/bluebanana/bluebananacolor.c @@ -225,6 +225,16 @@ static inline void RGB_to_rgb8(float *R, float *G, float *B, float *S, float F, } } +static inline void Aal_to_alp8(float *S, float F, unsigned char *row, int w, int bpp){ + F = 1.f - F; + while(w--){ + float a = (1 - *S*F)*255.f +.5f; + row[3] = CLAMP(a,0,255); + row+=bpp; ++S; + } +} + + static inline void RGB_to_rgbF(float *R, float *G, float *B, float *S, float F, float *row, int w, int bpp){ if(F>SELECT_THRESH){ if(S){ @@ -264,6 +274,16 @@ static inline void RGB_to_rgbF(float *R, float *G, float *B, float *S, float F, } } +static inline void Aal_to_alpF(float *S, float F, float *row, int w, int bpp){ + F = 1.f - F; + while(w--){ + float a = 1.f - *S*F; + row[3] = a; + row+=bpp; + } +} + + static inline void unmask_rgba8(unsigned char *row,int w){ while(w--){ row[3] = 255; diff --git a/cinelerra-5.1/plugins/bluebanana/bluebananaconfig.C b/cinelerra-5.1/plugins/bluebanana/bluebananaconfig.C index a4e48217..dc964de1 100644 --- a/cinelerra-5.1/plugins/bluebanana/bluebananaconfig.C +++ b/cinelerra-5.1/plugins/bluebanana/bluebananaconfig.C @@ -83,6 +83,8 @@ BluebananaConfig::BluebananaConfig() { Oadj_active=0; Oadj_val=100; + Aadj_active=0; + Aadj_val=100; } @@ -120,6 +122,8 @@ int BluebananaConfig::equivalent(BluebananaConfig &that) { if(Oadj_active != that.Oadj_active) return 0; if(Oadj_val != that.Oadj_val) return 0; + if(Aadj_active != that.Aadj_active) return 0; + if(Aadj_val != that.Aadj_val) return 0; if(Sadj_active != that.Sadj_active) return 0; if(Sadj_gamma != that.Sadj_gamma) return 0; diff --git a/cinelerra-5.1/plugins/bluebanana/bluebananaconfig.h b/cinelerra-5.1/plugins/bluebanana/bluebananaconfig.h index 6119d8d8..124617ac 100644 --- a/cinelerra-5.1/plugins/bluebanana/bluebananaconfig.h +++ b/cinelerra-5.1/plugins/bluebanana/bluebananaconfig.h @@ -96,6 +96,8 @@ public: int Oadj_active; float Oadj_val; + int Aadj_active; + float Aadj_val; }; diff --git a/cinelerra-5.1/plugins/bluebanana/bluebananaengine.C b/cinelerra-5.1/plugins/bluebanana/bluebananaengine.C index 3a68c2ac..924d13fe 100644 --- a/cinelerra-5.1/plugins/bluebanana/bluebananaengine.C +++ b/cinelerra-5.1/plugins/bluebanana/bluebananaengine.C @@ -96,7 +96,8 @@ void BluebananaUnit::process_package(LoadPackage *package){ float Gas = plugin->green_adj_toe_slope; float Bas = plugin->blue_adj_toe_slope; - float Aal = plugin->config.Oadj_active ? plugin->config.Oadj_val*.01 : 1.f; + float Oal = plugin->config.Oadj_active ? plugin->config.Oadj_val*.01 : 1.f; + float Aal = plugin->config.Aadj_active ? plugin->config.Aadj_val*.01 : 1.f; float Vscale = (plugin->config.Vadj_hi-plugin->config.Vadj_lo) / 100.f; float Vshift = plugin->config.Vadj_lo / 100.f; @@ -842,22 +843,22 @@ void BluebananaUnit::process_package(LoadPackage *package){ /* layer back into pipeline color format; master fader applies here */ switch(frame->get_color_model()) { case BC_RGB888: - RGB_to_rgb8(Rvec,Gvec,Bvec,have_selection?selection:0,Aal,row_fragment,todo,3); + RGB_to_rgb8(Rvec,Gvec,Bvec,have_selection?selection:0,Oal,row_fragment,todo,3); break; case BC_RGBA8888: - RGB_to_rgb8(Rvec,Gvec,Bvec,have_selection?selection:0,Aal,row_fragment,todo,4); + RGB_to_rgb8(Rvec,Gvec,Bvec,have_selection?selection:0,Oal,row_fragment,todo,4); break; case BC_RGB_FLOAT: - RGB_to_rgbF(Rvec,Gvec,Bvec,have_selection?selection:0,Aal,(float *)row_fragment,todo,3); + RGB_to_rgbF(Rvec,Gvec,Bvec,have_selection?selection:0,Oal,(float *)row_fragment,todo,3); break; case BC_RGBA_FLOAT: - RGB_to_rgbF(Rvec,Gvec,Bvec,have_selection?selection:0,Aal,(float *)row_fragment,todo,4); + RGB_to_rgbF(Rvec,Gvec,Bvec,have_selection?selection:0,Oal,(float *)row_fragment,todo,4); break; case BC_YUV888: - RGB_to_yuv8(Rvec,Gvec,Bvec,have_selection?selection:0,Aal,row_fragment,todo,3); + RGB_to_yuv8(Rvec,Gvec,Bvec,have_selection?selection:0,Oal,row_fragment,todo,3); break; case BC_YUVA8888: - RGB_to_yuv8(Rvec,Gvec,Bvec,have_selection?selection:0,Aal,row_fragment,todo,4); + RGB_to_yuv8(Rvec,Gvec,Bvec,have_selection?selection:0,Oal,row_fragment,todo,4); break; } } @@ -921,13 +922,22 @@ void BluebananaUnit::process_package(LoadPackage *package){ if(use_mask && capture_mask){ switch(frame->get_color_model()) { case BC_RGBA8888: - unmask_rgba8(row_fragment,todo); + if( have_selection && Aal < 1.f ) + Aal_to_alp8(selection,Aal,row_fragment,todo,4); + else + unmask_rgba8(row_fragment,todo); break; case BC_RGBA_FLOAT: - unmask_rgbaF((float *)row_fragment,todo); + if( have_selection && Aal < 1.f ) + Aal_to_alpF(selection,Aal,(float *)row_fragment,todo,4); + else + unmask_rgbaF((float *)row_fragment,todo); break; case BC_YUVA8888: - unmask_yuva8(row_fragment,todo); + if( have_selection && Aal < 1.f ) + Aal_to_alp8(selection,Aal,row_fragment,todo,4); + else + unmask_yuva8(row_fragment,todo); break; } } diff --git a/cinelerra-5.1/plugins/bluebanana/bluebananawindow.C b/cinelerra-5.1/plugins/bluebanana/bluebananawindow.C index fa6ac42d..8ef90b55 100644 --- a/cinelerra-5.1/plugins/bluebanana/bluebananawindow.C +++ b/cinelerra-5.1/plugins/bluebanana/bluebananawindow.C @@ -1340,6 +1340,56 @@ int BluebananaOAReadout::value_event(){ return 1; } +// ---------------------------------- alpha slider --------------------------------- +class BluebananaAAReadout : public BB_Tumble { + public: + BluebananaAAReadout(BluebananaMain *plugin, BluebananaWindow *gui, int w) + : BB_Tumble(plugin,gui,0.,0,100., 0,1,w){} + int value_event(); +}; + +class BluebananaAASlider : public BluebananaSliderSingle { +public: + int hidden; + BluebananaAASlider(BluebananaMain *plugin, BluebananaWindow *gui, + int x, int y, int w, int h) + : BluebananaSliderSingle(plugin,gui,x,y,w,h,0,100) { hidden = 0; } + virtual int handle_event() { + plugin->config.Aadj_val = val; + return 1; + } + void reset(){ + plugin->config.Aadj_val=100; + update(); + } + void update(){ + val = plugin->config.Aadj_val; + if( BC_CModels::has_alpha(plugin->colormodel) ) { + if( hidden ) { show_window(); hidden = 0; } + }else{ + if( !hidden ) { hide_window(); hidden = 1; } + } + if( hidden ) return; + highlight = plugin->config.active && plugin->config.Aadj_active; + gui->Aadj_readout->update(plugin->config.Aadj_val); + gui->slider_labels[11]->set_color(highlight && plugin->config.Aadj_val != 100 ? + get_resources()->default_text_color : dimtextcolor); + gui->enter_config_change(); + gui->commit_config_change(); + } + void trough_color(float hdel, float vdel, float &r, float &g, float &b, float &a){ + r=g=b=.8; + a=1-cos(hdel*M_PI*.5); + } +}; + +int BluebananaAAReadout::value_event(){ + float val = get_value(); + plugin->config.Aadj_val = val; + gui->Aadj_slider->update(); + return 1; +} + // ------------------------------------- picker buttons ----------------------------------------- class BluebananaHPicker : public BC_GenericButton{ public: @@ -1424,6 +1474,14 @@ class BluebananaOAReset : public BC_GenericButton{ int handle_event() { gui->Oadj_slider->reset(); return 1;} BluebananaWindow *gui; }; +class BluebananaAAReset : public BC_GenericButton{ + public: + BluebananaAAReset(BluebananaWindow *gui, int w) : BC_GenericButton(-1, -1, w, _("Reset")){ + this->gui = gui; + } + int handle_event() { gui->Aadj_slider->reset(); return 1;} + BluebananaWindow *gui; +}; // ----------------------------------- slider active buttons ------------------------------------ @@ -1632,6 +1690,36 @@ public: BluebananaWindow *gui; }; +class BluebananaAAActive : public BC_CheckBox { +public: + int hidden; + + BluebananaAAActive(BluebananaMain *plugin, BluebananaWindow *gui) + : BC_CheckBox(-1, -1, &plugin->config.Aadj_active, ""){ + this->plugin = plugin; + this->gui = gui; + hidden = 0; + } + virtual int handle_event(){ + plugin->config.Aadj_active = + !BC_CModels::has_alpha(plugin->colormodel) ? 0 : get_value(); + update(); + return 1; + } + void update(){ + this->BC_CheckBox::update(plugin->config.Aadj_active,1); + if( BC_CModels::has_alpha(plugin->colormodel) ) { + if( hidden ) { show_window(); hidden = 0; } + }else{ + if( !hidden ) { hide_window(); hidden = 1; } + } + if( hidden ) return; + gui->Aadj_slider->update(); + } + BluebananaMain *plugin; + BluebananaWindow *gui; +}; + // -------------------------------------------- Erode -------------------------------------------- class BluebananaErode : public BC_CheckBox { public: @@ -1738,6 +1826,7 @@ public: gui->Gadj_slider->update(); gui->Badj_slider->update(); gui->Oadj_slider->update(); + gui->Aadj_slider->update(); gui->commit_config_change(); } } @@ -1948,6 +2037,7 @@ BluebananaWindow::BluebananaWindow(BluebananaMain *plugin) Gadj_slider=NULL; Badj_slider=NULL; Oadj_slider=NULL; + Aadj_slider=NULL; use_mask=0; capture_mask=0; @@ -2002,8 +2092,8 @@ void BluebananaWindow::create_objects() y += l->get_h()*(row_padding+1.); } - const char *labels[11]={_("hue"),_("saturation"),_("value"),_("fill"),_("red"),_("green"),_("blue"),_("hue"),_("saturation"),_("value"),_("fade")}; - for(i=0;i<11;i++){ + const char *labels[12]={_("hue"),_("saturation"),_("value"),_("fill"),_("red"),_("green"),_("blue"),_("hue"),_("saturation"),_("value"),_("fade"),_("alpha")}; + for(i=0;i<12;i++){ add_subwindow(slider_labels[i] = new BC_Title(-1,-1,labels[i])); if(slider_labels[i]->get_w()>label_w)label_w=slider_labels[i]->get_w(); } @@ -2020,7 +2110,7 @@ void BluebananaWindow::create_objects() add_subwindow(erode_label); add_subwindow(erode); - for(i=0;i<11;i++){ + for(i=0;i<12;i++){ BC_GenericButton *p=NULL; BluebananaSlider *s=NULL; BB_Tumble *t0 = NULL, *t1=NULL, *t2=NULL; @@ -2223,6 +2313,14 @@ void BluebananaWindow::create_objects() s = Oadj_slider = new BluebananaOASlider(plugin,this,slider_x,y,slider_w,row_h); break; + case 11: + + add_subwindow(t0 = Aadj_readout = new BluebananaAAReadout(plugin,this,tumbler_text_ww)); + add_subwindow(a = Aadj_active = new BluebananaAAActive(plugin,this)); + add_subwindow(p = new BluebananaAAReset(this,tumbler_col2_w)); + s = Aadj_slider = new BluebananaAASlider(plugin,this,slider_x,y,slider_w,row_h); + break; + } add_subwindow(s); @@ -2388,6 +2486,7 @@ void BluebananaWindow::update(){ Gadj_slider->update(); Badj_slider->update(); Oadj_slider->update(); + Aadj_slider->update(); active->update(); mark->update(); @@ -2407,6 +2506,7 @@ void BluebananaWindow::update(){ Gadj_active->update(); Badj_active->update(); Oadj_active->update(); + Aadj_active->update(); // called to release configuration without pushing leave_config_change(); @@ -2425,6 +2525,7 @@ void BluebananaWindow::render(){ Gadj_slider->render(); Badj_slider->render(); Oadj_slider->render(); + Aadj_slider->render(); } } diff --git a/cinelerra-5.1/plugins/bluebanana/bluebananawindow.h b/cinelerra-5.1/plugins/bluebanana/bluebananawindow.h index 4b5f6e39..39675002 100644 --- a/cinelerra-5.1/plugins/bluebanana/bluebananawindow.h +++ b/cinelerra-5.1/plugins/bluebanana/bluebananawindow.h @@ -47,6 +47,7 @@ class BluebananaRAActive; class BluebananaGAActive; class BluebananaBAActive; class BluebananaOAActive; +class BluebananaAAActive; class BluebananaHSSlider; class BluebananaSSSlider; @@ -59,6 +60,7 @@ class BluebananaRASlider; class BluebananaGASlider; class BluebananaBASlider; class BluebananaOASlider; +class BluebananaAASlider; class BluebananaHSReadout0; class BluebananaHSReadout1; @@ -90,6 +92,7 @@ class BluebananaBAReadout0; class BluebananaBAReadout1; class BluebananaBAReadout2; class BluebananaOAReadout; +class BluebananaAAReadout; class BluebananaPreserve; @@ -186,6 +189,7 @@ public: BluebananaGAActive *Gadj_active; BluebananaBAActive *Badj_active; BluebananaOAActive *Oadj_active; + BluebananaAAActive *Aadj_active; BluebananaHSSlider *Hsel_slider; BluebananaHSReadout0 *Hsel_readout0; @@ -238,10 +242,12 @@ public: BluebananaOASlider *Oadj_slider; BluebananaOAReadout *Oadj_readout; + BluebananaAASlider *Aadj_slider; + BluebananaAAReadout *Aadj_readout; //BluebananaPreserve *preserve_luma; - BC_Title *slider_labels[11]; + BC_Title *slider_labels[12]; BC_Title *erode_label; int do_render; }; -- 2.26.2