From 4f7f413cbc1c6ea5da27cb75ca27a3ab317243ec Mon Sep 17 00:00:00 2001 From: Good Guy Date: Sat, 18 Mar 2017 16:00:56 -0600 Subject: [PATCH] titler fixes, auto paste bug, resize popup hang, focus policy fix, chk lang --- cinelerra-5.1/cinelerra/channelinfo.C | 17 +-- cinelerra-5.1/cinelerra/channelinfo.h | 3 - cinelerra-5.1/cinelerra/colorpicker.C | 60 +++++---- cinelerra-5.1/cinelerra/colorpicker.h | 4 +- cinelerra-5.1/cinelerra/floatauto.C | 6 +- cinelerra-5.1/cinelerra/mwindow.C | 28 +++++ cinelerra-5.1/cinelerra/mwindow.h | 1 + cinelerra-5.1/cinelerra/resizetrackthread.C | 20 +-- cinelerra-5.1/guicast/bcbutton.C | 8 +- cinelerra-5.1/guicast/bclistbox.C | 13 +- cinelerra-5.1/guicast/bclistbox.h | 9 +- cinelerra-5.1/guicast/bcpan.C | 4 +- cinelerra-5.1/guicast/bcpopupmenu.C | 4 +- cinelerra-5.1/guicast/bcpot.C | 2 - cinelerra-5.1/guicast/bcresources.C | 20 +-- cinelerra-5.1/guicast/bcslider.C | 2 - cinelerra-5.1/guicast/bctextbox.C | 12 +- cinelerra-5.1/guicast/bctextbox.h | 3 + cinelerra-5.1/guicast/bctoggle.C | 4 +- cinelerra-5.1/guicast/bctumble.C | 4 +- cinelerra-5.1/guicast/bcwindowbase.C | 129 +++++++------------- cinelerra-5.1/guicast/bcwindowbase.h | 15 ++- cinelerra-5.1/guicast/bcwindowdraw.C | 8 +- cinelerra-5.1/plugins/titler/titler.C | 8 +- cinelerra-5.1/plugins/titler/titlerwindow.C | 51 ++++++-- cinelerra-5.1/plugins/titler/titlerwindow.h | 4 + 26 files changed, 232 insertions(+), 207 deletions(-) diff --git a/cinelerra-5.1/cinelerra/channelinfo.C b/cinelerra-5.1/cinelerra/channelinfo.C index 42a3d883..b96be4f3 100644 --- a/cinelerra-5.1/cinelerra/channelinfo.C +++ b/cinelerra-5.1/cinelerra/channelinfo.C @@ -628,7 +628,6 @@ ChannelDataItem::ChannelDataItem(ChannelPanel *panel, int x, int y, int w, { this->panel = panel; x0 = x; y0 = y; - in_window = tooltip_done = 0; tip_info = 0; set_force_tooltip(1); } @@ -638,25 +637,11 @@ ChannelDataItem::~ChannelDataItem() delete [] tip_info; } -int ChannelDataItem::cursor_enter_event() -{ - if( is_event_win() ) { in_window = 1; tooltip_done = 0; } - else in_window = 0; - return 0; -} - -int ChannelDataItem::cursor_leave_event() -{ - if( tooltip_done ) { hide_tooltip(); in_window = 0; } - return 0; -} - int ChannelDataItem::repeat_event(int64_t duration) { - if( !tooltip_done && tip_info && in_window && + if( tip_info && cursor_above() && duration == get_resources()->tooltip_delay ) { show_tooltip(); - tooltip_done = 1; return 1; } return 0; diff --git a/cinelerra-5.1/cinelerra/channelinfo.h b/cinelerra-5.1/cinelerra/channelinfo.h index 5e01b06c..d436ebb8 100644 --- a/cinelerra-5.1/cinelerra/channelinfo.h +++ b/cinelerra-5.1/cinelerra/channelinfo.h @@ -267,10 +267,7 @@ public: ChannelPanel *panel; int x0, y0; const char *tip_info; - int in_window, tooltip_done; - int cursor_enter_event(); - int cursor_leave_event(); int repeat_event(int64_t duration); void set_tooltip(const char *tip); diff --git a/cinelerra-5.1/cinelerra/colorpicker.C b/cinelerra-5.1/cinelerra/colorpicker.C index 969e8c98..60fcfad9 100644 --- a/cinelerra-5.1/cinelerra/colorpicker.C +++ b/cinelerra-5.1/cinelerra/colorpicker.C @@ -24,6 +24,7 @@ #include "bcdisplayinfo.h" #include "colorpicker.h" #include "condition.h" +#include "keys.h" #include "language.h" #include "mutex.h" #include "mwindow.h" @@ -134,6 +135,10 @@ ColorWindow::~ColorWindow() delete yuv_y; delete yuv_u; delete yuv_v; delete aph_a; + if( button_grabbed ) { + ungrab_buttons(); + ungrab_cursor(); + } update_history(rgb888()); save_history(); } @@ -206,9 +211,9 @@ void ColorWindow::create_objects() yuv_y = new PaletteYUV(this, x,y+=40, yuv.y, 0, 1); yuv_y->create_objects(); yuv_y->set_tooltip(_("Luminance")); yuv_u = new PaletteYUV(this, x,y+=25, yuv.u, 0, 1); - yuv_u->create_objects(); yuv_u->set_tooltip(_("Compliment Red")); + yuv_u->create_objects(); yuv_u->set_tooltip(_("Complement Blue")); yuv_v = new PaletteYUV(this, x,y+=25, yuv.v, 0, 1); - yuv_v->create_objects(); yuv_v->set_tooltip(_("Compliment Blue")); + yuv_v->create_objects(); yuv_v->set_tooltip(_("Complement Red")); if( thread->do_alpha ) { aph_a = new PaletteAPH(this, x,y+=40, aph, 0, 1); aph_a->create_objects(); aph_a->set_tooltip(_("Alpha")); @@ -335,6 +340,21 @@ int ColorWindow::button_release_event() return 0; } +void ColorWindow::update_rgb_hex(const char *hex) +{ + int color; + if( sscanf(hex,"%x",&color) == 1 ) { + float r = ((color>>16) & 0xff) / 255.; + float g = ((color>>8) & 0xff) / 255.; + float b = ((color>>0) & 0xff) / 255.; + rgb.r = r; rgb.g = g; rgb.b = b; + update_rgb(); + update_display(); + update_history(); + handle_event(); + } +} + PaletteWheel::PaletteWheel(ColorWindow *window, int x, int y) : BC_SubWindow(x, y, 170, 170) @@ -602,9 +622,9 @@ int PaletteWheelValue::draw(float hue, float saturation, float value) g = (int)(g_f * 255); b = (int)(b_f * 255); for( j = 0; j < get_w(); j++ ) { - row[j * 3] = r; - row[j * 3 + 1] = g; - row[j * 3 + 2] = b; + row[j * 3] = r; + row[j * 3 + 1] = g; + row[j * 3 + 2] = b; } } @@ -880,7 +900,7 @@ void ColorWindow::load_history() FILE *fp = fopen(history_path,"r"); int i=0; if( fp ) { - while( i < PALLETTE_HISTORY_SIZE ) { + while( i < PALLETTE_HISTORY_SIZE ) { char line[BCSTRLEN]; if( !fgets(line,sizeof(line)-1,fp) ) break; line[sizeof(line)-1] = 0; @@ -999,17 +1019,7 @@ PaletteHexButton::~PaletteHexButton() int PaletteHexButton::handle_event() { const char *hex = window->hex_box->get_text(); - int color; - if( sscanf(hex,"%x",&color) == 1 ) { - float r = ((color>>16) & 0xff) / 255.; - float g = ((color>>8) & 0xff) / 255.; - float b = ((color>>0) & 0xff) / 255.; - window->rgb.r = r; window->rgb.g = g; window->rgb.b = b; - window->update_rgb(); - window->update_display(); - window->update_history(); - window->handle_event(); - } + window->update_rgb_hex(hex); return 1; } @@ -1027,8 +1037,11 @@ void PaletteHex::update() BC_TextBox::update(hex); } -int PaletteHex::handle_event() +int PaletteHex::keypress_event() { + if( get_keypress() != RETURN ) + return BC_TextBox::keypress_event(); + window->update_rgb_hex(get_text()); return 1; } @@ -1047,8 +1060,8 @@ PaletteGrabButton::PaletteGrabButton(ColorWindow *window, int x, int y) } PaletteGrabButton::~PaletteGrabButton() { - for( int i=0; i<3; ++i ) - delete vframes[i]; + for( int i=0; i<3; ++i ) + delete vframes[i]; } int PaletteGrabButton::handle_event() { @@ -1117,15 +1130,9 @@ int PaletteHistory::cursor_motion_event() return 1; } -int PaletteHistory::cursor_enter_event() -{ - set_tooltip_done(0); - return 0; -} int PaletteHistory::cursor_leave_event() { hide_tooltip(); - set_tooltip_done(0); return 0; } int PaletteHistory::repeat_event(int64_t duration) @@ -1135,7 +1142,6 @@ int PaletteHistory::repeat_event(int64_t duration) if( duration == get_resources()->tooltip_delay && get_tooltip() && *get_tooltip() && cursor_above() ) { show_tooltip(); - set_tooltip_done(1); result = 1; } return result; diff --git a/cinelerra-5.1/cinelerra/colorpicker.h b/cinelerra-5.1/cinelerra/colorpicker.h index a6306932..94386e8e 100644 --- a/cinelerra-5.1/cinelerra/colorpicker.h +++ b/cinelerra-5.1/cinelerra/colorpicker.h @@ -98,6 +98,7 @@ public: void update_rgb(float r, float g, float b); void update_hsv(float h, float s, float v); void update_yuv(float y, float u, float v); + void update_rgb_hex(const char *hex); int rgb888(); ColorThread *thread; @@ -335,7 +336,7 @@ class PaletteHex : public BC_TextBox public: PaletteHex(ColorWindow *window, int x, int y, const char *hex); ~PaletteHex(); - int handle_event(); + int keypress_event(); void update(); ColorWindow *window; }; @@ -360,7 +361,6 @@ public: int button_press_event(); int button_release_event(); int cursor_motion_event(); - int cursor_enter_event(); int cursor_leave_event(); int repeat_event(int64_t duration); diff --git a/cinelerra-5.1/cinelerra/floatauto.C b/cinelerra-5.1/cinelerra/floatauto.C index 1f22aeaa..bab8160f 100644 --- a/cinelerra-5.1/cinelerra/floatauto.C +++ b/cinelerra-5.1/cinelerra/floatauto.C @@ -142,9 +142,11 @@ int FloatAuto::interpolate_from(Auto *a1, Auto *a2, int64_t pos, Auto *templ) // set this->value using bézier interpolation if possible FloatAuto *left = (FloatAuto*)a1; FloatAuto *right = (FloatAuto*)a2; - float new_value = FloatAutos::calculate_bezier(left, right, pos); + if( pos != position ) { // this may trigger smoothing + this->adjust_to_new_coordinates(pos, + FloatAutos::calculate_bezier(left, right, pos)); + } float new_slope = FloatAutos::calculate_bezier_derivation(left, right, pos); - this->adjust_to_new_coordinates(pos, new_value); // this may trigger smoothing this->set_control_in_value(new_slope * control_in_position); this->set_control_out_value(new_slope * control_out_position); return 1; //return true: interpolated indeed... diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index 1060bb88..d02fe0bb 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -461,6 +461,32 @@ void MWindow::init_defaults(BC_Hash* &defaults, char *config_path) defaults->load(); } + +void MWindow::check_language() +{ + char curr_lang[BCTEXTLEN]; curr_lang[0] = 0; + const char *env_lang = getenv("LANGUAGE"); + if( !env_lang ) env_lang = getenv("LANG"); + if( !env_lang ) { + snprintf(curr_lang, sizeof(curr_lang), "%s-%s.%s", + BC_Resources::language, BC_Resources::region, BC_Resources::encoding); + env_lang = curr_lang; + } + char last_lang[BCTEXTLEN]; last_lang[0] = 0; + defaults->get("LAST_LANG",last_lang); + if( strcmp(env_lang,last_lang)) { + printf("lang changed from '%s' to '%s'\n", last_lang, env_lang); + defaults->update("LAST_LANG",env_lang); + char plugin_path[BCTEXTLEN]; + create_defaults_path(plugin_path, PLUGIN_FILE); + ::remove(plugin_path); + char ladspa_path[BCTEXTLEN]; + create_defaults_path(ladspa_path, LADSPA_FILE); + ::remove(ladspa_path); + defaults->save(); + } +} + void MWindow::get_plugin_path(char *path, const char *plug_dir, const char *fs_path) { char *base_path = FileSystem::basepath(fs_path), *bp = base_path; @@ -796,6 +822,7 @@ void MWindow::init_preferences() BC_Trace::disable_locks(); } BC_WindowBase::get_resources()->popupmenu_btnup = preferences->popupmenu_btnup; + BC_WindowBase::get_resources()->textbox_focus_policy = preferences->textbox_focus_policy; } void MWindow::clean_indexes() @@ -1891,6 +1918,7 @@ void MWindow::create_objects(int want_gui, if(debug) PRINT_TRACE default_standard = default_std(); init_defaults(defaults, config_path); + check_language(); init_preferences(); if(splash_window) splash_window->operation->update(_("Initializing Plugins")); diff --git a/cinelerra-5.1/cinelerra/mwindow.h b/cinelerra-5.1/cinelerra/mwindow.h index abe72590..a0ec37f3 100644 --- a/cinelerra-5.1/cinelerra/mwindow.h +++ b/cinelerra-5.1/cinelerra/mwindow.h @@ -632,6 +632,7 @@ public: void init_error(); void finit_error(); static void init_defaults(BC_Hash* &defaults, char *config_path); + void check_language(); const char *default_std(); void fill_preset_defaults(const char *preset, EDLSession *session); const char *get_preset_name(int index); diff --git a/cinelerra-5.1/cinelerra/resizetrackthread.C b/cinelerra-5.1/cinelerra/resizetrackthread.C index 1c2eadc8..4af7eb75 100644 --- a/cinelerra-5.1/cinelerra/resizetrackthread.C +++ b/cinelerra-5.1/cinelerra/resizetrackthread.C @@ -60,6 +60,12 @@ ResizeVTrackThread::~ResizeVTrackThread() void ResizeVTrackThread::start_window(int w, int h, int w1, int h1) { + if( window && running() ) { + window->lock_window(); + window->raise_window(); + window->unlock_window(); + return; + } this->w = w; this->h = h; this->w1 = w1; this->h1 = h1; w_scale = h_scale = 1; @@ -69,24 +75,18 @@ void ResizeVTrackThread::start_window(int w, int h, int w1, int h1) void ResizeVTrackThread::run() { - ResizeVTrackWindow *window = this->window = - new ResizeVTrackWindow(mwindow, - this, + window = new ResizeVTrackWindow(mwindow, this, mwindow->gui->get_abs_cursor_x(1), mwindow->gui->get_abs_cursor_y(1)); window->create_objects(); int result = window->run_window(); - this->window = 0; - delete window; - - if(!result) - { + delete window; window = 0; + if(!result) { update(); } - if(((w % 4) || - (h % 4)) && + if(((w % 4) || (h % 4)) && mwindow->edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL) { MainError::show_error( diff --git a/cinelerra-5.1/guicast/bcbutton.C b/cinelerra-5.1/guicast/bcbutton.C index 90a4681d..de76b69c 100644 --- a/cinelerra-5.1/guicast/bcbutton.C +++ b/cinelerra-5.1/guicast/bcbutton.C @@ -154,12 +154,10 @@ int BC_Button::draw_face(int flush) int BC_Button::repeat_event(int64_t duration) { - if( status == BUTTON_UPHI && !tooltip_done && - tooltip_text && tooltip_text[0] != 0 && + if( status == BUTTON_UPHI && tooltip_text && tooltip_text[0] != 0 && duration == top_level->get_resources()->tooltip_delay ) { show_tooltip(); - tooltip_done = 1; return 1; } return 0; @@ -169,9 +167,7 @@ int BC_Button::cursor_enter_event() { if(is_event_win() && enabled) { - tooltip_done = 0; - if(top_level->button_down) - { + if(top_level->button_down) { status = BUTTON_DOWNHI; } else diff --git a/cinelerra-5.1/guicast/bclistbox.C b/cinelerra-5.1/guicast/bclistbox.C index 3b133292..7a521a31 100644 --- a/cinelerra-5.1/guicast/bclistbox.C +++ b/cinelerra-5.1/guicast/bclistbox.C @@ -432,6 +432,7 @@ BC_ListBox::BC_ListBox(int x, // reset the search engine //printf("BC_ListBox::BC_ListBox 4\n"); + show_query = 0; reset_query(); //printf("BC_ListBox::BC_ListBox 5\n"); } @@ -2479,12 +2480,11 @@ int BC_ListBox::repeat_event(int64_t duration) case NO_OPERATION: // Show tooltip - if(button_highlighted && is_popup && !tooltip_done && + if(button_highlighted && is_popup && tooltip_text && tooltip_text[0] != 0 && duration == get_resources()->tooltip_delay) { show_tooltip(); - tooltip_done = 1; return 1; } break; @@ -3942,6 +3942,7 @@ int BC_ListBox::reposition_window(int x, int y, int w, int h, int flush) int BC_ListBox::deactivate() { + hide_tooltip(); // printf("BC_ListBox::deactivate %d this=%p gui=%p active=%d\n", // __LINE__, // this, @@ -4030,7 +4031,6 @@ int BC_ListBox::keypress_event() { case ESC: case RETURN: - case BACKSPACE: top_level->deactivate(); // If user is manipulating popup with keyboard, don't pass on event. @@ -4131,7 +4131,12 @@ int BC_ListBox::keypress_event() if(query_len > 0) query[--query_len] = 0; new_selection = query_list(); } - + if( show_query ) { + if( query_len > 0 ) + show_tooltip(query); + else + hide_tooltip(); + } redraw = 1; result = 1; } diff --git a/cinelerra-5.1/guicast/bclistbox.h b/cinelerra-5.1/guicast/bclistbox.h index e815a7f7..66d13255 100644 --- a/cinelerra-5.1/guicast/bclistbox.h +++ b/cinelerra-5.1/guicast/bclistbox.h @@ -253,6 +253,9 @@ public: void set_justify(int value); int get_w() { return is_popup ? BCPOPUPLISTBOX_W : popup_w; } int get_h() { return is_popup ? BCPOPUPLISTBOX_H : popup_h; } + int gui_tooltip(const char *text) { + return is_popup && gui ? gui->show_tooltip(text, gui->get_w(),0, -1,-1) : -1; + } int get_view_w() { return view_w; } int get_view_h() { return view_h; } int get_row_height() { return row_height; } @@ -275,6 +278,9 @@ public: void reset_query(); + int get_show_query() { return show_query; } + void set_show_query(int v) { show_query = v; } + int reposition_window(int x, int y, int w = -1, @@ -503,7 +509,7 @@ private: BC_ListBoxYScroll *yscrollbar; ArrayList expanders; char query[BCTEXTLEN]; - + int show_query; // Window containing the listbox BC_WindowBase *gui; @@ -534,7 +540,6 @@ private: int list_background; - // Popup button BC_Pixmap *button_images[4]; // Expander diff --git a/cinelerra-5.1/guicast/bcpan.C b/cinelerra-5.1/guicast/bcpan.C index 7af2d1eb..e35925f4 100644 --- a/cinelerra-5.1/guicast/bcpan.C +++ b/cinelerra-5.1/guicast/bcpan.C @@ -192,12 +192,11 @@ int BC_Pan::button_release_event() int BC_Pan::repeat_event(int64_t duration) { - if( highlighted && !active && !tooltip_done && + if( highlighted && !active && tooltip_text && tooltip_text[0] != 0 && duration == top_level->get_resources()->tooltip_delay ) { show_tooltip(); - tooltip_done = 1; return 1; } return 0; @@ -207,7 +206,6 @@ int BC_Pan::cursor_enter_event() { if(is_event_win() && !highlighted) { - tooltip_done = 0; highlighted = 1; draw(1, 1); } diff --git a/cinelerra-5.1/guicast/bcpopupmenu.C b/cinelerra-5.1/guicast/bcpopupmenu.C index 4c424ae5..6a8c63e2 100644 --- a/cinelerra-5.1/guicast/bcpopupmenu.C +++ b/cinelerra-5.1/guicast/bcpopupmenu.C @@ -355,12 +355,11 @@ int BC_PopupMenu::focus_out_event() int BC_PopupMenu::repeat_event(int64_t duration) { - if( status == BUTTON_HI && !tooltip_done && + if( status == BUTTON_HI && tooltip_text && tooltip_text[0] != 0 && duration == top_level->get_resources()->tooltip_delay ) { show_tooltip(); - tooltip_done = 1; return 1; } return 0; @@ -485,7 +484,6 @@ int BC_PopupMenu::cursor_enter_event() { if(is_event_win() && use_title) { - tooltip_done = 0; if(top_level->button_down) { status = BUTTON_DN; diff --git a/cinelerra-5.1/guicast/bcpot.C b/cinelerra-5.1/guicast/bcpot.C index d9cb1594..7417e79e 100644 --- a/cinelerra-5.1/guicast/bcpot.C +++ b/cinelerra-5.1/guicast/bcpot.C @@ -247,7 +247,6 @@ int BC_Pot::repeat_event(int64_t duration) } else show_tooltip(); - tooltip_done = 1; } return 1; } @@ -291,7 +290,6 @@ int BC_Pot::cursor_enter_event() { if(top_level->event_win == win && enabled) { - tooltip_done = 0; if(!top_level->button_down && status == POT_UP) { status = POT_HIGH; diff --git a/cinelerra-5.1/guicast/bcresources.C b/cinelerra-5.1/guicast/bcresources.C index 7f803ec0..6e8e1ca7 100644 --- a/cinelerra-5.1/guicast/bcresources.C +++ b/cinelerra-5.1/guicast/bcresources.C @@ -968,25 +968,25 @@ int BC_Resources::init_fontconfig(const char *search_path) } if(!strcasecmp(entry->swidth, "normal")) - entry->style = FL_WIDTH_NORMAL; + entry->style |= FL_WIDTH_NORMAL; else if(!strcasecmp(entry->swidth, "ultracondensed")) - entry->style = FL_WIDTH_ULTRACONDENSED; + entry->style |= FL_WIDTH_ULTRACONDENSED; else if(!strcasecmp(entry->swidth, "extracondensed")) - entry->style = FL_WIDTH_EXTRACONDENSED; + entry->style |= FL_WIDTH_EXTRACONDENSED; else if(!strcasecmp(entry->swidth, "condensed")) - entry->style = FL_WIDTH_CONDENSED; + entry->style |= FL_WIDTH_CONDENSED; else if(!strcasecmp(entry->swidth, "semicondensed")) - entry->style = FL_WIDTH_SEMICONDENSED; + entry->style |= FL_WIDTH_SEMICONDENSED; else if(!strcasecmp(entry->swidth, "semiexpanded")) - entry->style = FL_WIDTH_SEMIEXPANDED; + entry->style |= FL_WIDTH_SEMIEXPANDED; else if(!strcasecmp(entry->swidth, "expanded")) - entry->style = FL_WIDTH_EXPANDED; + entry->style |= FL_WIDTH_EXPANDED; else if(!strcasecmp(entry->swidth, "extraexpanded")) - entry->style = FL_WIDTH_EXTRAEXPANDED; + entry->style |= FL_WIDTH_EXTRAEXPANDED; else if(!strcasecmp(entry->swidth, "ultraexpanded")) - entry->style = FL_WIDTH_ULTRAEXPANDED; + entry->style |= FL_WIDTH_ULTRAEXPANDED; else - entry->style = FL_WIDTH_NORMAL; + entry->style |= FL_WIDTH_NORMAL; fontlist->append(entry); // printf("TitleMain::build_fonts %s: success\n", entry->path); diff --git a/cinelerra-5.1/guicast/bcslider.C b/cinelerra-5.1/guicast/bcslider.C index fdb0c030..79283d29 100644 --- a/cinelerra-5.1/guicast/bcslider.C +++ b/cinelerra-5.1/guicast/bcslider.C @@ -208,7 +208,6 @@ int BC_Slider::repeat_event(int64_t duration) set_tooltip(get_caption()); show_tooltip(); } - tooltip_done = 1; return 1; } } @@ -256,7 +255,6 @@ int BC_Slider::cursor_enter_event() //printf("BC_Slider::cursor_enter_event 1\n"); if(top_level->event_win == win && status == SLIDER_UP) { - tooltip_done = 0; status = SLIDER_HI; draw_face(1); } diff --git a/cinelerra-5.1/guicast/bctextbox.C b/cinelerra-5.1/guicast/bctextbox.C index 78c51e00..6916f2e1 100644 --- a/cinelerra-5.1/guicast/bctextbox.C +++ b/cinelerra-5.1/guicast/bctextbox.C @@ -753,7 +753,6 @@ int BC_TextBox::cursor_enter_event() if( top_level->event_win == win && enabled && !(top_level->get_resources()->textbox_focus_policy & CLICK_ACTIVATE) ) { - tooltip_done = 0; if( !active ) { top_level->deactivate(); activate(); @@ -1014,7 +1013,6 @@ int BC_TextBox::repeat_event(int64_t duration) tooltip_text && tooltip_text[0] != 0 && highlighted) { show_tooltip(); - tooltip_done = 1; result = 1; } @@ -2455,6 +2453,16 @@ int BC_PopupTextBox::get_h() return textbox->get_h(); } +int BC_PopupTextBox::get_show_query() +{ + return listbox->get_show_query(); +} + +void BC_PopupTextBox::set_show_query(int v) +{ + listbox->set_show_query(v); +} + int BC_PopupTextBox::handle_event() { return 1; diff --git a/cinelerra-5.1/guicast/bctextbox.h b/cinelerra-5.1/guicast/bctextbox.h index c8e2a71a..a46661cd 100644 --- a/cinelerra-5.1/guicast/bctextbox.h +++ b/cinelerra-5.1/guicast/bctextbox.h @@ -322,6 +322,9 @@ public: int get_y(); int get_w(); int get_h(); + int get_show_query(); + void set_show_query(int v); + void update(const char *text); void update_list(ArrayList *data); void reposition_window(int x, int y); diff --git a/cinelerra-5.1/guicast/bctoggle.C b/cinelerra-5.1/guicast/bctoggle.C index 3d82b78c..11554673 100644 --- a/cinelerra-5.1/guicast/bctoggle.C +++ b/cinelerra-5.1/guicast/bctoggle.C @@ -273,12 +273,11 @@ void BC_Toggle::set_status(int value) int BC_Toggle::repeat_event(int64_t duration) { - if(tooltip_text && tooltip_text[0] != 0 && !tooltip_done && + if(tooltip_text && tooltip_text[0] != 0 && duration == top_level->get_resources()->tooltip_delay && (status == BC_Toggle::TOGGLE_UPHI || status == BC_Toggle::TOGGLE_CHECKEDHI)) { show_tooltip(); - tooltip_done = 1; return 1; } return 0; @@ -288,7 +287,6 @@ int BC_Toggle::cursor_enter_event() { if(top_level->event_win == win && enabled) { - tooltip_done = 0; if(top_level->button_down) status = BC_Toggle::TOGGLE_DOWN; else diff --git a/cinelerra-5.1/guicast/bctumble.C b/cinelerra-5.1/guicast/bctumble.C index 7dd78161..e95f8abb 100644 --- a/cinelerra-5.1/guicast/bctumble.C +++ b/cinelerra-5.1/guicast/bctumble.C @@ -130,10 +130,9 @@ int BC_Tumbler::repeat_event(int64_t duration) if(duration == top_level->get_resources()->tooltip_delay) { if(tooltip_text && tooltip_text[0] != 0 && - status == TUMBLE_UPHI && !tooltip_done) + status == TUMBLE_UPHI) { show_tooltip(); - tooltip_done = 1; return 1; } } @@ -163,7 +162,6 @@ int BC_Tumbler::cursor_enter_event() { if(top_level->event_win == win) { - tooltip_done = 0; if(! top_level->button_down && status == TUMBLE_UP) { status = TUMBLE_UPHI; diff --git a/cinelerra-5.1/guicast/bcwindowbase.C b/cinelerra-5.1/guicast/bcwindowbase.C index 823d81aa..e4a0ef6b 100644 --- a/cinelerra-5.1/guicast/bcwindowbase.C +++ b/cinelerra-5.1/guicast/bcwindowbase.C @@ -302,7 +302,6 @@ int BC_WindowBase::initialize() force_tooltip = 0; // next_repeat_id = 0; tooltip_popup = 0; - tooltip_done = 0; current_font = MEDIUMFONT; current_color = BLACK; current_cursor = ARROW_CURSOR; @@ -1771,69 +1770,54 @@ int BC_WindowBase::dispatch_drag_motion() } - - - -int BC_WindowBase::show_tooltip(int w, int h) +int BC_WindowBase::show_tooltip(const char *text, int x, int y, int w, int h) { - Window tempwin; - - if(tooltip_text && !tooltip_on && - (force_tooltip || get_resources()->tooltips_enabled)) - { - int x, y; +// default text + int forced = !text ? force_tooltip : 1; + if( !text ) text = tooltip_text; + if( !text || (!forced && !get_resources()->tooltips_enabled) ) { top_level->hide_tooltip(); - + return 1; + } +// default w,h + if(w < 0) w = get_text_width(MEDIUMFONT, text) + TOOLTIP_MARGIN * 2; + if(h < 0) h = get_text_height(MEDIUMFONT, text) + TOOLTIP_MARGIN * 2; +// default x,y (win relative) + if( x < 0 ) x = get_w(); + if( y < 0 ) y = get_h(); + int wx, wy; + get_root_coordinates(x, y, &wx, &wy); +// keep the tip inside the window/display + int x0 = top_level->get_x(), x1 = x0 + top_level->get_w(); + int x2 = top_level->get_screen_x(0, -1) + top_level->get_screen_w(0, -1); + if( x1 > x2 ) x1 = x2; + if( wx < x0 ) wx = x0; + if( wx >= (x1-=w) ) wx = x1; + int y0 = top_level->get_y(), y1 = y0 + top_level->get_h(); + int y2 = top_level->get_root_h(0); + if( y1 > y2 ) y1 = y2; + if( wy < y0 ) wy = y0; + if( wy >= (y1-=h) ) wy = y1; +// avoid tip under cursor (flickers) + int abs_x, abs_y; + get_abs_cursor_xy(abs_x,abs_y, 0); + if( wx < abs_x && abs_x < wx+w && wy < abs_y && abs_y < wy+h ) { + if( wx-abs_x < wy-abs_y ) + wx = abs_x+1; + else + wy = abs_y+1; + } + if( !tooltip_on ) { tooltip_on = 1; - if(w < 0) - w = get_text_width(MEDIUMFONT, tooltip_text); - - if(h < 0) - h = get_text_height(MEDIUMFONT, tooltip_text); - - w += TOOLTIP_MARGIN * 2; - h += TOOLTIP_MARGIN * 2; - - XTranslateCoordinates(top_level->display, win, - top_level->rootwin, get_w(), get_h(), - &x, &y, &tempwin); - // keep the tip inside the window/display - int top_x = top_level->get_x(); - if( x < top_x ) x = top_x; - int top_w = top_x + top_level->get_w(); - int lmt_w = top_level->get_screen_x(0, -1) + top_level->get_screen_w(0, -1); - if( top_w < lmt_w ) lmt_w = top_w; - if( x+w > lmt_w ) x = lmt_w-w; - if( x < 0 ) x = 0; - int top_y = top_level->get_y(); - if( y < top_y ) y = top_y; - int top_h = top_y + top_level->get_h(); - int lmt_h = top_level->get_root_h(0); - if( top_h < lmt_h ) lmt_h = top_h; - if( y+h > lmt_h ) y = lmt_h-h; - if( y < 0 ) y = 0; - int abs_x, abs_y, win_x, win_y; - unsigned int temp_mask; - Window temp_win; - XQueryPointer(top_level->display, top_level->win, - &temp_win, &temp_win, &abs_x, &abs_y, - &win_x, &win_y, &temp_mask); - // check for cursor inside popup - if( x < abs_x && abs_x < x+w && y < abs_y && abs_y < y+h ) - { - if( x-abs_x < y-abs_y ) - x = abs_x+1; - else - y = abs_y+1; - } - tooltip_popup = new BC_Popup(top_level, x, y, w, h, - get_resources()->tooltip_bg_color); - - draw_tooltip(); - tooltip_popup->set_font(MEDIUMFONT); - tooltip_popup->flash(); - tooltip_popup->flush(); + tooltip_popup = new BC_Popup(top_level, wx, wy, w, h, + get_resources()->tooltip_bg_color); } + else + tooltip_popup->reposition_window(wx, wy, w, h); + + draw_tooltip(text); + tooltip_popup->flash(); + tooltip_popup->flush(); return 0; } @@ -1871,11 +1855,6 @@ int BC_WindowBase::set_tooltip(const char *text) } return 0; } -void BC_WindowBase::set_tooltip_done(int v) -{ - tooltip_done = v; -} - // signal the event handler to repeat int BC_WindowBase::set_repeat(int64_t duration) { @@ -3398,26 +3377,6 @@ void BC_WindowBase::ungrab_cursor() XUndefineCursor(top_level->display, top_level->rootwin); } -int BC_WindowBase::get_w() -{ - return w; -} - -int BC_WindowBase::get_h() -{ - return h; -} - -int BC_WindowBase::get_x() -{ - return x; -} - -int BC_WindowBase::get_y() -{ - return y; -} - // for get_root_w/h // WidthOfScreen/HeightOfScreen of XDefaultScreenOfDisplay // this is the bounding box of all the screens diff --git a/cinelerra-5.1/guicast/bcwindowbase.h b/cinelerra-5.1/guicast/bcwindowbase.h index 767427dc..891daf06 100644 --- a/cinelerra-5.1/guicast/bcwindowbase.h +++ b/cinelerra-5.1/guicast/bcwindowbase.h @@ -269,10 +269,10 @@ public: void add_keyboard_listener(int(BC_WindowBase::*handler)(BC_WindowBase *)); void del_keyboard_listener(int(BC_WindowBase::*handler)(BC_WindowBase *)); // Dimensions - virtual int get_w(); - virtual int get_h(); - virtual int get_x(); - virtual int get_y(); + virtual int get_w() { return w; } + virtual int get_h() { return h; } + virtual int get_x() { return x; } + virtual int get_y() { return y; } int get_root_w(int lock_display); int get_root_h(int lock_display); XineramaScreenInfo *get_xinerama_info(int screen); @@ -514,8 +514,8 @@ public: int unset_repeat(int64_t duration); const char *get_tooltip(); int set_tooltip(const char *text); - void set_tooltip_done(int v); - int show_tooltip(int w = -1, int h = -1); + virtual int show_tooltip(const char *text, int x=-1, int y=-1, int w = -1, int h = -1); + int show_tooltip(int w=-1, int h=-1) { return show_tooltip(0, -1, -1, w, h); } int hide_tooltip(); int set_icon(VFrame *data); int load_defaults(BC_Hash *defaults); @@ -583,7 +583,7 @@ private: int trigger_tooltip(); int untrigger_tooltip(); - void draw_tooltip(); + void draw_tooltip(const char *text=0); static XEvent *new_xevent(); // delete all repeater opjects for a close int unset_all_repeaters(); @@ -730,7 +730,6 @@ private: // Popup window for tooltip BC_Popup *tooltip_popup; // If this subwindow has already shown a tooltip since the last EnterNotify - int tooltip_done; int options; int flash_enabled; diff --git a/cinelerra-5.1/guicast/bcwindowdraw.C b/cinelerra-5.1/guicast/bcwindowdraw.C index e95b0402..52b7f837 100644 --- a/cinelerra-5.1/guicast/bcwindowdraw.C +++ b/cinelerra-5.1/guicast/bcwindowdraw.C @@ -1117,9 +1117,11 @@ void BC_WindowBase::draw_vframe(VFrame *frame, pixmap); } -void BC_WindowBase::draw_tooltip() +void BC_WindowBase::draw_tooltip(const char *text) { - if(tooltip_popup && tooltip_text) + if( !text ) + text = tooltip_text; + if(tooltip_popup && text) { int w = tooltip_popup->get_w(), h = tooltip_popup->get_h(); tooltip_popup->set_color(get_resources()->tooltip_bg_color); @@ -1129,7 +1131,7 @@ void BC_WindowBase::draw_tooltip() tooltip_popup->set_font(MEDIUMFONT); tooltip_popup->draw_text(TOOLTIP_MARGIN, get_text_ascent(MEDIUMFONT) + TOOLTIP_MARGIN, - tooltip_text); + text); } } diff --git a/cinelerra-5.1/plugins/titler/titler.C b/cinelerra-5.1/plugins/titler/titler.C index b7d8e727..ad9e772f 100644 --- a/cinelerra-5.1/plugins/titler/titler.C +++ b/cinelerra-5.1/plugins/titler/titler.C @@ -1486,13 +1486,15 @@ BC_FontEntry* TitleMain::get_font(const char *font_name, int style) int mask = FL_WEIGHT_MASK | FL_SLANT_MASK; BC_Resources *resources = BC_WindowBase::get_resources(); - return resources->find_fontentry(font_name, flavor, mask, style); + BC_FontEntry *font = resources->find_fontentry(font_name, flavor, mask, style); + if( font && strcmp(font_name, font->displayname) ) font = 0; + return font; } BC_FontEntry* TitleMain::config_font() { BC_FontEntry *font = get_font(config.font, config.style); - if( font && load_font(font) ) - font = get_font(FIXED_FONT,0); + if( !font || load_font(font) ) + load_font(font = get_font(FIXED_FONT,0)); return font; } diff --git a/cinelerra-5.1/plugins/titler/titlerwindow.C b/cinelerra-5.1/plugins/titler/titlerwindow.C index 721bc6a1..3b0894ce 100644 --- a/cinelerra-5.1/plugins/titler/titlerwindow.C +++ b/cinelerra-5.1/plugins/titler/titlerwindow.C @@ -30,6 +30,7 @@ #include "cwindowgui.h" #include "edl.h" #include "edlsession.h" +#include "keys.h" #include "language.h" #include "mwindow.h" #include "plugin.h" @@ -117,6 +118,10 @@ TitleWindow::TitleWindow(TitleMain *client) void TitleWindow::done_event(int result) { ungrab(client->server->mwindow->cwindow->gui); + color_thread->close_window(); + outline_color_thread->close_window(); + color_popup->close_window(); + png_popup->close_window(); } TitleWindow::~TitleWindow() @@ -224,6 +229,7 @@ void TitleWindow::create_objects() add_tool(font_title = new BC_Title(x, y, _("Font:"))); font = new TitleFont(client, this, x, y + font_title->get_h()); font->create_objects(); + font->set_show_query(1); x += font->get_w(); add_subwindow(font_tumbler = new TitleFontTumble(client, this, x, y+margin)); x += font_tumbler->get_w() + margin; @@ -853,7 +859,7 @@ int TitlePitch::handle_event() } TitleColorButton::TitleColorButton(TitleMain *client, TitleWindow *window, int x, int y) - : BC_GenericButton(x, y, _("Color...")) + : BC_GenericButton(x, y, _("Text Color...")) { this->client = client; this->window = window; @@ -970,11 +976,27 @@ int TitleFade::handle_event() void TitleWindow::check_style(const char *font_name) { - BC_FontEntry *font; - font = TitleMain::get_font(font_name, BC_FONT_ITALIC); - strcmp(font_name, font->displayname) ? italic->disable() : italic->enable(); - font = TitleMain::get_font(font_name, BC_FONT_BOLD); - strcmp(font_name, font->displayname) ? bold->disable() : bold->enable(); + BC_FontEntry *font_nrm = TitleMain::get_font(font_name, 0); + BC_FontEntry *font_itl = TitleMain::get_font(font_name, BC_FONT_ITALIC); + BC_FontEntry *font_bld = TitleMain::get_font(font_name, BC_FONT_BOLD); + BC_FontEntry *font_bit = TitleMain::get_font(font_name, BC_FONT_ITALIC | BC_FONT_BOLD); + int has_norm = font_nrm != 0 ? 1 : 0; + int has_ital = font_itl != 0 || font_bit != 0 ? 1 : 0; + int has_bold = font_bld != 0 || font_bit != 0 ? 1 : 0; + if( bold->get_value() ) { + if( !has_bold ) bold->update(0); + } + else { + if( !has_norm && has_bold ) bold->update(1); + } + if( italic->get_value() ) { + if( !has_ital ) italic->update(0); + } + else { + if( !has_norm && has_ital ) italic->update(1); + } + if( has_norm && has_bold ) bold->enable(); else bold->disable(); + if( has_norm && has_ital ) italic->enable(); else italic->disable(); } TitleFont::TitleFont(TitleMain *client, TitleWindow *window, int x, int y) @@ -1236,7 +1258,7 @@ int TitleBottom::handle_event() TitleColorThread::TitleColorThread(TitleMain *client, TitleWindow *window, int is_outline) - : ColorThread(1, _("Text Color")) + : ColorThread(1, is_outline? _("Outline Color") : _("Text Color")) { this->client = client; this->window = window; @@ -1469,10 +1491,23 @@ TitleFontsPopup::TitleFontsPopup(TitleMain *client, TitleWindow *window) this->client = client; this->window = window; set_use_button(0); + set_show_query(1); } TitleFontsPopup::~TitleFontsPopup() { } +int TitleFontsPopup::keypress_event() +{ + switch( get_keypress() ) { + case ESC: + case DELETE: + deactivate(); + return 1; + default: + break; + } + return BC_ListBox::keypress_event(); +} int TitleFontsPopup::handle_event() { @@ -1485,7 +1520,7 @@ int TitleFontsPopup::handle_event() } TitleColorPopup::TitleColorPopup(TitleMain *client, TitleWindow *window) - : ColorThread(0, _("Text Color")) + : ColorThread(0, _("Color")) { this->client = client; this->window = window; diff --git a/cinelerra-5.1/plugins/titler/titlerwindow.h b/cinelerra-5.1/plugins/titler/titlerwindow.h index 5af1c7aa..331b42b0 100644 --- a/cinelerra-5.1/plugins/titler/titlerwindow.h +++ b/cinelerra-5.1/plugins/titler/titlerwindow.h @@ -550,7 +550,11 @@ class TitleFontsPopup : public BC_ListBox public: TitleFontsPopup(TitleMain *client, TitleWindow *window); ~TitleFontsPopup(); + int keypress_event(); int handle_event(); + int show_tooltip(const char *text, int x,int y, int w,int h) { + return gui_tooltip(text); + } TitleMain *client; TitleWindow *window; -- 2.26.2