Improved layout of controls and more cleanup. There is now a splitter
between the source file list and the controls on the right, and ticket #6985 is fixed. A lot of issues and quirks remain with this application. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39855 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
0a81944d5d
commit
7730c84696
@ -1,8 +1,9 @@
|
|||||||
// Copyright 1999, Be Incorporated. All Rights Reserved.
|
// Copyright 1999, Be Incorporated. All Rights Reserved.
|
||||||
// Copyright 2000-2004, Jun Suzuki. All Rights Reserved.
|
// Copyright 2000-2004, Jun Suzuki. All Rights Reserved.
|
||||||
// Copyright 2007, Stephan Aßmus. All Rights Reserved.
|
// Copyright 2007, 2010 Stephan Aßmus. All Rights Reserved.
|
||||||
// Copyright 2010, Haiku, Inc. All Rights Reserved.
|
// Copyright 2010, Haiku, Inc. All Rights Reserved.
|
||||||
// This file may be used under the terms of the Be Sample Code License.
|
// This file may be used under the terms of the Be Sample Code License.
|
||||||
|
|
||||||
#include "MediaConverterWindow.h"
|
#include "MediaConverterWindow.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -134,13 +135,18 @@ MediaConverterWindow::MediaConverterWindow(BRect frame)
|
|||||||
fInfoBox = new BBox(B_FANCY_BORDER, fInfoView);
|
fInfoBox = new BBox(B_FANCY_BORDER, fInfoView);
|
||||||
fInfoBox->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
|
fInfoBox->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
|
||||||
B_ALIGN_USE_FULL_HEIGHT));
|
B_ALIGN_USE_FULL_HEIGHT));
|
||||||
|
fInfoBox->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
||||||
|
|
||||||
|
float padding = be_control_look->DefaultItemSpacing();
|
||||||
|
|
||||||
// Output format box
|
// Output format box
|
||||||
fOutputBox = new BBox(B_FANCY_BORDER, NULL);
|
fOutputBox = new BBox(B_FANCY_BORDER, NULL);
|
||||||
float padding = be_control_look->DefaultItemSpacing();
|
|
||||||
BGridLayout* outputGrid = new BGridLayout(padding, padding);
|
BGridLayout* outputGrid = new BGridLayout(padding, padding);
|
||||||
fOutputBox->SetLayout(outputGrid);
|
fOutputBox->SetLayout(outputGrid);
|
||||||
// fOutputBox's layout is also adjusted in _UpdateLabels
|
// fOutputBox's layout is also adjusted in _UpdateLabels
|
||||||
|
outputGrid->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
|
||||||
|
B_ALIGN_USE_FULL_HEIGHT));
|
||||||
|
fOutputBox->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
|
||||||
|
|
||||||
fFormatMenu = new BMenuField(NULL, FORMAT_LABEL, new BPopUpMenu(""));
|
fFormatMenu = new BMenuField(NULL, FORMAT_LABEL, new BPopUpMenu(""));
|
||||||
fAudioMenu = new BMenuField(NULL, AUDIO_LABEL, new BPopUpMenu(""));
|
fAudioMenu = new BMenuField(NULL, AUDIO_LABEL, new BPopUpMenu(""));
|
||||||
@ -195,7 +201,7 @@ MediaConverterWindow::MediaConverterWindow(BRect frame)
|
|||||||
// Status views
|
// Status views
|
||||||
fStatus = new BStringView(NULL, NULL);
|
fStatus = new BStringView(NULL, NULL);
|
||||||
fStatus->SetExplicitAlignment(labelAlignment);
|
fStatus->SetExplicitAlignment(labelAlignment);
|
||||||
fFileStatus= new BStringView(NULL, NULL);
|
fFileStatus = new BStringView(NULL, NULL);
|
||||||
fFileStatus->SetExplicitAlignment(labelAlignment);
|
fFileStatus->SetExplicitAlignment(labelAlignment);
|
||||||
|
|
||||||
SetStatusMessage("");
|
SetStatusMessage("");
|
||||||
@ -204,17 +210,22 @@ MediaConverterWindow::MediaConverterWindow(BRect frame)
|
|||||||
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
|
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
|
||||||
.SetInsets(0, 0, 0, 0)
|
.SetInsets(0, 0, 0, 0)
|
||||||
.Add(fMenuBar)
|
.Add(fMenuBar)
|
||||||
.AddGrid(padding, padding)
|
.AddSplit(B_HORIZONTAL, padding / 2)
|
||||||
.SetInsets(padding, padding, padding, padding)
|
.SetInsets(padding, padding, padding, padding)
|
||||||
.Add(fSourcesBox, 0, 0, 1, 2)
|
.Add(fSourcesBox, 0.4)
|
||||||
.Add(fInfoBox, 1, 0, 1, 1)
|
.AddGroup(B_VERTICAL, padding, 0.6)
|
||||||
.Add(fOutputBox, 1, 1, 1, 1)
|
.Add(fInfoBox)
|
||||||
.AddGrid(padding, padding, 0, 2, 2, 1)
|
.Add(fOutputBox)
|
||||||
.SetInsets(0, 0, 0, 0)
|
.End()
|
||||||
|
.End()
|
||||||
|
.AddGrid(padding, padding)
|
||||||
|
.SetInsets(padding, 0, padding, padding)
|
||||||
.Add(fStatus, 0, 0)
|
.Add(fStatus, 0, 0)
|
||||||
.Add(fFileStatus, 0, 1)
|
.Add(fFileStatus, 0, 1)
|
||||||
.Add(fPreviewButton, 2, 0)
|
.Add(fPreviewButton, 2, 0)
|
||||||
.Add(fConvertButton, 3, 0);
|
.Add(fConvertButton, 3, 0)
|
||||||
|
.End()
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -228,24 +239,6 @@ MediaConverterWindow::~MediaConverterWindow()
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
void
|
|
||||||
MediaConverterWindow::DispatchMessage(BMessage *msg, BHandler *handler)
|
|
||||||
{
|
|
||||||
if (msg->WasDropped() && msg->what == B_SIMPLE_DATA) {
|
|
||||||
|
|
||||||
printf("Dispatch 1\n");
|
|
||||||
DetachCurrentMessage();
|
|
||||||
msg->what = B_REFS_RECEIVED;
|
|
||||||
BMessenger(be_app).SendMessage(msg);
|
|
||||||
delete msg;
|
|
||||||
} else {
|
|
||||||
BWindow::DispatchMessage(msg, handler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MediaConverterWindow::MessageReceived(BMessage* msg)
|
MediaConverterWindow::MessageReceived(BMessage* msg)
|
||||||
{
|
{
|
||||||
@ -497,18 +490,18 @@ MediaConverterWindow::LanguageChanged()
|
|||||||
void
|
void
|
||||||
MediaConverterWindow::BuildAudioVideoMenus()
|
MediaConverterWindow::BuildAudioVideoMenus()
|
||||||
{
|
{
|
||||||
BMenu *menu = fAudioMenu->Menu();
|
BMenu* menu = fAudioMenu->Menu();
|
||||||
BMenuItem *item;
|
BMenuItem* item;
|
||||||
// clear out old audio codec menu items
|
// clear out old audio codec menu items
|
||||||
while ((item = menu->RemoveItem((int32)0)) != NULL) {
|
while ((item = menu->RemoveItem(0L)) != NULL)
|
||||||
delete item;
|
delete item;
|
||||||
}
|
|
||||||
|
|
||||||
bool separator = true;
|
bool separator = true;
|
||||||
|
|
||||||
// get selected file format
|
// get selected file format
|
||||||
FileFormatMenuItem *ffmi = (FileFormatMenuItem*)fFormatMenu->Menu()->FindMarked();
|
FileFormatMenuItem* ffmi
|
||||||
media_file_format *mf_format = &(ffmi->fFileFormat);
|
= (FileFormatMenuItem*)fFormatMenu->Menu()->FindMarked();
|
||||||
|
media_file_format* mf_format = &(ffmi->fFileFormat);
|
||||||
|
|
||||||
media_format format, outfmt;
|
media_format format, outfmt;
|
||||||
memset(&format, 0, sizeof(format));
|
memset(&format, 0, sizeof(format));
|
||||||
@ -519,7 +512,8 @@ MediaConverterWindow::BuildAudioVideoMenus()
|
|||||||
// add available audio encoders to menu
|
// add available audio encoders to menu
|
||||||
format.type = B_MEDIA_RAW_AUDIO;
|
format.type = B_MEDIA_RAW_AUDIO;
|
||||||
format.u.raw_audio = media_raw_audio_format::wildcard;
|
format.u.raw_audio = media_raw_audio_format::wildcard;
|
||||||
while (get_next_encoder(&cookie, mf_format, &format, &outfmt, &codec_info) == B_OK) {
|
while (get_next_encoder(&cookie, mf_format, &format, &outfmt, &codec_info)
|
||||||
|
== B_OK) {
|
||||||
if (separator) {
|
if (separator) {
|
||||||
menu->AddItem(new BMenuItem("No audio",
|
menu->AddItem(new BMenuItem("No audio",
|
||||||
new BMessage(AUDIO_CODEC_SELECT_MESSAGE)));
|
new BMessage(AUDIO_CODEC_SELECT_MESSAGE)));
|
||||||
@ -553,9 +547,8 @@ MediaConverterWindow::BuildAudioVideoMenus()
|
|||||||
|
|
||||||
// clear out old video codec menu items
|
// clear out old video codec menu items
|
||||||
menu = fVideoMenu->Menu();
|
menu = fVideoMenu->Menu();
|
||||||
while ((item = menu->RemoveItem((int32)0)) != NULL) {
|
while ((item = menu->RemoveItem(0L)) != NULL)
|
||||||
delete item;
|
delete item;
|
||||||
}
|
|
||||||
|
|
||||||
separator = true;
|
separator = true;
|
||||||
|
|
||||||
@ -727,13 +720,8 @@ MediaConverterWindow::SourceFileSelectionChanged()
|
|||||||
{
|
{
|
||||||
int32 selected = fListView->CurrentSelection();
|
int32 selected = fListView->CurrentSelection();
|
||||||
BMediaFile* file = NULL;
|
BMediaFile* file = NULL;
|
||||||
entry_ref* _ref = NULL;
|
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
bool enabled = false;
|
bool enabled = GetSourceFileAt(selected, &file, &ref) == B_OK;
|
||||||
if (GetSourceFileAt(selected, &file, &ref) == B_OK) {
|
|
||||||
_ref = &ref;
|
|
||||||
enabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
fPreviewButton->SetEnabled(enabled);
|
fPreviewButton->SetEnabled(enabled);
|
||||||
fVideoQualitySlider->SetEnabled(enabled);
|
fVideoQualitySlider->SetEnabled(enabled);
|
||||||
@ -741,16 +729,17 @@ MediaConverterWindow::SourceFileSelectionChanged()
|
|||||||
fStartDurationTC->SetEnabled(enabled);
|
fStartDurationTC->SetEnabled(enabled);
|
||||||
fEndDurationTC->SetEnabled(enabled);
|
fEndDurationTC->SetEnabled(enabled);
|
||||||
|
|
||||||
if (enabled)
|
BString duration;
|
||||||
fInfoView->Update(file, _ref);
|
if (enabled) {
|
||||||
|
fInfoView->Update(file, &ref);
|
||||||
// HACK: get the fInfoView to update the duration "synchronously"
|
// HACK: get the fInfoView to update the duration "synchronously"
|
||||||
UpdateIfNeeded();
|
UpdateIfNeeded();
|
||||||
|
duration << fInfoView->Duration() / 1000;
|
||||||
|
} else
|
||||||
|
duration = "0";
|
||||||
|
|
||||||
// update duration text controls
|
// update duration text controls
|
||||||
fStartDurationTC->SetText("0");
|
fStartDurationTC->SetText("0");
|
||||||
BString duration;
|
|
||||||
duration << fInfoView->Duration() / 1000;
|
|
||||||
fEndDurationTC->SetText(duration.String());
|
fEndDurationTC->SetText(duration.String());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -888,7 +877,7 @@ MediaConverterWindow::_UpdateBBoxLayoutInsets(BBox* box)
|
|||||||
{
|
{
|
||||||
BTwoDimensionalLayout* layout
|
BTwoDimensionalLayout* layout
|
||||||
= dynamic_cast<BTwoDimensionalLayout*>(box->GetLayout());
|
= dynamic_cast<BTwoDimensionalLayout*>(box->GetLayout());
|
||||||
if (layout) {
|
if (layout != NULL) {
|
||||||
float padding = be_control_look->DefaultItemSpacing();
|
float padding = be_control_look->DefaultItemSpacing();
|
||||||
layout->SetInsets(padding, box->TopBorderOffset() + padding, padding,
|
layout->SetInsets(padding, box->TopBorderOffset() + padding, padding,
|
||||||
padding);
|
padding);
|
||||||
|
@ -25,17 +25,15 @@ class MediaFileListView;
|
|||||||
class StatusView;
|
class StatusView;
|
||||||
|
|
||||||
class MediaConverterWindow : public BWindow {
|
class MediaConverterWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
MediaConverterWindow(BRect frame);
|
MediaConverterWindow(BRect frame);
|
||||||
virtual ~MediaConverterWindow();
|
virtual ~MediaConverterWindow();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// virtual void DispatchMessage(BMessage* message,
|
|
||||||
// BHandler* handler);
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void LanguageChanged();
|
void LanguageChanged();
|
||||||
|
|
||||||
void BuildFormatMenu();
|
void BuildFormatMenu();
|
||||||
@ -73,13 +71,14 @@ class MediaConverterWindow : public BWindow {
|
|||||||
|
|
||||||
BDirectory OutputDirectory() const;
|
BDirectory OutputDirectory() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _UpdateLabels();
|
void _UpdateLabels();
|
||||||
void _UpdateBBoxLayoutInsets(BBox* box);
|
void _UpdateBBoxLayoutInsets(BBox* box);
|
||||||
void _CreateMenu();
|
void _CreateMenu();
|
||||||
void _DestroyMenu();
|
void _DestroyMenu();
|
||||||
void _SetOutputFolder(BEntry entry);
|
void _SetOutputFolder(BEntry entry);
|
||||||
|
|
||||||
|
private:
|
||||||
BButton* fConvertButton;
|
BButton* fConvertButton;
|
||||||
|
|
||||||
BButton* fDestButton;
|
BButton* fDestButton;
|
||||||
|
Loading…
Reference in New Issue
Block a user