ShowImage: Use layouts for the main view area.
The main window itself is still not using them, due to incompatibilities with the toolbar animation. Fixes #18547.
This commit is contained in:
@@ -29,10 +29,9 @@
|
|||||||
const float kHorzSpacing = 5.f;
|
const float kHorzSpacing = 5.f;
|
||||||
|
|
||||||
|
|
||||||
ShowImageStatusView::ShowImageStatusView(BScrollView* scrollView)
|
ShowImageStatusView::ShowImageStatusView()
|
||||||
:
|
:
|
||||||
BView(BRect(), "statusview", B_FOLLOW_BOTTOM | B_FOLLOW_LEFT, B_WILL_DRAW),
|
BView("statusview", B_WILL_DRAW),
|
||||||
fScrollView(scrollView),
|
|
||||||
fPreferredSize(0.0, 0.0)
|
fPreferredSize(0.0, 0.0)
|
||||||
{
|
{
|
||||||
memset(fCellWidth, 0, sizeof(fCellWidth));
|
memset(fCellWidth, 0, sizeof(fCellWidth));
|
||||||
@@ -45,9 +44,6 @@ ShowImageStatusView::AttachedToWindow()
|
|||||||
SetFont(be_plain_font);
|
SetFont(be_plain_font);
|
||||||
BPrivate::AdoptScrollBarFontSize(this);
|
BPrivate::AdoptScrollBarFontSize(this);
|
||||||
|
|
||||||
BScrollBar* scrollBar = fScrollView->ScrollBar(B_HORIZONTAL);
|
|
||||||
MoveTo(0.0, scrollBar->Frame().top);
|
|
||||||
|
|
||||||
AdoptParentColors();
|
AdoptParentColors();
|
||||||
|
|
||||||
ResizeToPreferred();
|
ResizeToPreferred();
|
||||||
@@ -206,7 +202,6 @@ ShowImageStatusView::_SetImageTypeText(const BString& imageType)
|
|||||||
void
|
void
|
||||||
ShowImageStatusView::_ValidatePreferredSize()
|
ShowImageStatusView::_ValidatePreferredSize()
|
||||||
{
|
{
|
||||||
float orgWidth = fPreferredSize.width;
|
|
||||||
// width
|
// width
|
||||||
fPreferredSize.width = 0.f;
|
fPreferredSize.width = 0.f;
|
||||||
for (size_t i = 0; i < kStatusCellCount; i++) {
|
for (size_t i = 0; i < kStatusCellCount; i++) {
|
||||||
@@ -232,9 +227,6 @@ ShowImageStatusView::_ValidatePreferredSize()
|
|||||||
if (fPreferredSize.height < scrollBarSize)
|
if (fPreferredSize.height < scrollBarSize)
|
||||||
fPreferredSize.height = scrollBarSize;
|
fPreferredSize.height = scrollBarSize;
|
||||||
|
|
||||||
float delta = fPreferredSize.width - orgWidth;
|
SetExplicitMinSize(fPreferredSize);
|
||||||
ResizeBy(delta, 0);
|
SetExplicitMaxSize(fPreferredSize);
|
||||||
BScrollBar* scrollBar = fScrollView->ScrollBar(B_HORIZONTAL);
|
|
||||||
scrollBar->ResizeBy(-delta, 0);
|
|
||||||
scrollBar->MoveBy(delta, 0);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ enum {
|
|||||||
|
|
||||||
class ShowImageStatusView : public BView {
|
class ShowImageStatusView : public BView {
|
||||||
public:
|
public:
|
||||||
ShowImageStatusView(BScrollView* scrollView);
|
ShowImageStatusView();
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void GetPreferredSize(float* _width, float* _height);
|
virtual void GetPreferredSize(float* _width, float* _height);
|
||||||
@@ -44,7 +44,6 @@ public:
|
|||||||
void _SetPagesText(const BString& pages);
|
void _SetPagesText(const BString& pages);
|
||||||
void _SetImageTypeText(const BString& imageType);
|
void _SetImageTypeText(const BString& imageType);
|
||||||
void _ValidatePreferredSize();
|
void _ValidatePreferredSize();
|
||||||
BScrollView* fScrollView;
|
|
||||||
BSize fPreferredSize;
|
BSize fPreferredSize;
|
||||||
BString fCellText[kStatusCellCount];
|
BString fCellText[kStatusCellCount];
|
||||||
float fCellWidth[kStatusCellCount];
|
float fCellWidth[kStatusCellCount];
|
||||||
|
|||||||
@@ -172,10 +172,9 @@ PopUpMenu::~PopUpMenu()
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
ShowImageView::ShowImageView(BRect rect, const char* name, uint32 resizingMode,
|
ShowImageView::ShowImageView(const char* name, uint32 flags)
|
||||||
uint32 flags)
|
|
||||||
:
|
:
|
||||||
BView(rect, name, resizingMode, flags),
|
BView(name, flags),
|
||||||
fBitmapOwner(NULL),
|
fBitmapOwner(NULL),
|
||||||
fBitmap(NULL),
|
fBitmap(NULL),
|
||||||
fDisplayBitmap(NULL),
|
fDisplayBitmap(NULL),
|
||||||
|
|||||||
@@ -31,8 +31,7 @@ class BitmapOwner;
|
|||||||
|
|
||||||
class ShowImageView : public BView {
|
class ShowImageView : public BView {
|
||||||
public:
|
public:
|
||||||
ShowImageView(BRect rect, const char* name,
|
ShowImageView(const char* name, uint32 flags);
|
||||||
uint32 resizingMode, uint32 flags);
|
|
||||||
virtual ~ShowImageView();
|
virtual ~ShowImageView();
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <FilePanel.h>
|
#include <FilePanel.h>
|
||||||
|
#include <GridLayout.h>
|
||||||
#include <Locale.h>
|
#include <Locale.h>
|
||||||
#include <Menu.h>
|
#include <Menu.h>
|
||||||
#include <MenuBar.h>
|
#include <MenuBar.h>
|
||||||
@@ -132,7 +133,7 @@ bs_printf(BString* string, const char* format, ...)
|
|||||||
ShowImageWindow::ShowImageWindow(BRect frame, const entry_ref& ref,
|
ShowImageWindow::ShowImageWindow(BRect frame, const entry_ref& ref,
|
||||||
const BMessenger& trackerMessenger)
|
const BMessenger& trackerMessenger)
|
||||||
:
|
:
|
||||||
BWindow(frame, "", B_DOCUMENT_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS),
|
BWindow(frame, "", B_DOCUMENT_WINDOW, 0),
|
||||||
fNavigator(ref, trackerMessenger),
|
fNavigator(ref, trackerMessenger),
|
||||||
fSavePanel(NULL),
|
fSavePanel(NULL),
|
||||||
fBar(NULL),
|
fBar(NULL),
|
||||||
@@ -171,7 +172,6 @@ ShowImageWindow::ShowImageWindow(BRect frame, const entry_ref& ref,
|
|||||||
|
|
||||||
// Create the tool bar
|
// Create the tool bar
|
||||||
BRect viewFrame = contentView->Bounds();
|
BRect viewFrame = contentView->Bounds();
|
||||||
viewFrame.right -= be_control_look->GetScrollBarWidth(B_VERTICAL);
|
|
||||||
fToolBar = new BToolBar(viewFrame);
|
fToolBar = new BToolBar(viewFrame);
|
||||||
|
|
||||||
// Add the tool icons.
|
// Add the tool icons.
|
||||||
@@ -222,24 +222,51 @@ ShowImageWindow::ShowImageWindow(BRect frame, const entry_ref& ref,
|
|||||||
fToolBarVisible = fShowToolBar;
|
fToolBarVisible = fShowToolBar;
|
||||||
|
|
||||||
viewFrame.bottom = contentView->Bounds().bottom;
|
viewFrame.bottom = contentView->Bounds().bottom;
|
||||||
viewFrame.bottom -= be_control_look->GetScrollBarWidth(B_HORIZONTAL);
|
|
||||||
|
// create the scroll area
|
||||||
|
fScrollArea = new BScrollView("image_scroller", NULL, 0,
|
||||||
|
false, false, B_PLAIN_BORDER);
|
||||||
|
BGridLayout* gridLayout = new BGridLayout(0, 0);
|
||||||
|
fScrollArea->SetLayout(gridLayout);
|
||||||
|
gridLayout->SetInsets(1, 1, -1, -1);
|
||||||
|
|
||||||
|
fScrollArea->MoveTo(viewFrame.LeftTop());
|
||||||
|
fScrollArea->ResizeTo(viewFrame.Size());
|
||||||
|
fScrollArea->SetResizingMode(B_FOLLOW_ALL);
|
||||||
|
contentView->AddChild(fScrollArea);
|
||||||
|
|
||||||
// create the image view
|
// create the image view
|
||||||
fImageView = new ShowImageView(viewFrame, "image_view", B_FOLLOW_ALL,
|
fImageView = new ShowImageView("image_view",
|
||||||
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED
|
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED
|
||||||
| B_FRAME_EVENTS);
|
| B_FRAME_EVENTS);
|
||||||
// wrap a scroll view around the view
|
fImageView->SetExplicitMinSize(BSize(0, 0));
|
||||||
fScrollView = new BScrollView("image_scroller", fImageView,
|
gridLayout->AddView(fImageView, 0, 0, 2, 1);
|
||||||
B_FOLLOW_ALL, 0, true, true, B_PLAIN_BORDER);
|
|
||||||
contentView->AddChild(fScrollView);
|
|
||||||
|
|
||||||
fStatusView = new ShowImageStatusView(fScrollView);
|
// create the scroll bars (wrapped to avoid double borders)
|
||||||
fScrollView->AddChild(fStatusView);
|
fVScrollBar = new BScrollBar(NULL, NULL, 0, 0, B_VERTICAL); {
|
||||||
|
BGroupView* vScrollBarContainer = new BGroupView(B_VERTICAL, 0);
|
||||||
|
vScrollBarContainer->GroupLayout()->AddView(fVScrollBar);
|
||||||
|
vScrollBarContainer->GroupLayout()->SetInsets(0, -1, 0, -1);
|
||||||
|
gridLayout->AddView(vScrollBarContainer, 2, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
fHScrollBar = new BScrollBar(NULL, NULL, 0, 0, B_HORIZONTAL); {
|
||||||
|
BGroupView* hScrollBarContainer = new BGroupView(B_VERTICAL, 0);
|
||||||
|
hScrollBarContainer->GroupLayout()->AddView(fHScrollBar);
|
||||||
|
hScrollBarContainer->GroupLayout()->SetInsets(0, -1, -1, -1);
|
||||||
|
gridLayout->AddView(hScrollBarContainer, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
fVScrollBar->SetTarget(fImageView);
|
||||||
|
fHScrollBar->SetTarget(fImageView);
|
||||||
|
|
||||||
|
fStatusView = new ShowImageStatusView;
|
||||||
|
gridLayout->AddView(fStatusView, 0, 1);
|
||||||
|
|
||||||
// Update minimum window size
|
// Update minimum window size
|
||||||
float toolBarMinWidth = fToolBar->MinSize().width;
|
float toolBarMinWidth = fToolBar->MinSize().width;
|
||||||
SetSizeLimits(std::max(menuBarMinWidth, toolBarMinWidth), 100000, 100,
|
SetSizeLimits(std::max(menuBarMinWidth, toolBarMinWidth), 100000,
|
||||||
100000);
|
fBar->MinSize().height + gridLayout->MinSize().height, 100000);
|
||||||
|
|
||||||
// finish creating the window
|
// finish creating the window
|
||||||
if (_LoadImage() != B_OK) {
|
if (_LoadImage() != B_OK) {
|
||||||
@@ -1040,8 +1067,8 @@ ShowImageWindow::MessageReceived(BMessage* message)
|
|||||||
float offset;
|
float offset;
|
||||||
if (message->FindFloat("offset", &offset) == B_OK) {
|
if (message->FindFloat("offset", &offset) == B_OK) {
|
||||||
fToolBar->MoveBy(0, offset);
|
fToolBar->MoveBy(0, offset);
|
||||||
fScrollView->ResizeBy(0, -offset);
|
fScrollArea->ResizeBy(0, -offset);
|
||||||
fScrollView->MoveBy(0, offset);
|
fScrollArea->MoveBy(0, offset);
|
||||||
UpdateIfNeeded();
|
UpdateIfNeeded();
|
||||||
snooze(15000);
|
snooze(15000);
|
||||||
}
|
}
|
||||||
@@ -1059,8 +1086,8 @@ ShowImageWindow::MessageReceived(BMessage* message)
|
|||||||
fToolBar->Hide();
|
fToolBar->Hide();
|
||||||
BRect frame = fToolBar->Parent()->Bounds();
|
BRect frame = fToolBar->Parent()->Bounds();
|
||||||
frame.top = fToolBar->Frame().bottom + 1;
|
frame.top = fToolBar->Frame().bottom + 1;
|
||||||
fScrollView->MoveTo(fScrollView->Frame().left, frame.top);
|
fScrollArea->MoveTo(fScrollArea->Frame().left, frame.top);
|
||||||
fScrollView->ResizeTo(fScrollView->Bounds().Width(),
|
fScrollArea->ResizeTo(fScrollArea->Bounds().Width(),
|
||||||
frame.Height() + 1);
|
frame.Height() + 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1608,8 +1635,8 @@ ShowImageWindow::_SetToolBarVisible(bool visible, bool animate)
|
|||||||
finalMessage.AddBool("show", visible);
|
finalMessage.AddBool("show", visible);
|
||||||
PostMessage(&finalMessage, this);
|
PostMessage(&finalMessage, this);
|
||||||
} else {
|
} else {
|
||||||
fScrollView->ResizeBy(0, -diff);
|
fScrollArea->ResizeBy(0, -diff);
|
||||||
fScrollView->MoveBy(0, diff);
|
fScrollArea->MoveBy(0, diff);
|
||||||
fToolBar->MoveBy(0, diff);
|
fToolBar->MoveBy(0, diff);
|
||||||
if (!visible)
|
if (!visible)
|
||||||
fToolBar->Hide();
|
fToolBar->Hide();
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ class BMenuBar;
|
|||||||
class BMenuItem;
|
class BMenuItem;
|
||||||
class BMessageRunner;
|
class BMessageRunner;
|
||||||
class BScrollBar;
|
class BScrollBar;
|
||||||
class BScrollView;
|
|
||||||
class ProgressWindow;
|
class ProgressWindow;
|
||||||
class ShowImageView;
|
class ShowImageView;
|
||||||
class ShowImageStatusView;
|
class ShowImageStatusView;
|
||||||
@@ -123,7 +122,8 @@ private:
|
|||||||
BMenu* fRatingMenu;
|
BMenu* fRatingMenu;
|
||||||
BToolBar* fToolBar;
|
BToolBar* fToolBar;
|
||||||
bool fToolBarVisible;
|
bool fToolBarVisible;
|
||||||
BScrollView* fScrollView;
|
BView* fScrollArea;
|
||||||
|
BScrollBar *fVScrollBar, *fHScrollBar;
|
||||||
ShowImageView* fImageView;
|
ShowImageView* fImageView;
|
||||||
ShowImageStatusView* fStatusView;
|
ShowImageStatusView* fStatusView;
|
||||||
ProgressWindow* fProgressWindow;
|
ProgressWindow* fProgressWindow;
|
||||||
|
|||||||
Reference in New Issue
Block a user