CHANGED the MidiPlayer GUI to use the layout system, mostly for the purposes of
the article I am writing, though it really did need this change. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26408 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -20,9 +20,13 @@
|
|||||||
* DEALINGS IN THE SOFTWARE.
|
* DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <GridLayoutBuilder.h>
|
||||||
|
#include <GroupLayout.h>
|
||||||
|
#include <GroupLayoutBuilder.h>
|
||||||
#include <MidiProducer.h>
|
#include <MidiProducer.h>
|
||||||
#include <MidiRoster.h>
|
#include <MidiRoster.h>
|
||||||
#include <StorageKit.h>
|
#include <StorageKit.h>
|
||||||
|
#include <SpaceLayoutItem.h>
|
||||||
|
|
||||||
#include "MidiPlayerApp.h"
|
#include "MidiPlayerApp.h"
|
||||||
#include "MidiPlayerWindow.h"
|
#include "MidiPlayerWindow.h"
|
||||||
@@ -36,7 +40,7 @@
|
|||||||
|
|
||||||
MidiPlayerWindow::MidiPlayerWindow()
|
MidiPlayerWindow::MidiPlayerWindow()
|
||||||
: BWindow(BRect(0, 0, 1, 1), "MidiPlayer", B_TITLED_WINDOW,
|
: BWindow(BRect(0, 0, 1, 1), "MidiPlayer", B_TITLED_WINDOW,
|
||||||
B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
|
B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
|
||||||
{
|
{
|
||||||
playing = false;
|
playing = false;
|
||||||
scopeEnabled = true;
|
scopeEnabled = true;
|
||||||
@@ -188,12 +192,7 @@ void MidiPlayerWindow::CreateInputMenu()
|
|||||||
|
|
||||||
inputPopUp->AddItem(inputOff);
|
inputPopUp->AddItem(inputOff);
|
||||||
|
|
||||||
inputMenu = new BMenuField(
|
inputMenu = new BMenuField("Live Input:", inputPopUp, NULL);
|
||||||
BRect(0, 0, 128, 17), "inputMenu", "Live Input:", inputPopUp,
|
|
||||||
B_FOLLOW_LEFT | B_FOLLOW_TOP);
|
|
||||||
|
|
||||||
inputMenu->SetDivider(55);
|
|
||||||
inputMenu->ResizeToPreferred();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -227,26 +226,20 @@ void MidiPlayerWindow::CreateReverbMenu()
|
|||||||
reverbPopUp->AddItem(reverbCavern);
|
reverbPopUp->AddItem(reverbCavern);
|
||||||
reverbPopUp->AddItem(reverbDungeon);
|
reverbPopUp->AddItem(reverbDungeon);
|
||||||
|
|
||||||
reverbMenu = new BMenuField(
|
reverbMenu = new BMenuField("Reverb:", reverbPopUp, NULL);
|
||||||
BRect(0, 0, 128, 17), "reverbMenu", "Reverb:", reverbPopUp,
|
|
||||||
B_FOLLOW_LEFT | B_FOLLOW_TOP);
|
|
||||||
|
|
||||||
reverbMenu->SetDivider(55);
|
|
||||||
reverbMenu->ResizeToPreferred();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
void MidiPlayerWindow::CreateViews()
|
void MidiPlayerWindow::CreateViews()
|
||||||
{
|
{
|
||||||
|
// Set up needed views
|
||||||
scopeView = new ScopeView;
|
scopeView = new ScopeView;
|
||||||
|
|
||||||
showScope = new BCheckBox(
|
showScope = new BCheckBox(
|
||||||
BRect(0, 0, 1, 1), "showScope", "Scope",
|
BRect(0, 0, 1, 1), "showScope", "Scope",
|
||||||
new BMessage(MSG_SHOW_SCOPE), B_FOLLOW_LEFT);
|
new BMessage(MSG_SHOW_SCOPE), B_FOLLOW_LEFT);
|
||||||
|
|
||||||
showScope->SetValue(B_CONTROL_ON);
|
showScope->SetValue(B_CONTROL_ON);
|
||||||
showScope->ResizeToPreferred();
|
|
||||||
|
|
||||||
CreateInputMenu();
|
CreateInputMenu();
|
||||||
CreateReverbMenu();
|
CreateReverbMenu();
|
||||||
@@ -254,83 +247,52 @@ void MidiPlayerWindow::CreateViews()
|
|||||||
volumeSlider = new BSlider(
|
volumeSlider = new BSlider(
|
||||||
BRect(0, 0, 1, 1), "volumeSlider", NULL, NULL,
|
BRect(0, 0, 1, 1), "volumeSlider", NULL, NULL,
|
||||||
0, 100, B_TRIANGLE_THUMB);
|
0, 100, B_TRIANGLE_THUMB);
|
||||||
|
|
||||||
rgb_color col = { 152, 152, 255 };
|
rgb_color col = { 152, 152, 255 };
|
||||||
volumeSlider->UseFillColor(true, &col);
|
volumeSlider->UseFillColor(true, &col);
|
||||||
volumeSlider->SetModificationMessage(new BMessage(MSG_VOLUME));
|
volumeSlider->SetModificationMessage(new BMessage(MSG_VOLUME));
|
||||||
volumeSlider->ResizeToPreferred();
|
|
||||||
volumeSlider->ResizeTo(_W(scopeView) - 42, _H(volumeSlider));
|
|
||||||
|
|
||||||
playButton = new BButton(
|
playButton = new BButton(
|
||||||
BRect(0, 1, 80, 1), "playButton", "Play", new BMessage(MSG_PLAY_STOP),
|
BRect(0, 1, 80, 1), "playButton", "Play", new BMessage(MSG_PLAY_STOP),
|
||||||
B_FOLLOW_RIGHT);
|
B_FOLLOW_RIGHT);
|
||||||
|
|
||||||
//playButton->MakeDefault(true);
|
|
||||||
playButton->ResizeToPreferred();
|
|
||||||
playButton->SetEnabled(false);
|
playButton->SetEnabled(false);
|
||||||
|
|
||||||
BBox* background = new BBox(
|
|
||||||
BRect(0, 0, 1, 1), B_EMPTY_STRING, B_FOLLOW_ALL_SIDES,
|
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
|
|
||||||
B_PLAIN_BORDER);
|
|
||||||
|
|
||||||
BBox* divider = new BBox(
|
BBox* divider = new BBox(
|
||||||
BRect(0, 0, 1, 1), B_EMPTY_STRING, B_FOLLOW_ALL_SIDES,
|
BRect(0, 0, 1, 1), B_EMPTY_STRING, B_FOLLOW_ALL_SIDES,
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER);
|
B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER);
|
||||||
|
divider->SetExplicitMaxSize(
|
||||||
divider->ResizeTo(_W(scopeView), 1);
|
BSize(B_SIZE_UNLIMITED, 1));
|
||||||
|
|
||||||
BStringView* volumeLabel = new BStringView(
|
BStringView* volumeLabel = new BStringView(
|
||||||
BRect(0, 0, 1, 1), NULL, "Volume:");
|
BRect(0, 0, 1, 1), NULL, "Volume:");
|
||||||
|
volumeLabel->SetAlignment(B_ALIGN_LEFT);
|
||||||
volumeLabel->ResizeToPreferred();
|
volumeLabel->SetExplicitMaxSize(
|
||||||
|
BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
||||||
|
|
||||||
float width = 8 + _W(scopeView) + 8;
|
// Build the layout
|
||||||
|
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||||
|
|
||||||
float height =
|
AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
|
||||||
8 + _H(scopeView)
|
.Add(scopeView)
|
||||||
+ 8 + _H(showScope)
|
.Add(BGridLayoutBuilder(10, 10)
|
||||||
+ 4 + _H(inputMenu)
|
.Add(BSpaceLayoutItem::CreateGlue(), 0, 0)
|
||||||
+ _H(reverbMenu)
|
.Add(showScope, 1, 0)
|
||||||
+ 2 + _H(volumeSlider)
|
|
||||||
+ 10 + _H(divider)
|
|
||||||
+ 6 + _H(playButton)
|
|
||||||
+ 16;
|
|
||||||
|
|
||||||
ResizeTo(width, height);
|
.Add(reverbMenu->CreateLabelLayoutItem(), 0, 1)
|
||||||
|
.Add(reverbMenu->CreateMenuBarLayoutItem(), 1, 1)
|
||||||
|
|
||||||
AddChild(background);
|
.Add(inputMenu->CreateLabelLayoutItem(), 0, 2)
|
||||||
background->ResizeTo(width, height);
|
.Add(inputMenu->CreateMenuBarLayoutItem(), 1, 2)
|
||||||
background->AddChild(scopeView);
|
|
||||||
background->AddChild(showScope);
|
|
||||||
background->AddChild(reverbMenu);
|
|
||||||
background->AddChild(inputMenu);
|
|
||||||
background->AddChild(volumeLabel);
|
|
||||||
background->AddChild(volumeSlider);
|
|
||||||
background->AddChild(divider);
|
|
||||||
background->AddChild(playButton);
|
|
||||||
|
|
||||||
float y = 8;
|
.Add(volumeLabel, 0, 3)
|
||||||
scopeView->MoveTo(8, y);
|
.Add(volumeSlider, 1, 3)
|
||||||
|
)
|
||||||
y += _H(scopeView) + 8;
|
.AddGlue()
|
||||||
showScope->MoveTo(8 + 55, y);
|
.Add(divider)
|
||||||
|
.AddGlue()
|
||||||
y += _H(showScope) + 4;
|
.Add(playButton)
|
||||||
inputMenu->MoveTo(8, y);
|
.AddGlue()
|
||||||
|
.SetInsets(5, 5, 5, 5)
|
||||||
y += _H(inputMenu);
|
);
|
||||||
reverbMenu->MoveTo(8, y);
|
|
||||||
|
|
||||||
y += _H(reverbMenu) + 2;
|
|
||||||
volumeLabel->MoveTo(8, y);
|
|
||||||
volumeSlider->MoveTo(8 + 49, y);
|
|
||||||
|
|
||||||
y += _H(volumeSlider) + 10;
|
|
||||||
divider->MoveTo(8, y);
|
|
||||||
|
|
||||||
y += _H(divider) + 6;
|
|
||||||
playButton->MoveTo((width - _W(playButton)) / 2, y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
ScopeView::ScopeView()
|
ScopeView::ScopeView()
|
||||||
: BView(BRect(0, 0, 127, 63), NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
: BView(BRect(0, 0, 180, 63), NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
B_WILL_DRAW)
|
B_WILL_DRAW)
|
||||||
{
|
{
|
||||||
SetViewColor(0, 0, 0);
|
SetViewColor(0, 0, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user