Sfoglia il codice sorgente

update UIMenuWindow functionality

JimMarlowe 9 anni fa
parent
commit
fbe5c625c4
2 ha cambiato i file con 9 aggiunte e 22 eliminazioni
  1. 9 20
      Source/Atomic/UI/UIMenuWindow.cpp
  2. 0 2
      Source/Atomic/UI/UIMenuWindow.h

+ 9 - 20
Source/Atomic/UI/UIMenuWindow.cpp

@@ -57,7 +57,11 @@ void UIMenuWindow::Show(UISelectItemSource* source, int x, int y)
 
     source_ = source->GetTBItemSource();
 
-    FixMenu( (TBMenuWindow*)widget_ );  // get rid of scrollbars for menu popups
+    // get rid of scrollbars for menu popups, reconfigure menu container
+    TBScrollContainer *mys = ((TBMenuWindow*)widget_ )->GetList()->GetScrollContainer();
+    mys->SetScrollMode(SCROLL_MODE_OFF);
+    mys->SetAdaptToContentSize(true);
+    mys->SetAdaptContentSize(false);
 
     if (x != -1 && y != -1)
     {
@@ -68,15 +72,12 @@ void UIMenuWindow::Show(UISelectItemSource* source, int x, int y)
         ((TBMenuWindow*)widget_)->Show(source_, TBPopupAlignment());
     }
 
-    TBMenuWindow* src = (TBMenuWindow*)widget_ ;
-    TBSelectList* list = src->GetList();
-
-    int swidth = src->GetRect().w;
-    int num = list->GetNumItems()-1;
+    TBMenuWindow* src = (TBMenuWindow*)widget_; // get rid of scrollbars for menu popups, fix size
+    TBSelectList* list = ((TBMenuWindow*)widget_ )->GetList();
+    int num = list->GetNumItems() - 1;
     int sheight = list->GetItemWidget(num)->GetRect().y + list->GetItemWidget(num)->GetRect().h + 4;
-
     if ( src->GetRect().h != sheight )
-        src->SetSize(swidth, sheight);
+        src->SetSize(src->GetRect().w, sheight);
 
 }
 
@@ -94,16 +95,4 @@ void UIMenuWindow::Close()
 
 }
 
-void UIMenuWindow::FixMenu( tb::TBMenuWindow *mymenu ) // get rid of scrollbars for menu popups
-{
-    if ( mymenu )
-    {
-        TBScrollContainer *mys = mymenu->GetList()->GetScrollContainer();
-        mys->SetScrollMode(SCROLL_MODE_OFF);
-        mys->SetAdaptToContentSize(true);
-        mys->SetAdaptContentSize(false);
-    }
-}
-
-
 }

+ 0 - 2
Source/Atomic/UI/UIMenuWindow.h

@@ -51,8 +51,6 @@ protected:
 private:
 
     tb::TBSelectItemSource* source_;
-    
-    void FixMenu( tb::TBMenuWindow* ); // get rid of scrollbars for menu popups
 
 };