Index: ../../../src/preferences/media/MediaViews.h =================================================================== --- ../../../src/preferences/media/MediaViews.h (revision 30132) +++ ../../../src/preferences/media/MediaViews.h (working copy) @@ -30,7 +30,8 @@ class BarView : public BView { public: - BarView(BRect frame); + //BarView(BRect frame); + BarView(); virtual void Draw(BRect updateRect); bool fDisplay; }; @@ -58,7 +59,8 @@ class SettingsView : public BView { public: - SettingsView(BRect frame, bool isVideo); + //SettingsView(BRect frame, bool isVideo); + SettingsView(bool isVideo); void AddNodes(BList &list, bool isInput); void SetDefault(dormant_node_info &info, bool isInput, int32 outputID = -1); BCheckBox *fRealtimeCheckBox; Index: ../../../src/preferences/media/MediaWindow.cpp =================================================================== --- ../../../src/preferences/media/MediaWindow.cpp (revision 30132) +++ ../../../src/preferences/media/MediaWindow.cpp (working copy) @@ -193,38 +193,51 @@ BRect barRect(titleRect.left, titleRect.bottom + 10, titleRect.right - 2, titleRect.bottom + 11); - fListView = new BListView(menuRect, "media_list_view", - B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES); + //fListView = new BListView(menuRect, "media_list_view", + // B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES); + fListView = new BListView("media_list_view", + B_SINGLE_SELECTION_LIST); fListView->SetSelectionMessage(new BMessage(ML_SELECTED_NODE)); // Add ScrollView to Media Menu BScrollView *scrollView = new BScrollView("listscroller", - fListView, B_FOLLOW_LEFT|B_FOLLOW_TOP_BOTTOM, 0, false, false, + fListView, 0, false, false, B_FANCY_BORDER); scrollView->SetExplicitMinSize(BSize(scrollWidth, B_SIZE_UNSET)); scrollView->SetExplicitMaxSize(BSize(scrollWidth, B_SIZE_UNSET)); // Create the Views - fBox = new BBox(bounds, "background", B_FOLLOW_ALL_SIDES, - B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER); + //fBox = new BBox(bounds, "background", B_FOLLOW_ALL_SIDES, + // B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER); + fBox = new BBox("background", B_WILL_DRAW | B_FRAME_EVENTS, + B_PLAIN_BORDER); SetLayout(new BGroupLayout(B_HORIZONTAL)); GetLayout()->AddView(fBox); // StringViews rgb_color titleFontColor = { 0,0,0,0 }; - fTitleView = new BStringView(titleRect, "AudioSettings", - "Audio Settings", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); + //fTitleView = new BStringView(titleRect, "AudioSettings", + // "Audio Settings", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); + fTitleView = new BStringView("AudioSettings", "Audio Settings", + B_WILL_DRAW); fTitleView->SetFont(be_bold_font); fTitleView->SetHighColor(titleFontColor); - fContentView = new BBox(availableRect, "contentView", - B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS, B_NO_BORDER); + //fContentView = new BBox(availableRect, "contentView", + // B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS, B_NO_BORDER); + fContentView = new BBox("contentView", B_WILL_DRAW | B_FRAME_EVENTS, + B_NO_BORDER); + fContentView->SetExplicitMinSize(BSize(B_SIZE_UNSET, B_SIZE_UNSET)); + fContentView->SetExplicitMaxSize(BSize(B_SIZE_UNSET, B_SIZE_UNSET)); BRect settingsRect(0, 0, availableRect.Width(), availableRect.Height()); - fAudioView = new SettingsView(settingsRect, false); - fVideoView = new SettingsView(settingsRect, true); + //fAudioView = new SettingsView(settingsRect, false); + //fVideoView = new SettingsView(settingsRect, true); + fAudioView = new SettingsView(false); + fVideoView = new SettingsView(true); - fBar = new BarView(barRect); + //fBar = new BarView(barRect); + fBar = new BarView(); BGroupView* titleGroupView = new BGroupView(B_HORIZONTAL); titleGroupView->GroupLayout()->AddView(fTitleView); titleGroupView->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue()); @@ -621,7 +634,7 @@ if (roster->GetParameterWebFor(*fCurrentNode, &fParamWeb)==B_OK && (paramView = BMediaTheme::PreferredTheme()->ViewFor(fParamWeb)) != NULL) { fContentView->AddChild(paramView); - paramView->ResizeTo(fContentView->Bounds().Width(), fContentView->Bounds().Height() - 10); + //paramView->ResizeTo(fContentView->Bounds().Width(), fContentView->Bounds().Height() - 10); roster->StartWatching(this, *fCurrentNode, B_MEDIA_WILDCARD); } else { Index: ../../../src/preferences/media/MediaViews.cpp =================================================================== --- ../../../src/preferences/media/MediaViews.cpp (revision 30132) +++ ../../../src/preferences/media/MediaViews.cpp (working copy) @@ -31,8 +31,10 @@ #include "MediaViews.h" -BarView::BarView(BRect frame) - : BView (frame, "barView", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW ), +//BarView::BarView(BRect frame) + //: BView (frame, "barView", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW ), +BarView::BarView() + : BView ("barView", B_WILL_DRAW ), fDisplay(true) { } @@ -56,18 +58,21 @@ } -SettingsView::SettingsView (BRect frame, bool isVideo) - : BView (frame, "SettingsView", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW ), +//SettingsView::SettingsView (BRect frame, bool isVideo) +// : BView (frame, "SettingsView", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW ), +SettingsView::SettingsView (bool isVideo) + : BView ("SettingsView", B_WILL_DRAW ), fIsVideo(isVideo) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - BRect rect(frame); - rect.left += 10; - rect.top += 12; - rect.right -=21; - rect.bottom = rect.top + 104; - BBox *defaultsBox = new BBox(rect, "defaults"); +// BRect rect(frame); +// rect.left += 10; +// rect.top += 12; +// rect.right -=21; +// rect.bottom = rect.top + 104; +// BBox *defaultsBox = new BBox(rect, "defaults"); + BBox *defaultsBox = new BBox("defaults"); defaultsBox->SetLabel(fIsVideo ? "Default Nodes" : "Defaults"); // create the default box @@ -124,15 +129,17 @@ fRestartView->Hide(); // create the realtime box - rect.top = rect.bottom + 10; - rect.bottom = rect.top + 162; - BBox *realtimeBox = new BBox(rect, "realtime"); + //rect.top = rect.bottom + 10; + //rect.bottom = rect.top + 162; + //BBox *realtimeBox = new BBox(rect, "realtime"); + BBox *realtimeBox = new BBox("realtime"); realtimeBox->SetLabel("Real-Time"); BMessage *message = new BMessage(ML_ENABLE_REAL_TIME); message->AddBool("isVideo", fIsVideo); - BRect rect2(22,20, frame.Width() - 22, 40); - fRealtimeCheckBox = new BCheckBox(rect2, "realtimeCheckBox", + //BRect rect2(22,20, frame.Width() - 22, 40); + //fRealtimeCheckBox = new BCheckBox(rect2, "realtimeCheckBox", + fRealtimeCheckBox = new BCheckBox("realtimeCheckBox", fIsVideo ? "Enable Real-Time Video" : "Enable Real-Time Audio", message); uint32 flags; @@ -140,10 +147,11 @@ if (flags & (fIsVideo ? B_MEDIA_REALTIME_VIDEO : B_MEDIA_REALTIME_AUDIO)) fRealtimeCheckBox->SetValue(B_CONTROL_ON); - rect2.top += 26; - rect2.bottom = rect.Height() - 5; - BRect textRect(3, 3, rect2.Width() - 3, rect2.Height() - 3); - BTextView *textView = new BTextView(rect2, "stringView", textRect, B_FOLLOW_ALL, B_WILL_DRAW); + //rect2.top += 26; + //rect2.bottom = rect.Height() - 5; + //BRect textRect(3, 3, rect2.Width() - 3, rect2.Height() - 3); + //BTextView *textView = new BTextView(rect2, "stringView", textRect, B_FOLLOW_ALL, B_WILL_DRAW); + BTextView *textView = new BTextView("stringView", B_WILL_DRAW); textView->Insert(fIsVideo ? "Enabling Real-Time Video allows system to perform video operations as fast and smoothly as possible. It achieves optimum performance by using more RAM." "\n\nOnly enable this feature if you need the lowest latency possible." : "Enabling Real-time Audio allows system to record and play audio as fast as possible. It achieves this performance by using more CPU and RAM." @@ -163,19 +171,21 @@ // create the bottom line: volumen in deskbar checkbox and restart button BGroupView* bottomView = new BGroupView(B_HORIZONTAL); - rect.top = rect.bottom + 11; - rect.bottom = rect.top + 20; - rect.left = rect.right - StringWidth("Restart Media Services") - 20; - BButton *restartButton = new BButton(rect, "restartButton", + //rect.top = rect.bottom + 11; + //rect.bottom = rect.top + 20; + //rect.left = rect.right - StringWidth("Restart Media Services") - 20; + //BButton *restartButton = new BButton(rect, "restartButton", + BButton *restartButton = new BButton("restartButton", "Restart Media Services", new BMessage(ML_RESTART_MEDIA_SERVER)); if (!fIsVideo) { - rect.right = rect.left - 10; - rect.top += 4; - rect.left = frame.left + 33; - if (StringWidth("Show Volume Control on Deskbar") > rect.Width() - 30) - rect.left -= 10; - fVolumeCheckBox = new BCheckBox(rect, "volumeCheckBox", + //rect.right = rect.left - 10; + //rect.top += 4; + //rect.left = frame.left + 33; + //if (StringWidth("Show Volume Control on Deskbar") > rect.Width() - 30) + // rect.left -= 10; + //fVolumeCheckBox = new BCheckBox(rect, "volumeCheckBox", + fVolumeCheckBox = new BCheckBox("volumeCheckBox", "Show Volume Control on Deskbar", new BMessage(ML_SHOW_VOLUME_CONTROL)); bottomView->GroupLayout()->AddView(fVolumeCheckBox); if (BDeskbar().HasItem("MediaReplicant")) Index: ../../../src/kits/media/DefaultMediaTheme.cpp =================================================================== --- ../../../src/kits/media/DefaultMediaTheme.cpp (revision 30132) +++ ../../../src/kits/media/DefaultMediaTheme.cpp (working copy) @@ -21,6 +21,10 @@ #include #include #include +#include +#include +#include +#include #include "debug.h" @@ -30,7 +34,7 @@ namespace BPrivate { -class DynamicScrollView : public BView { +class DynamicScrollView : public BGroupView { public: DynamicScrollView(const char *name, BView *target); virtual ~DynamicScrollView(); @@ -52,31 +56,20 @@ bool fIsDocumentScroller; }; -class GroupView : public BView { +class GroupView : public BGroupView { public: - GroupView(BRect frame, const char *name); + GroupView(const char *name, enum orientation orientation, float spacing); virtual ~GroupView(); - - virtual void AttachedToWindow(); - virtual void AllAttached(); - virtual void GetPreferredSize(float *_width, float *_height); - - virtual BSize MinSize(); - virtual BSize MaxSize(); - virtual BSize PreferredSize(); - - void SetContentBounds(BRect bounds); - BRect ContentBounds() const { return fContentBounds; } - - private: - BRect fContentBounds; }; class TabView : public BTabView { public: - TabView(BRect frame, const char *name, button_width width = B_WIDTH_FROM_LABEL, - uint32 resizingMode = B_FOLLOW_ALL, uint32 flags = B_FULL_UPDATE_ON_RESIZE - | B_WILL_DRAW | B_NAVIGABLE_JUMP | B_FRAME_EVENTS | B_NAVIGABLE); + //TabView(BRect frame, const char *name, button_width width = B_WIDTH_FROM_LABEL, + // uint32 resizingMode = B_FOLLOW_ALL, uint32 flags = B_FULL_UPDATE_ON_RESIZE + // | B_WILL_DRAW | B_NAVIGABLE_JUMP | B_FRAME_EVENTS | B_NAVIGABLE); + TabView(const char *name, button_width width = B_WIDTH_FROM_LABEL, + uint32 flags = B_FULL_UPDATE_ON_RESIZE | B_WILL_DRAW + | B_NAVIGABLE_JUMP | B_FRAME_EVENTS | B_NAVIGABLE); virtual void FrameResized(float width, float height); virtual void Select(int32 tab); @@ -88,18 +81,22 @@ virtual ~SeparatorView(); virtual void Draw(BRect updateRect); + virtual void GetPreferredSize(float *width, float *height); + virtual BSize MaxSize(); private: + BRect fBounds; bool fVertical; }; class TitleView : public BView { public: - TitleView(BRect frame, const char *title); + TitleView(const char *title); virtual ~TitleView(); virtual void Draw(BRect updateRect); virtual void GetPreferredSize(float *width, float *height); + virtual BSize MaxSize(); private: const char *fTitle; @@ -169,16 +166,17 @@ DynamicScrollView::DynamicScrollView(const char *name, BView *target) - : BView(target->Frame(), name, B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS), + //: BView(target->Frame(), name, B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS), + : BGroupView(B_VERTICAL, 0), fHorizontalScrollBar(NULL), fVerticalScrollBar(NULL), fTarget(target), fIsDocumentScroller(false) { - fContentBounds.Set(-1, -1, -1, -1); + SetName(name), + SetFlags(B_WILL_DRAW | B_FRAME_EVENTS), SetViewColor(fTarget->ViewColor()); - target->MoveTo(B_ORIGIN); - AddChild(target); + GetLayout()->AddView(target); } @@ -206,6 +204,10 @@ void DynamicScrollView::FrameResized(float width, float height) { + + ERROR("DynamicScrollView frame resized in FrameResized to %010dx%010d\n", + int(width), int(height) + ); UpdateBars(); } @@ -249,20 +251,28 @@ // it could have (without the space for the scroll bars) float width, height; - if (fContentBounds == BRect(-1, -1, -1, -1)) + //if (fContentBounds == BRect(-1, -1, -1, -1)) fTarget->GetPreferredSize(&width, &height); - else { - width = fContentBounds.Width(); - height = fContentBounds.Height(); - } + //else { + // width = fContentBounds.Width(); + // height = fContentBounds.Height(); + //} BRect bounds = Bounds(); + + ERROR("DynamicScrollView: Updating bars\n\tTarget: %010dx%010d\n\tScroller: %010dx%010d\n", + int(width), int(height), + int(bounds.Width()), int(bounds.Height()) + ); // do we have to remove a scroll bar? bool horizontal = width > bounds.Width(); bool vertical = height > bounds.Height(); +// for testing +vertical = true; + if (!horizontal && fHorizontalScrollBar != NULL) { RemoveChild(fHorizontalScrollBar); delete fHorizontalScrollBar; @@ -355,10 +365,10 @@ // #pragma mark - - -GroupView::GroupView(BRect frame, const char *name) - : BView(frame, name, B_FOLLOW_NONE, B_WILL_DRAW) +GroupView::GroupView(const char *name, enum orientation orientation, float spacing) + : BGroupView(orientation, spacing) { + SetName(name); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); } @@ -368,66 +378,6 @@ } -void -GroupView::AttachedToWindow() -{ - for (int32 i = CountChildren(); i-- > 0;) { - BControl *control = dynamic_cast(ChildAt(i)); - if (control == NULL) - continue; - - control->SetTarget(control); - } -} - - -void -GroupView::AllAttached() -{ -} - - -void -GroupView::GetPreferredSize(float *_width, float *_height) -{ - if (_width) - *_width = fContentBounds.Width(); - - if (_height) - *_height = fContentBounds.Height(); -} - - -BSize -GroupView::MinSize() -{ - return BSize(100, 100); -} - - -BSize -GroupView::PreferredSize() -{ - return MinSize(); -} - - -BSize -GroupView::MaxSize() -{ - BSize max; - GetPreferredSize(&max.width, &max.height); - return max; -} - - -void -GroupView::SetContentBounds(BRect bounds) -{ - fContentBounds = bounds; -} - - // #pragma mark - @@ -438,20 +388,39 @@ * selected (does not take their resize flags into account, though). */ -TabView::TabView(BRect frame, const char *name, button_width width, - uint32 resizingMode, uint32 flags) - : BTabView(frame, name, width, resizingMode, flags) +//TabView::TabView(BRect frame, const char *name, button_width width, +// uint32 resizingMode, uint32 flags) +// : BTabView(frame, name, width, resizingMode, flags) +TabView::TabView(const char *name, button_width width, uint32 flags) + : BTabView(name, width, flags) { } void TabView::FrameResized(float width, float height) -{ +{ BRect rect = Bounds(); rect.top += TabHeight(); rect.InsetBy(3.0f, 3.0f); //ContainerView is inseted by 3.0 in BTabView::_InitObject() + + ERROR("TabView container resized to %010dx%010d\n", + int(rect.Width()), int(rect.Height()) + ); + + BSize minSize = ContainerView()->MinSize(); + BSize maxSize = ContainerView()->MaxSize(); + + ERROR("TabView min/max sizes:\n\t%010dx%010d\n\t%010dx%010d\n", + int(minSize.width), int(minSize.height), + int(maxSize.width), int(maxSize.height) + ); + + // for some reason, at this point MinSize has been set to something + // far greater than available viewing rect - this resets it + ContainerView()->SetExplicitMinSize(BSize(rect.Width(), rect.Height())); + ContainerView()->SetExplicitMaxSize(BSize(rect.Width(), rect.Height())); ContainerView()->ResizeTo(rect.Width(), rect.Height()); } @@ -465,6 +434,20 @@ BView *view = ViewForTab(Selection()); if (view != NULL) { BRect rect = ContainerView()->Bounds(); + + // for some reason, the container view is getting resized after + // FrameResized() - probably something to do with the layout - + // system - and so the above line of code does not work; this + // forces the correct bounds + //BRect rect = Bounds(); + rect.top += TabHeight(); + rect.InsetBy(3.0f, 3.0f); + //ContainerView is inseted by 3.0 in BTabView::_InitObject() + + ERROR("TabView ViewForTab resized to %010dx%010d\n", + int(rect.Width()), int(rect.Height()) + ); + view->ResizeTo(rect.Width(), rect.Height()); } } @@ -474,9 +457,11 @@ SeparatorView::SeparatorView(BRect frame) - : BView(frame, "-", B_FOLLOW_NONE, B_WILL_DRAW) + : BView("-", B_WILL_DRAW) { + fBounds = frame; fVertical = frame.Width() < frame.Height(); + SetViewColor(B_TRANSPARENT_COLOR); } @@ -506,11 +491,33 @@ } +void +SeparatorView::GetPreferredSize(float *_width, float *_height) +{ + if (_width) + *_width = fBounds.right - fBounds.left; + + if (_height) + *_height = fBounds.bottom - fBounds.top; +} + + +BSize +SeparatorView::MaxSize() +{ + float width, height; + GetPreferredSize(&width, &height); + + return BLayoutUtils::ComposeSize(BSize(width, height), + BSize(width, height)); +} + + // #pragma mark - -TitleView::TitleView(BRect frame, const char *title) - : BView(frame, title, B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW) +TitleView::TitleView(const char *title) + : BView(title, B_WILL_DRAW) { fTitle = strdup(title); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); @@ -555,6 +562,17 @@ } +BSize +TitleView::MaxSize() +{ + float height; + GetPreferredSize(NULL, &height); + + return BLayoutUtils::ComposeSize(BSize(B_SIZE_UNLIMITED, height), + BSize(B_SIZE_UNLIMITED, height)); +} + + // #pragma mark - @@ -798,70 +816,30 @@ if (web == NULL) return NULL; - BRect rect; - if (hintRect) - rect = *hintRect; - - BRect bestRect; - - // do we have more than one attached parameter group? - // if so, use a tabbed view with a tab for each group - TabView *tabView = NULL; if (web->CountGroups() > 1) - tabView = new TabView(rect, "web"); + tabView = new TabView("web"); - rect.OffsetTo(B_ORIGIN); - for (int32 i = 0; i < web->CountGroups(); i++) { BParameterGroup *group = web->GroupAt(i); if (group == NULL) continue; - BView *groupView = MakeViewFor(*group, hintRect ? &rect : NULL); + BView *groupView = MakeViewFor(*group); if (groupView == NULL) continue; - if (GroupView *view = dynamic_cast(groupView)) { - // the top-level group views must not be larger than their hintRect, - // but unlike their children, they should follow all sides when - // their parent is resized - if (hintRect != NULL) - view->ResizeTo(rect.Width() - 10, rect.Height() - 10); - view->SetResizingMode(B_FOLLOW_ALL); - } - if (tabView == NULL) { // if we don't need a container to put that view into, - // we're done here (but the groupView may span over the - // whole hintRect) - if (groupView->Frame().LeftTop() == BPoint(5, 5)) { - // remove insets, as they are not needed - groupView->MoveBy(-5, -5); - groupView->ResizeBy(10, 10); - } + // we're done here return new DynamicScrollView(groupView->Name(), groupView); } - DynamicScrollView *scrollView = new DynamicScrollView(groupView->Name(), groupView); + DynamicScrollView *scrollView = new DynamicScrollView(groupView->Name(), groupView); tabView->AddTab(scrollView); - - if (!hintRect) { - bestRect = bestRect | scrollView->Bounds(); - } } - - if (tabView != NULL) { - // this adjustment must be kept in sync with TabView::FrameResized - bestRect.bottom += tabView->TabHeight(); - bestRect.InsetBy(-3.0,-3.0); - - tabView->ResizeTo(bestRect.Width(), bestRect.Height()); - tabView->FrameResized(bestRect.Width(), bestRect.Height()); - //needed since we're not attached to a window yet - } return tabView; } @@ -871,29 +849,26 @@ DefaultMediaTheme::MakeViewFor(BParameterGroup& group, const BRect* hintRect) { CALLED(); + + ERROR("MakeViewFor^2 called\n"); if (group.Flags() & B_HIDDEN_PARAMETER) return NULL; - BRect rect; - if (hintRect != NULL) - rect = *hintRect; + BGroupView *view = new GroupView(group.Name(), B_VERTICAL, 5); + + BGroupLayout* viewLayout = view->GroupLayout(); + viewLayout->SetInsets(5,5,5,5); - GroupView *view = new GroupView(rect, group.Name()); - // Create the parameter views - but don't add them yet - rect.OffsetTo(B_ORIGIN); - rect.InsetBySelf(5, 5); - BList views; for (int32 i = 0; i < group.CountParameters(); i++) { BParameter *parameter = group.ParameterAt(i); if (parameter == NULL) continue; - BView *parameterView = MakeSelfHostingViewFor(*parameter, - hintRect ? &rect : NULL); + BView *parameterView = MakeSelfHostingViewFor(*parameter); if (parameterView == NULL) continue; @@ -908,22 +883,17 @@ TitleView *titleView = dynamic_cast((BView *)views.ItemAt(0)); if (titleView != NULL) { - view->AddChild(titleView); - rect.OffsetBy(0, titleView->Bounds().Height()); + viewLayout->AddView(titleView); } // Add the sub-group views - rect.right = rect.left + 20; - rect.bottom = rect.top + 20; - float lastHeight = 0; - for (int32 i = 0; i < group.CountGroups(); i++) { BParameterGroup *subGroup = group.GroupAt(i); if (subGroup == NULL) continue; - BView *groupView = MakeViewFor(*subGroup, &rect); + BView *groupView = MakeViewFor(*subGroup); if (groupView == NULL) continue; @@ -932,42 +902,23 @@ BRect separatorRect(groupView->Frame()); separatorRect.left -= 3; separatorRect.right = separatorRect.left + 1; - if (lastHeight > separatorRect.Height()) - separatorRect.bottom = separatorRect.top + lastHeight; - view->AddChild(new SeparatorView(separatorRect)); + viewLayout->AddView(new SeparatorView(separatorRect)); } - view->AddChild(groupView); - - rect.OffsetBy(groupView->Bounds().Width() + 5, 0); - - lastHeight = groupView->Bounds().Height(); - if (lastHeight > rect.Height()) - rect.bottom = rect.top + lastHeight - 1; + viewLayout->AddView(groupView); } - view->ResizeTo(rect.left + 10, rect.bottom + 5); - view->SetContentBounds(view->Bounds()); - if (group.CountParameters() == 0) return view; // add the parameter views part of the group - if (group.CountGroups() > 0) { - rect.top = rect.bottom + 10; - rect.bottom = rect.top + 20; - } - bool center = false; for (int32 i = 0; i < views.CountItems(); i++) { BView *parameterView = static_cast(views.ItemAt(i)); - if (parameterView->Bounds().Width() + 5 > rect.Width()) - rect.right = parameterView->Bounds().Width() + rect.left + 5; - // we don't need to add the title view again if (parameterView == titleView) continue; @@ -977,33 +928,10 @@ if (dynamic_cast(parameterView) != NULL) center = true; - parameterView->MoveTo(parameterView->Frame().left, rect.top); - view->AddChild(parameterView); - - rect.OffsetBy(0, parameterView->Bounds().Height() + 5); + viewLayout->AddView(parameterView); } - if (views.CountItems() > (titleView != NULL ? 1 : 0)) - view->ResizeTo(rect.right + 5, rect.top + 5); - - // center the parameter views if needed, and tweak some views - - float width = view->Bounds().Width(); - - for (int32 i = 0; i < views.CountItems(); i++) { - BView *subView = static_cast(views.ItemAt(i)); - BRect frame = subView->Frame(); - - if (center) - subView->MoveTo((width - frame.Width()) / 2, frame.top); - else { - // tweak the PopUp views to look better - if (dynamic_cast(subView) != NULL) - subView->ResizeTo(width, frame.Height()); - } - } - - view->SetContentBounds(view->Bounds()); + viewLayout->AddItem(BSpaceLayoutItem::CreateGlue()); return view; } @@ -1019,7 +947,7 @@ || parameter_should_be_hidden(parameter)) return NULL; - BView *view = MakeViewFor(¶meter, hintRect); + BView *view = MakeViewFor(¶meter); if (view == NULL) { // The MakeViewFor() method above returns a BControl - which we // don't need for a null parameter; that's why it returns NULL. @@ -1030,15 +958,13 @@ // this is the first parameter in this group, so // let's use a nice title view - TitleView *titleView = new TitleView(BRect(0, 0, 10, 10), parameter.Name()); - titleView->ResizeToPreferred(); + TitleView *titleView = new TitleView(parameter.Name()); return titleView; } - BStringView *stringView = new BStringView(BRect(0, 0, 10, 10), - parameter.Name(), parameter.Name()); + BStringView *stringView = new BStringView(parameter.Name(), + parameter.Name()); stringView->SetAlignment(B_ALIGN_CENTER); - stringView->ResizeToPreferred(); return stringView; } @@ -1058,10 +984,7 @@ DefaultMediaTheme::MakeViewFor(BParameter *parameter, const BRect *hintRect) { BRect rect; - if (hintRect) - rect = *hintRect; - else - rect.Set(0, 0, 50, 100); + rect.Set(0, 0, 50, 100); switch (parameter->Type()) { case BParameter::B_NULL_PARAMETER: @@ -1077,9 +1000,8 @@ || discrete.CountItems() == 0) { // create a checkbox item - BCheckBox *checkBox = new BCheckBox(rect, discrete.Name(), + BCheckBox *checkBox = new BCheckBox(discrete.Name(), discrete.Name(), NULL); - checkBox->ResizeToPreferred(); return checkBox; } else { @@ -1100,14 +1022,13 @@ rect.right = rect.left + width; BOptionPopUp *popUp = new BOptionPopUp(rect, discrete.Name(), + //BOptionPopUp *popUp = new BOptionPopUp(discrete.Name(), discrete.Name(), NULL); for (int32 i = 0; i < discrete.CountItems(); i++) { popUp->AddOption(discrete.ItemNameAt(i), discrete.ItemValueAt(i)); } - popUp->ResizeToPreferred(); - return popUp; } } @@ -1118,7 +1039,8 @@ if (!strcmp(continuous.Kind(), B_MASTER_GAIN) || !strcmp(continuous.Kind(), B_GAIN)) { - BChannelSlider *slider = new BChannelSlider(rect, continuous.Name(), + //BChannelSlider *slider = new BChannelSlider(rect, continuous.Name(), + BChannelSlider *slider = new BChannelSlider(continuous.Name(), continuous.Name(), NULL, B_VERTICAL, continuous.CountChannels()); char minLabel[64], maxLabel[64]; @@ -1134,10 +1056,6 @@ } slider->SetLimitLabels(minLabel, maxLabel); - float width, height; - slider->GetPreferredSize(&width, &height); - slider->ResizeTo(width, 190); - // ToDo: take BContinuousParameter::GetResponse() & ValueStep() into account! for (int32 i = 0; i < continuous.CountChannels(); i++) { @@ -1149,12 +1067,9 @@ } BSlider *slider = new BSlider(rect, parameter->Name(), parameter->Name(), + //BSlider *slider = new BSlider(parameter->Name(), parameter->Name(), NULL, 0, 100); - float width, height; - slider->GetPreferredSize(&width, &height); - slider->ResizeTo(100, height); - return slider; } Index: ../../../headers/private/media/DefaultMediaTheme.h =================================================================== --- ../../../headers/private/media/DefaultMediaTheme.h (revision 30132) +++ ../../../headers/private/media/DefaultMediaTheme.h (working copy) @@ -27,8 +27,8 @@ virtual BView* MakeViewFor(BParameterWeb* web, const BRect* hintRect = NULL); private: - BView* MakeViewFor(BParameterGroup& group, const BRect* hintRect); - BView* MakeSelfHostingViewFor(BParameter& parameter, const BRect* hintRect); + BView* MakeViewFor(BParameterGroup& group, const BRect* hintRect = NULL); + BView* MakeSelfHostingViewFor(BParameter& parameter, const BRect* hintRect = NULL); }; } // namespace BPrivate