add BC_SCALE env var for hi def monitors, cleanup theme data
[goodguy/cinelerra.git] / cinelerra-5.1 / guicast / bcpopupmenu.C
index 13cc6816c3824bef2f8dc643133298db4ff08cd2..62a2b4030e760bfddbf5a8d51400e1ac98afa01f 100644 (file)
@@ -37,8 +37,8 @@
 #define TOTAL_IMAGES 3
 
 
-#define TRIANGLE_W 10
-#define TRIANGLE_H 10
+#define TRIANGLE_W xS(10)
+#define TRIANGLE_H yS(10)
 
 
 BC_PopupMenu::BC_PopupMenu(int x, int y, int w, const char *text,
@@ -118,8 +118,8 @@ int BC_PopupMenu::initialize()
        }
        else {
 // Move outside window if no title
-               x = -10;  y = -10;
-               w = 10;   h = 10;
+               x = -TRIANGLE_W;  y = -TRIANGLE_H;
+               w = TRIANGLE_W;   h = TRIANGLE_H;
        }
 
        BC_SubWindow::initialize();
@@ -149,7 +149,7 @@ int BC_PopupMenu::calculate_w(int margin, int text_width, int use_title)
 {
        BC_Resources *resources = get_resources();
        int l = margin >= 0 ? margin : resources->popupmenu_margin;
-       int r = use_title < 0 ? l : resources->popupmenu_triangle_margin;
+       int r = use_title < 0 ? l : l + resources->popupmenu_triangle_margin;
        return l + text_width + r;
 }
 
@@ -231,9 +231,11 @@ int BC_PopupMenu::draw_face(int dx, int color)
                        get_h()/2 - icon->get_h()/2 + offset);
        }
 
-       if( use_title >= 0 )
-               draw_triangle_down_flat(available_w + margin,
-                       get_h()/2 - TRIANGLE_H/2, TRIANGLE_W, TRIANGLE_H);
+       if( use_title >= 0 ) {
+               int tx = get_w() - margin - get_resources()->popupmenu_triangle_margin;
+               int ty = get_h()/2 - TRIANGLE_H/2;
+               draw_triangle_down_flat(tx, ty, TRIANGLE_W, TRIANGLE_H);
+       }
        return 1;
 }
 
@@ -291,10 +293,12 @@ int BC_PopupMenu::menu_activate()
                                w, h, 0, 1);
                }
                else
-                       menu_popup->activate_menu(x+3, y+3, w, h, 0, 1);
+                       menu_popup->activate_menu(x+xS(3), y+yS(3), w, h, 0, 1);
                popup_down = 1;
                if( use_title ) draw_title(1);
        }
+       else
+               deactivate_menu();
        return 1;
 }
 
@@ -335,9 +339,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 ) {
+       if( get_buttonpress() == 1 && is_event_win() && use_title ) {
                top_level->hide_tooltip();
                if( status == BUTTON_HI || status == BUTTON_UP ) status = BUTTON_DN;
                activate_menu();