From c8602bcd111555e5a2c7110f336bb9b2508383c0 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 14 Jun 2009 00:37:07 +0000 Subject: [PATCH] The Media preflet was using a mix of old and layout style primitives to set itself up. As a consequence resizing basically didn't work correctly at all. Fixes ticket #3427. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31038 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/preferences/media/MediaViews.cpp | 72 ++++++++------------------- src/preferences/media/MediaViews.h | 4 +- src/preferences/media/MediaWindow.cpp | 54 +++++--------------- 3 files changed, 37 insertions(+), 93 deletions(-) diff --git a/src/preferences/media/MediaViews.cpp b/src/preferences/media/MediaViews.cpp index bfe95467f2..4a1bd6280f 100644 --- a/src/preferences/media/MediaViews.cpp +++ b/src/preferences/media/MediaViews.cpp @@ -31,8 +31,8 @@ #include "MediaViews.h" -BarView::BarView(BRect frame) - : BView (frame, "barView", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW ), +BarView::BarView() + : BView ("barView", B_WILL_DRAW ), fDisplay(true) { } @@ -56,24 +56,18 @@ BarView::Draw(BRect updateRect) } -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 | B_SUPPORTS_LAYOUT), 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"); + BBox *defaultsBox = new BBox("defaults"); defaultsBox->SetLabel(fIsVideo ? "Default Nodes" : "Defaults"); // create the default box BGroupLayout* defaultBoxLayout = new BGroupLayout(B_VERTICAL, 5); - float inset = defaultsBox->Frame().left - defaultsBox->InnerFrame().left; - defaultBoxLayout->SetInsets(inset, defaultsBox->TopBorderOffset() * 2, inset, inset); + defaultBoxLayout->SetInsets(10,10,10,10); defaultsBox->SetLayout(defaultBoxLayout); defaultBoxLayout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(5)); @@ -82,19 +76,17 @@ SettingsView::SettingsView (BRect frame, bool isVideo) defaultsBox->GetLayout()->AddView(inputField); defaultsBox->GetLayout()->AddView(outputField); - BRect defaultRect(20, 22, 250, 40); float divider = StringWidth(fIsVideo ? "Video Output:" : "Audio Output:") + 5; fMenu1 = new BPopUpMenu(""); fMenu1->SetLabelFromMarked(true); - BMenuField *menuField1 = new BMenuField(defaultRect, "menuField1", - fIsVideo ? "Video Input:" : "Audio Input:", fMenu1); + BMenuField *menuField1 = new BMenuField("menuField1", + fIsVideo ? "Video Input:" : "Audio Input:", fMenu1, NULL); menuField1->SetDivider(divider); - defaultRect.OffsetBy(0, 26); fMenu2 = new BPopUpMenu(""); fMenu2->SetLabelFromMarked(true); - BMenuField *menuField2 = new BMenuField(defaultRect, "menuField2", - fIsVideo ? "Video Output:" : "Audio Output:", fMenu2); + BMenuField *menuField2 = new BMenuField("menuField2", + fIsVideo ? "Video Output:" : "Audio Output:", fMenu2, NULL); menuField2->SetDivider(divider); inputField->GroupLayout()->AddView(menuField1); @@ -102,48 +94,37 @@ SettingsView::SettingsView (BRect frame, bool isVideo) BMenuField *menuField3 = NULL; if (!fIsVideo) { - defaultRect.OffsetBy(186, 0); - defaultRect.right -= 30; fMenu3 = new BPopUpMenu(""); fMenu3->SetLabelFromMarked(true); - menuField3 = new BMenuField(defaultRect, "menuField3", - "Channel:", fMenu3); + menuField3 = new BMenuField("menuField3", + "Channel:", fMenu3, NULL); outputField->GroupLayout()->AddView(menuField3); menuField3->SetDivider(StringWidth("Channel:")+5); - defaultRect.right += 30; - defaultRect.OffsetBy(-186, 0); } - defaultRect.OffsetBy(0, 32); - defaultRect.right += 100; rgb_color red_color = {222, 32, 33}; - fRestartView = new BStringView(defaultRect, "restartStringView", "Restart the Media Server to apply changes.", - B_FOLLOW_ALL, B_WILL_DRAW); + fRestartView = new BStringView("restartStringView", + "Restart the Media Server to apply changes."); fRestartView->SetHighColor(red_color); defaultsBox->AddChild(fRestartView); fRestartView->Hide(); // create the realtime box - 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", - fIsVideo ? "Enable Real-Time Video" : "Enable Real-Time Audio", message); + fRealtimeCheckBox = new BCheckBox("realtimeCheckBox", + fIsVideo ? "Enable Real-Time Video" : "Enable Real-Time Audio", + message); uint32 flags; BMediaRoster::Roster()->GetRealtimeFlags(&flags); 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); + BTextView *textView = new BTextView("stringView"); 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." @@ -153,8 +134,7 @@ SettingsView::SettingsView (BRect frame, bool isVideo) textView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BGroupLayout* realtimeBoxLayout = new BGroupLayout(B_VERTICAL, 5); - inset = realtimeBox->Frame().left - realtimeBox->InnerFrame().left; - realtimeBoxLayout->SetInsets(inset, defaultsBox->TopBorderOffset() * 2, inset, inset); + realtimeBoxLayout->SetInsets(10,10,10,10); realtimeBox->SetLayout(realtimeBoxLayout); realtimeBoxLayout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(5)); @@ -163,19 +143,11 @@ SettingsView::SettingsView (BRect frame, bool isVideo) // 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", + 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", + fVolumeCheckBox = new BCheckBox("volumeCheckBox", "Show Volume Control on Deskbar", new BMessage(ML_SHOW_VOLUME_CONTROL)); bottomView->GroupLayout()->AddView(fVolumeCheckBox); if (BDeskbar().HasItem("MediaReplicant")) diff --git a/src/preferences/media/MediaViews.h b/src/preferences/media/MediaViews.h index 046fd04659..ade76f0826 100644 --- a/src/preferences/media/MediaViews.h +++ b/src/preferences/media/MediaViews.h @@ -30,7 +30,7 @@ const uint32 ML_DEFAULTOUTPUT_CHANGE = 'doch'; class BarView : public BView { public: - BarView(BRect frame); + BarView(); virtual void Draw(BRect updateRect); bool fDisplay; }; @@ -58,7 +58,7 @@ class Settings2Item : public BMenuItem class SettingsView : public BView { public: - 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; diff --git a/src/preferences/media/MediaWindow.cpp b/src/preferences/media/MediaWindow.cpp index 3cf0d33481..7fe37f6036 100644 --- a/src/preferences/media/MediaWindow.cpp +++ b/src/preferences/media/MediaWindow.cpp @@ -35,7 +35,7 @@ const uint32 ML_INIT_MEDIA = 'MlIM'; // MediaWindow - Constructor MediaWindow::MediaWindow(BRect frame) -: BWindow (frame, "Media", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS), +: BWindow (frame, "Media", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), fCurrentNode(NULL), fParamWeb(NULL), fAlert(NULL), @@ -172,59 +172,36 @@ MediaWindow::InitWindow(void) fIcons.AddItem(icon); const float scrollWidth = 9 * be_plain_font->Size() + 30; - const float contentWidth = 34 * be_plain_font->Size(); - float totalWidthFont = scrollWidth + contentWidth + 14 * 3; - const float totalWidth = (605.0 > totalWidthFont) ? - 605.0 : totalWidthFont; - BRect bounds = Bounds(); // the whole view - // Create the OutlineView - font_height titleHeightStruct; - be_bold_font->GetHeight(&titleHeightStruct); - float titleHeight = titleHeightStruct.ascent + titleHeightStruct.descent - + titleHeightStruct.leading + 1; - - BRect menuRect(bounds.left + 14, bounds.top + 14, scrollWidth, - bounds.bottom - 14); - BRect titleRect(menuRect.right + 14, menuRect.top, - totalWidth - 10, menuRect.top + titleHeight); - BRect availableRect(menuRect.right + 15, titleRect.bottom + 12, - totalWidth - 14, bounds.bottom - 16); - 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("media_list_view"); 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, - B_FANCY_BORDER); + 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("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("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("contentView", B_WILL_DRAW | B_FRAME_EVENTS, + B_NO_BORDER); - BRect settingsRect(0, 0, availableRect.Width(), availableRect.Height()); - 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(); BGroupView* titleGroupView = new BGroupView(B_HORIZONTAL); titleGroupView->GroupLayout()->AddView(fTitleView); titleGroupView->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue()); @@ -252,11 +229,6 @@ MediaWindow::InitWindow(void) if (IsHidden()) Show(); } - - // Set window limits - ResizeTo(totalWidth + 14, bounds.Height()); - SetZoomLimits(totalWidth + 14, bounds.Height()); - SetSizeLimits(totalWidth + 14, 100000, bounds.Height(), 100000); } @@ -705,7 +677,7 @@ MediaWindow::UpdateProgress(int stage, const char * message, void * cookie) { MediaAlert *alert = static_cast(cookie); PRINT(("stage : %i\n", stage)); - char *string = "Unknown stage"; + const char *string = "Unknown stage"; switch (stage) { case 10: string = "Stopping Media Server" B_UTF8_ELLIPSIS;