textbox cursor fix, h265 param files, bluray updates, new-proj theme fixes
[goodguy/history.git] / cinelerra-5.1 / guicast / bcwindowbase.C
index 75e37fb472633a6db03eb7a0d88293d39021a137..7d4fa2b56185dd047d93dc101f5d58546828d810 100644 (file)
@@ -2886,27 +2886,21 @@ int BC_WindowBase::get_text_width(int font, const char *text, int length)
 
 int BC_WindowBase::get_text_width(int font, const wchar_t *text, int length)
 {
-       int i, j, w = 0, line_w = 0;
-
-       if(length < 0) length = wcslen(text);
-
-       for(i = 0, j = 0; i <= length; i++)
-       {
-               line_w = 0;
-               if(text[i] == '\n')
-               {
-                       line_w = get_single_text_width(font, &text[j], i - j);
-                       j = i + 1;
+       int i, j, w = 0;
+       if( length < 0 ) length = wcslen(text);
+
+       for( i=j=0; i<length && text[i]; ++i ) {
+               if( text[i] != '\n' ) continue;
+               if( i > j ) {
+                       int lw = get_single_text_width(font, &text[j], i-j);
+                       if( w < lw ) w = lw;
                }
-               else
-               if(text[i] == 0)
-                       line_w = get_single_text_width(font, &text[j], length - j);
-
-               if(line_w > w) w = line_w;
+               j = i + 1;
+       }
+       if( j < length ) {
+               int lw = get_single_text_width(font, &text[j], length-j);
+               if( w < lw ) w = lw;
        }
-
-       if(i > length && w == 0)
-               w = get_single_text_width(font, text, length);
 
        return w;
 }
@@ -3696,6 +3690,26 @@ int BC_WindowBase::get_abs_cursor_y(int lock_window)
        return abs_y;
 }
 
+int BC_WindowBase::get_pop_cursor_x(int lock_window)
+{
+       int margin = 100;
+       int px = get_abs_cursor_x(lock_window);
+       if( px < margin ) px = margin;
+       int wd = get_screen_w(lock_window,-1) - margin;
+       if( px > wd ) px = wd;
+       return px;
+}
+
+int BC_WindowBase::get_pop_cursor_y(int lock_window)
+{
+       int margin = 100;
+       int py = get_abs_cursor_y(lock_window);
+       if( py < margin ) py = margin;
+       int ht = get_screen_h(lock_window,-1) - margin;
+       if( py > ht ) py = ht;
+       return py;
+}
+
 int BC_WindowBase::match_window(Window win)
 {
        if (this->win == win) return 1;