Applied patch by Clemens Zeidler:

* The Media preflet itself is now font sensitive by using the new layout
  management.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24765 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2008-04-03 09:53:24 +00:00
parent 13b895c5c6
commit 2af5f8952c
3 changed files with 125 additions and 46 deletions

View File

@ -19,7 +19,7 @@
Media::Media()
: BApplication("application/x-vnd.Haiku-Media")
{
BRect rect(32,64,637,442);
BRect rect(32,64,637,462);
BPath path;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
@ -51,7 +51,6 @@ Media::Media()
}
fWindow = new MediaWindow(rect);
fWindow->SetSizeLimits(605.0, 10000.0, 378.0, 10000.0);
be_roster->StartWatching(BMessenger(this));
}

View File

@ -26,6 +26,9 @@
#include <MediaAddOn.h>
#include <String.h>
#include <TextView.h>
#include <GroupView.h>
#include <SpaceLayoutItem.h>
#include "MediaViews.h"
BarView::BarView(BRect frame)
@ -55,9 +58,10 @@ BarView::Draw(BRect updateRect)
SettingsView::SettingsView (BRect frame, bool isVideo)
: BView (frame, "SettingsView", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW ),
fIsVideo(isVideo)
fIsVideo(isVideo)
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
BRect rect(frame);
rect.left += 10;
rect.top += 12;
@ -65,33 +69,46 @@ SettingsView::SettingsView (BRect frame, bool isVideo)
rect.bottom = rect.top + 104;
BBox *defaultsBox = new BBox(rect, "defaults");
defaultsBox->SetLabel(fIsVideo ? "Default Nodes" : "Defaults");
AddChild(defaultsBox);
// 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);
defaultsBox->SetLayout(defaultBoxLayout);
defaultBoxLayout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(5));
BGroupView* inputField = new BGroupView(B_HORIZONTAL);
BGroupView* outputField = new BGroupView(B_HORIZONTAL);
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("<none>");
fMenu1->SetLabelFromMarked(true);
BMenuField *menuField1 = new BMenuField(defaultRect, "menuField1",
BMenuField *menuField1 = new BMenuField(defaultRect, "menuField1",
fIsVideo ? "Video Input:" : "Audio Input:", fMenu1);
defaultsBox->AddChild(menuField1);
menuField1->SetDivider(divider);
defaultRect.OffsetBy(0, 26);
fMenu2 = new BPopUpMenu("<none>");
fMenu2->SetLabelFromMarked(true);
BMenuField *menuField2 = new BMenuField(defaultRect, "menuField2",
BMenuField *menuField2 = new BMenuField(defaultRect, "menuField2",
fIsVideo ? "Video Output:" : "Audio Output:", fMenu2);
defaultsBox->AddChild(menuField2);
menuField2->SetDivider(divider);
inputField->GroupLayout()->AddView(menuField1);
outputField->GroupLayout()->AddView(menuField2);
BMenuField *menuField3 = NULL;
if (!fIsVideo) {
defaultRect.OffsetBy(186, 0);
defaultRect.right -= 30;
fMenu3 = new BPopUpMenu("<none>");
fMenu3->SetLabelFromMarked(true);
BMenuField *menuField3 = new BMenuField(defaultRect, "menuField3",
menuField3 = new BMenuField(defaultRect, "menuField3",
"Channel:", fMenu3);
defaultsBox->AddChild(menuField3);
outputField->GroupLayout()->AddView(menuField3);
menuField3->SetDivider(StringWidth("Channel:")+5);
defaultRect.right += 30;
defaultRect.OffsetBy(-186, 0);
@ -100,24 +117,23 @@ SettingsView::SettingsView (BRect frame, bool isVideo)
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.",
fRestartView = new BStringView(defaultRect, "restartStringView", "Restart the Media Server to apply changes.",
B_FOLLOW_ALL, B_WILL_DRAW);
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");
realtimeBox->SetLabel("Real-Time");
AddChild(realtimeBox);
BMessage *message = new BMessage(ML_ENABLE_REAL_TIME);
message->AddBool("isVideo", fIsVideo);
BRect rect2(22,20, 190, 40);
fRealtimeCheckBox = new BCheckBox(rect2, "realtimeCheckBox",
BRect rect2(22,20, frame.Width() - 22, 40);
fRealtimeCheckBox = new BCheckBox(rect2, "realtimeCheckBox",
fIsVideo ? "Enable Real-Time Video" : "Enable Real-Time Audio", message);
realtimeBox->AddChild(fRealtimeCheckBox);
uint32 flags;
BMediaRoster::Roster()->GetRealtimeFlags(&flags);
@ -126,7 +142,6 @@ SettingsView::SettingsView (BRect frame, bool isVideo)
rect2.top += 26;
rect2.bottom = rect.Height() - 5;
rect2.right = rect.right - 15;
BRect textRect(3, 3, rect2.Width() - 3, rect2.Height() - 3);
BTextView *textView = new BTextView(rect2, "stringView", textRect, B_FOLLOW_ALL, B_WILL_DRAW);
textView->Insert(fIsVideo ? "Enabling Real-Time Video allows the BeOS to perform video operations as fast and smoothly as possible. It achieves optimum performance by using more RAM."
@ -136,14 +151,23 @@ SettingsView::SettingsView (BRect frame, bool isVideo)
textView->MakeEditable(false);
textView->MakeSelectable(false);
textView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
realtimeBox->AddChild(textView);
BGroupLayout* realtimeBoxLayout = new BGroupLayout(B_VERTICAL, 5);
inset = realtimeBox->Frame().left - realtimeBox->InnerFrame().left;
realtimeBoxLayout->SetInsets(inset, defaultsBox->TopBorderOffset() * 2, inset, inset);
realtimeBox->SetLayout(realtimeBoxLayout);
realtimeBoxLayout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(5));
realtimeBoxLayout->AddView(fRealtimeCheckBox);
realtimeBoxLayout->AddView(textView);
// 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",
"Restart Media Services", new BMessage(ML_RESTART_MEDIA_SERVER));
AddChild(restartButton);
if (!fIsVideo) {
rect.right = rect.left - 10;
@ -151,14 +175,24 @@ SettingsView::SettingsView (BRect frame, bool isVideo)
rect.left = frame.left + 33;
if (StringWidth("Show Volume Control on Deskbar") > rect.Width() - 30)
rect.left -= 10;
fVolumeCheckBox = new BCheckBox(rect, "volumeCheckBox",
"Show Volume Control on Deskbar", new BMessage(ML_SHOW_VOLUME_CONTROL));
AddChild(fVolumeCheckBox);
bottomView->GroupLayout()->AddView(fVolumeCheckBox);
if (BDeskbar().HasItem("MediaReplicant"))
fVolumeCheckBox->SetValue(B_CONTROL_ON);
}
else{
bottomView->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue());
}
bottomView->GroupLayout()->AddView(restartButton);
// compose all stuff
BGroupLayout* rootlayout = new BGroupLayout(B_VERTICAL, 5);
SetLayout(rootlayout);
rootlayout->AddView(defaultsBox);
rootlayout->AddView(realtimeBox);
rootlayout->AddView(bottomView);
}
void

View File

@ -23,6 +23,8 @@
#include <String.h>
#include <Debug.h>
#include <Autolock.h>
#include <GroupView.h>
#include <SpaceLayoutItem.h>
#include "MediaWindow.h"
// Images
@ -148,16 +150,19 @@ MediaWindow::InitWindow(void)
// Bitmaps
BRect iconRect(0, 0, 15, 15);
BBitmap *icon = new BBitmap(iconRect, B_CMAP8);
icon->SetBits(kDevicesBits, kDevicesWidth*kDevicesHeight, 0, kDevicesColorSpace);
icon->SetBits(kDevicesBits, kDevicesWidth*kDevicesHeight, 0,
kDevicesColorSpace);
fIcons.AddItem(icon);
icon = new BBitmap(iconRect, B_CMAP8);
icon->SetBits(kMixerBits, kMixerWidth*kMixerHeight, 0, kMixerColorSpace);
icon->SetBits(kMixerBits, kMixerWidth*kMixerHeight, 0,
kMixerColorSpace);
fIcons.AddItem(icon);
icon = new BBitmap(iconRect, B_CMAP8);
icon->SetBits(kMicBits, kMicWidth*kMicHeight, 0, kMicColorSpace);
fIcons.AddItem(icon);
icon = new BBitmap(iconRect, B_CMAP8);
icon->SetBits(kSpeakerBits, kSpeakerWidth*kSpeakerHeight, 0, kSpeakerColorSpace);
icon->SetBits(kSpeakerBits, kSpeakerWidth*kSpeakerHeight, 0,
kSpeakerColorSpace);
fIcons.AddItem(icon);
icon = new BBitmap(iconRect, B_CMAP8);
icon->SetBits(kCamBits, kCamWidth*kCamHeight, 0, kCamColorSpace);
@ -166,47 +171,80 @@ MediaWindow::InitWindow(void)
icon->SetBits(kTVBits, kTVWidth*kTVHeight, 0, kTVColorSpace);
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
BRect menuRect(bounds.left+14, bounds.top+14, bounds.left+146, bounds.bottom-14);
BRect titleRect(menuRect.right+14, menuRect.top, bounds.right-10, menuRect.top+16);
BRect availableRect(menuRect.right+15, titleRect.bottom+12, bounds.right-14, bounds.bottom-4);
BRect barRect(titleRect.left, titleRect.bottom+10, titleRect.right-2, titleRect.bottom+11);
font_height titleHeightStruct;
be_bold_font->GetHeight(&titleHeightStruct);
float titleHeight = titleHeightStruct.ascent + titleHeightStruct.descent
+ titleHeightStruct.leading + 1;
fListView = new BListView(menuRect, "media_list_view", B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES);
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->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);
BScrollView *scrollView = new BScrollView("listscroller",
fListView, B_FOLLOW_LEFT|B_FOLLOW_TOP_BOTTOM, 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);
// Add Child(ren)
AddChild(fBox);
fBox->AddChild(scrollView);
fBox = new BBox(bounds, "background", B_FOLLOW_ALL_SIDES,
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->SetFont(be_bold_font);
fTitleView->SetFontSize(12.0);
fTitleView->SetHighColor(titleFontColor);
fBox->AddChild(fTitleView);
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);
fBox->AddChild(fContentView);
BRect settingsRect(0, 0, 442, 335);
BRect settingsRect(0, 0, availableRect.Width(), availableRect.Height());
fAudioView = new SettingsView(settingsRect, false);
fVideoView = new SettingsView(settingsRect, true);
fBar = new BarView(barRect);
fBox->AddChild(fBar);
BGroupView* titleGroupView = new BGroupView(B_HORIZONTAL);
titleGroupView->GroupLayout()->AddView(fTitleView);
titleGroupView->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue());
// Layout all views
BGroupView* rightView = new BGroupView(B_VERTICAL, 5);
rightView->GroupLayout()->SetInsets(14, 0, 0, 0);
rightView->GroupLayout()->AddView(titleGroupView);
rightView->GroupLayout()->AddView(fBar, 0);
rightView->GroupLayout()->AddView(fContentView);
BGroupLayout* rootLayout = new BGroupLayout(B_HORIZONTAL);
rootLayout->SetInsets(14, 14, 14, 14);
fBox->SetLayout(rootLayout);
rootLayout->AddView(scrollView);
rootLayout->AddView(rightView);
// Start the window
fInitCheck = InitMedia(true);
if (fInitCheck != B_OK) {
PostMessage(B_QUIT_REQUESTED);
@ -214,8 +252,16 @@ 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);
}
// ---------------------------------------------------------------------------------------------------------- //
// #pragma mark -
status_t
MediaWindow::InitMedia(bool first)