+static void ui_popup_block_clip(wmWindow *window, uiBlock *block)
+{
+ int winx, winy;
+
+ wm_window_get_size(window, &winx, &winy);
+
+ if(block->minx < MENU_SHADOW_SIDE)
+ block->minx= MENU_SHADOW_SIDE;
+ if(block->maxx > winx-MENU_SHADOW_SIDE)
+ block->maxx= winx-MENU_SHADOW_SIDE;
+
+ if(block->miny < MENU_SHADOW_BOTTOM)
+ block->miny= MENU_SHADOW_BOTTOM;
+ if(block->maxy > winy-MENU_TOP)
+ block->maxy= winy-MENU_TOP;
+}
+
+void ui_popup_block_scrolltest(uiBlock *block)
+{
+ uiBut *bt;
+
+ block->flag &= ~(UI_BLOCK_CLIPBOTTOM|UI_BLOCK_CLIPTOP);
+
+ for(bt= block->buttons.first; bt; bt= bt->next)
+ bt->flag &= ~UI_SCROLLED;
+
+ if(block->buttons.first==block->buttons.last)
+ return;
+
+ /* mark buttons that are outside boundary and the ones next to it for arrow(s) */
+ for(bt= block->buttons.first; bt; bt= bt->next) {
+ if(bt->y1 < block->miny) {
+ bt->flag |= UI_SCROLLED;
+ block->flag |= UI_BLOCK_CLIPBOTTOM;
+ /* make space for arrow */
+ if(bt->y2 < block->miny +10) {
+ if(bt->next && bt->next->y1 > bt->y1)
+ bt->next->flag |= UI_SCROLLED;
+ if(bt->prev && bt->prev->y1 > bt->y1)
+ bt->prev->flag |= UI_SCROLLED;
+ }
+ }
+ if(bt->y2 > block->maxy) {
+ bt->flag |= UI_SCROLLED;
+ block->flag |= UI_BLOCK_CLIPTOP;
+ /* make space for arrow */
+ if(bt->y1 > block->maxy -10) {
+ if(bt->next && bt->next->y2 < bt->y2)
+ bt->next->flag |= UI_SCROLLED;
+ if(bt->prev && bt->prev->y2 < bt->y2)
+ bt->prev->flag |= UI_SCROLLED;
+ }
+ }
+ }
+}
+