undo nested clip bug, wheel zoom redraw fix, uninited vars, shortcuts doc
[goodguy/history.git] / cinelerra-5.1 / guicast / bcpopupmenu.C
index d6b4d15eec052d5344cabee197d262920284fca1..4c639fe27d25890f96bd4289cc77c21c651ca569 100644 (file)
@@ -26,7 +26,7 @@
 #include "bcpopupmenu.h"
 #include "bcresources.h"
 #include "bcsignals.h"
-#include "colors.h"
+#include "bccolors.h"
 #include "fonts.h"
 #include <string.h>
 #include "vframe.h"
@@ -67,6 +67,7 @@ BC_PopupMenu::BC_PopupMenu(int x,
        this->data = data;
        this->w_argument = w;
        status = BUTTON_UP;
+       pending = 0;
 }
 
 BC_PopupMenu::BC_PopupMenu(int x,
@@ -88,11 +89,14 @@ BC_PopupMenu::BC_PopupMenu(int x,
        this->data = data;
        this->w_argument = -1;
        status = BUTTON_UP;
+       pending = 0;
 }
 
 BC_PopupMenu::~BC_PopupMenu()
 {
-       if(menu_popup) delete menu_popup;
+       use_title = 0;
+       deactivate();
+       delete menu_popup;
        for(int i = 0; i < TOTAL_IMAGES; i++)
        {
                if(images[i]) delete images[i];
@@ -220,8 +224,7 @@ int BC_PopupMenu::del_item(BC_MenuItem *item)
 
 int BC_PopupMenu::total_items()
 {
-       return menu_popup->total_menuitems();
-       return 0;
+       return menu_popup->total_items();
 }
 
 BC_MenuItem* BC_PopupMenu::get_item(int i)
@@ -286,7 +289,17 @@ int BC_PopupMenu::deactivate()
 
 int BC_PopupMenu::activate_menu()
 {
-       if(!popup_down)
+       if( !get_button_down() || !BC_WindowBase::get_resources()->popupmenu_btnup )
+               return menu_activate();
+       top_level->active_popup_menu = this;
+       pending = 1;
+       return 0;
+}
+
+int BC_PopupMenu::menu_activate()
+{
+       pending = 0;
+       if( !popup_down )
        {
                int x = this->x;
                int y = this->y;
@@ -316,7 +329,7 @@ int BC_PopupMenu::activate_menu()
                popup_down = 1;
                if(use_title) draw_title(1);
        }
-       return 0;
+       return 1;
 }
 
 int BC_PopupMenu::deactivate_menu()
@@ -344,12 +357,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;
@@ -357,6 +369,7 @@ int BC_PopupMenu::repeat_event(int64_t duration)
 
 int BC_PopupMenu::button_press_event()
 {
+       int result = 0;
        if(get_buttonpress() == 1 &&
                is_event_win() &&
                use_title)
@@ -371,10 +384,10 @@ int BC_PopupMenu::button_press_event()
        // Scrolling section
        if (is_event_win()
                && (get_buttonpress() == 4 || get_buttonpress() == 5)
-               && menu_popup->total_menuitems() > 1 )
+               && menu_popup->total_items() > 1 )
        {
                int theval = -1;
-               for (int i = 0; i < menu_popup->total_menuitems(); i++) {
+               for (int i = 0; i < menu_popup->total_items(); i++) {
                        if (!strcmp(menu_popup->menu_items.values[i]->get_text(),get_text())) {
                                theval=i;
                                break;
@@ -387,22 +400,23 @@ int BC_PopupMenu::button_press_event()
 
                if (theval < 0)
                        theval=0;
-               if (theval >= menu_popup->total_menuitems())
-                       theval = menu_popup->total_menuitems() - 1;
+               if (theval >= menu_popup->total_items())
+                       theval = menu_popup->total_items() - 1;
 
                BC_MenuItem *tmp = menu_popup->menu_items.values[theval];
                set_text(tmp->get_text());
-               if (!tmp->handle_event())
-                       this->handle_event();
+               result = tmp->handle_event();
+               if( !result )
+                       result = this->handle_event();
        }
        if(popup_down)
        {
 // Menu is down so dispatch to popup.
                menu_popup->dispatch_button_press();
-               return 1;
+               result = 1;
        }
 
-       return 0;
+       return result;
 }
 
 int BC_PopupMenu::button_release_event()
@@ -420,15 +434,18 @@ int BC_PopupMenu::button_release_event()
                }
        }
 
+       if( pending )
+               return menu_activate();
+
        if( !use_title && status == BUTTON_DN ) {
                result = 1;
        }
-       else if(popup_down) {
+       else if( popup_down && menu_popup->cursor_inside() ) {
 // Menu is down so dispatch to popup.
                result = menu_popup->dispatch_button_release();
        }
 // released outside popup
-       if( !result && popup_down ) {
+       if( get_resources()->popupmenu_btnup && !result && popup_down ) {
                deactivate();
                result = 1;
        }
@@ -456,8 +473,10 @@ int BC_PopupMenu::cursor_leave_event()
 
 // dispatch to popup
        if( popup_down ) {
-               if( !get_button_down() && !menu_popup->cursor_inside() )
-                       deactivate_menu();
+               if( !get_button_down() && !menu_popup->cursor_inside() ) {
+                       status = BUTTON_UP;
+//                     deactivate_menu();
+               }
                menu_popup->dispatch_cursor_leave();
        }
 
@@ -469,7 +488,6 @@ int BC_PopupMenu::cursor_enter_event()
 {
        if(is_event_win() && use_title)
        {
-               tooltip_done = 0;
                if(top_level->button_down)
                {
                        status = BUTTON_DN;
@@ -488,25 +506,19 @@ int BC_PopupMenu::cursor_motion_event()
        int result = 0;
 
 // This menu is down.
-       if(popup_down)
-       {
+       if(popup_down) {
                result = menu_popup->dispatch_motion_event();
        }
 
-       if(!result && use_title && top_level->event_win == win)
-       {
-               if(highlighted)
-               {
-                       if(cursor_inside())
-                       {
+       if(!result && use_title && is_event_win()) {
+               if(highlighted) {
+                       if(!cursor_inside()) {
                                highlighted = 0;
                                draw_title(1);
                        }
                }
-               else
-               {
-                       if(cursor_inside())
-                       {
+               else {
+                       if(cursor_inside()) {
                                highlighted = 1;
                                draw_title(1);
                                result = 1;