From 070c8b72c7e7ebec73b834ffc3e3c657766102b6 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Wed, 2 Nov 2016 18:21:21 +0100 Subject: [PATCH] CodyCam: fix layout BTextView in non editable mode does strange things. Do not use the same view for error display and for showing the video. We can force the video to have the right size, and the error will show nicely centered. --- src/apps/codycam/CodyCam.cpp | 29 +++++++++++++++++++++-------- src/apps/codycam/CodyCam.h | 3 ++- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/apps/codycam/CodyCam.cpp b/src/apps/codycam/CodyCam.cpp index ea8678e6bd..b42263a554 100644 --- a/src/apps/codycam/CodyCam.cpp +++ b/src/apps/codycam/CodyCam.cpp @@ -451,13 +451,21 @@ VideoWindow::VideoWindow(const char* title, window_type type, _BuildCaptureControls(); BBox* box = new BBox("box"); + BGroupLayout* layout = new BGroupLayout(B_VERTICAL); + box->SetLayout(layout); + layout->SetInsets(2, 2, 2, 2); box->AddChild(fVideoView); + box->AddChild(fErrorView); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .Add(menuBar) .AddGroup(B_VERTICAL) .SetInsets(B_USE_WINDOW_SPACING) - .Add(box) + .AddGroup(B_HORIZONTAL) + .AddGlue() + .Add(box) + .AddGlue() + .End() .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING) .Add(fCaptureSetupBox) .Add(fFtpSetupBox) @@ -592,14 +600,12 @@ void VideoWindow::_BuildCaptureControls() { // a view to hold the video image - fVideoView = new BTextView(""); + fVideoView = new BView("Video preview", B_WILL_DRAW); fVideoView->SetExplicitMinSize(BSize(VIDEO_SIZE_X, VIDEO_SIZE_Y)); fVideoView->SetExplicitMaxSize(BSize(VIDEO_SIZE_X, VIDEO_SIZE_Y)); - fVideoView->MakeEditable(false); - fVideoView->MakeResizable(false); - fVideoView->MakeSelectable(false); - fVideoView->SetAlignment(B_ALIGN_CENTER); - fVideoView->SetInsets(0, VIDEO_SIZE_Y / 3, 0 , 0); + + fErrorView = new BTextView("error"); + fErrorView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); // Capture controls fCaptureSetupBox = new BBox("Capture Controls", B_WILL_DRAW); @@ -734,7 +740,14 @@ void VideoWindow::ErrorAlert(const char* message, status_t err) { Lock(); - fVideoView->SetText(message); + fErrorView->SetText(message); + fErrorView->MakeEditable(false); + fErrorView->MakeSelectable(false); + fErrorView->SetWordWrap(true); + fErrorView->SetExplicitMinSize(BSize(VIDEO_SIZE_X, VIDEO_SIZE_Y)); + fErrorView->SetExplicitMaxSize(BSize(VIDEO_SIZE_X, VIDEO_SIZE_Y)); + fErrorView->Show(); + fVideoView->Hide(); Unlock(); printf("%s\n%s [%" B_PRIx32 "]", message, strerror(err), err); diff --git a/src/apps/codycam/CodyCam.h b/src/apps/codycam/CodyCam.h index d1ae0267b1..b54c734adb 100644 --- a/src/apps/codycam/CodyCam.h +++ b/src/apps/codycam/CodyCam.h @@ -142,7 +142,8 @@ private: media_node* fProducer; port_id* fPortPtr; - BTextView* fVideoView; + BView* fVideoView; + BTextView* fErrorView; BTextControl* fFileName; BBox* fCaptureSetupBox;