Small footprint UI library for hardware accelerated games & applications
リビジョン | 80a88ee62c2a6dd29e834e8563c7a492f7edfcd4 (tree) |
---|---|
日時 | 2014-05-01 20:23:24 |
作者 | Emil Segerås <emilsegers@gmai...> |
コミッター | Emil Segerås |
Extracted TBWindow::ResizeToFitContent logic into new method.
@@ -34,7 +34,7 @@ TBWindow::~TBWindow() | ||
34 | 34 | m_mover.RemoveChild(&m_textfield); |
35 | 35 | } |
36 | 36 | |
37 | -void TBWindow::ResizeToFitContent(RESIZE_FIT fit) | |
37 | +TBRect TBWindow::GetResizeToFitContentRect(RESIZE_FIT fit) | |
38 | 38 | { |
39 | 39 | PreferredSize ps = GetPreferredSize(); |
40 | 40 | int new_w = ps.pref_w; |
@@ -54,7 +54,12 @@ void TBWindow::ResizeToFitContent(RESIZE_FIT fit) | ||
54 | 54 | new_w = MIN(new_w, GetParent()->GetRect().w); |
55 | 55 | new_h = MIN(new_h, GetParent()->GetRect().h); |
56 | 56 | } |
57 | - SetRect(TBRect(GetRect().x, GetRect().y, new_w, new_h)); | |
57 | + return TBRect(GetRect().x, GetRect().y, new_w, new_h); | |
58 | +} | |
59 | + | |
60 | +void TBWindow::ResizeToFitContent(RESIZE_FIT fit) | |
61 | +{ | |
62 | + SetRect(GetResizeToFitContentRect(fit)); | |
58 | 63 | } |
59 | 64 | |
60 | 65 | void TBWindow::Close() |
@@ -74,8 +74,12 @@ public: | ||
74 | 74 | RESIZE_FIT_CURRENT_OR_NEEDED ///< Fit the minimal or maximum size only if needed. Will keep |
75 | 75 | ///< the new size as close as possible to the current size. |
76 | 76 | }; |
77 | - /** Resize the window to fit the its content. | |
78 | - It can fit in a few different ways (See RESIZE_FIT). */ | |
77 | + | |
78 | + /** Get a suitable rect for the window based on the contents and the given fit. */ | |
79 | + TBRect GetResizeToFitContentRect(RESIZE_FIT fit = RESIZE_FIT_PREFERRED); | |
80 | + | |
81 | + /** Resize the window to fit the its content. This is the same as doing | |
82 | + SetRect(GetResizeToFitContentRect(fit)). */ | |
79 | 83 | void ResizeToFitContent(RESIZE_FIT fit = RESIZE_FIT_PREFERRED); |
80 | 84 | |
81 | 85 | /** Set the window title. */ |