HaikuDepot: Scrollbars for content, document window look
* All text views that potentially need scrolling are now embedded into a CustomScrollView. That one controls a vertical BScrollBar only and has B_NO_BORDER frame. Since the regular BScrollView doesn't do some adjustments in this setup, the CustomScrollView takes care of moving the BScrollBar such that the B_DOCUMENT_WINDOW_LOOK resize handle does not obscure the bottom arrow button.
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
MainWindow::MainWindow(BRect frame)
|
MainWindow::MainWindow(BRect frame)
|
||||||
:
|
:
|
||||||
BWindow(frame, B_TRANSLATE_SYSTEM_NAME("HaikuDepot"),
|
BWindow(frame, B_TRANSLATE_SYSTEM_NAME("HaikuDepot"),
|
||||||
B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||||
B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
|
B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
|
||||||
{
|
{
|
||||||
BMenuBar* menuBar = new BMenuBar(B_TRANSLATE("Main Menu"));
|
BMenuBar* menuBar = new BMenuBar(B_TRANSLATE("Main Menu"));
|
||||||
@@ -40,7 +40,7 @@ MainWindow::MainWindow(BRect frame)
|
|||||||
fPackageListView = new PackageListView();
|
fPackageListView = new PackageListView();
|
||||||
fPackageInfoView = new PackageInfoView(&fPackageManager);
|
fPackageInfoView = new PackageInfoView(&fPackageManager);
|
||||||
|
|
||||||
fSplitView = new BSplitView(B_VERTICAL, B_USE_SMALL_SPACING);
|
fSplitView = new BSplitView(B_VERTICAL, 5.0f);
|
||||||
|
|
||||||
BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f)
|
BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f)
|
||||||
.Add(menuBar)
|
.Add(menuBar)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include <LayoutUtils.h>
|
#include <LayoutUtils.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <TabView.h>
|
#include <TabView.h>
|
||||||
|
#include <ScrollView.h>
|
||||||
#include <SpaceLayoutItem.h>
|
#include <SpaceLayoutItem.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
|
|
||||||
@@ -111,6 +112,41 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//! Layouts the scrollbar so it looks nice with no border and the document
|
||||||
|
// window look.
|
||||||
|
class CustomScrollView : public BScrollView {
|
||||||
|
public:
|
||||||
|
CustomScrollView(const char* name, BView* target)
|
||||||
|
:
|
||||||
|
BScrollView(name, target, 0, false, true, B_NO_BORDER)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void DoLayout()
|
||||||
|
{
|
||||||
|
BRect innerFrame = Bounds();
|
||||||
|
innerFrame.right -= B_V_SCROLL_BAR_WIDTH + 1;
|
||||||
|
|
||||||
|
BView* target = Target();
|
||||||
|
if (target != NULL) {
|
||||||
|
Target()->MoveTo(innerFrame.left, innerFrame.top);
|
||||||
|
Target()->ResizeTo(innerFrame.Width(), innerFrame.Height());
|
||||||
|
}
|
||||||
|
|
||||||
|
BScrollBar* scrollBar = ScrollBar(B_VERTICAL);
|
||||||
|
if (scrollBar != NULL) {
|
||||||
|
BRect rect = innerFrame;
|
||||||
|
rect.left = rect.right + 1;
|
||||||
|
rect.right = rect.left + B_V_SCROLL_BAR_WIDTH;
|
||||||
|
rect.bottom -= B_H_SCROLL_BAR_HEIGHT;
|
||||||
|
|
||||||
|
scrollBar->MoveTo(rect.left, rect.top);
|
||||||
|
scrollBar->ResizeTo(rect.Width(), rect.Height());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - AboutView
|
// #pragma mark - AboutView
|
||||||
|
|
||||||
|
|
||||||
@@ -421,19 +457,20 @@ public:
|
|||||||
AboutView()
|
AboutView()
|
||||||
:
|
:
|
||||||
BView("about view", 0),
|
BView("about view", 0),
|
||||||
fLayout(new BGroupLayout(B_HORIZONTAL)),
|
|
||||||
fEmailIcon("text/x-email"),
|
fEmailIcon("text/x-email"),
|
||||||
fWebsiteIcon("text/html")
|
fWebsiteIcon("text/html")
|
||||||
{
|
{
|
||||||
SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
|
SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
|
||||||
kContentTint));
|
kContentTint));
|
||||||
|
|
||||||
SetLayout(fLayout);
|
|
||||||
|
|
||||||
fDescriptionView = new BTextView("description view");
|
fDescriptionView = new BTextView("description view");
|
||||||
fDescriptionView->SetViewColor(ViewColor());
|
fDescriptionView->SetViewColor(ViewColor());
|
||||||
fDescriptionView->MakeEditable(false);
|
fDescriptionView->MakeEditable(false);
|
||||||
fDescriptionView->SetInsets(0.0f, be_plain_font->Size(), 0.0f, 0.0f);
|
const float textInset = be_plain_font->Size();
|
||||||
|
fDescriptionView->SetInsets(textInset, textInset, textInset, 0.0f);
|
||||||
|
|
||||||
|
BScrollView* scrollView = new CustomScrollView(
|
||||||
|
"description scroll view", fDescriptionView);
|
||||||
|
|
||||||
BFont smallFont;
|
BFont smallFont;
|
||||||
GetFont(&smallFont);
|
GetFont(&smallFont);
|
||||||
@@ -449,9 +486,8 @@ public:
|
|||||||
fWebsiteLinkView->SetFont(&smallFont);
|
fWebsiteLinkView->SetFont(&smallFont);
|
||||||
fWebsiteLinkView->SetHighColor(kLightBlack);
|
fWebsiteLinkView->SetHighColor(kLightBlack);
|
||||||
|
|
||||||
BLayoutBuilder::Group<>(fLayout)
|
BLayoutBuilder::Group<>(this, B_HORIZONTAL, 0.0f)
|
||||||
.Add(BSpaceLayoutItem::CreateHorizontalStrut(32.0f))
|
// .Add(BSpaceLayoutItem::CreateHorizontalStrut(32.0f))
|
||||||
.Add(fDescriptionView, 1.0f)
|
|
||||||
.AddGroup(B_VERTICAL, 0.0f)
|
.AddGroup(B_VERTICAL, 0.0f)
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
.AddGroup(B_HORIZONTAL)
|
.AddGroup(B_HORIZONTAL)
|
||||||
@@ -465,9 +501,13 @@ public:
|
|||||||
.End()
|
.End()
|
||||||
.End()
|
.End()
|
||||||
.End()
|
.End()
|
||||||
|
.Add(scrollView, 1.0f)
|
||||||
|
|
||||||
.SetExplicitMaxSize(BSize(B_SIZE_UNSET, B_SIZE_UNLIMITED))
|
.SetExplicitMaxSize(BSize(B_SIZE_UNSET, B_SIZE_UNLIMITED))
|
||||||
.SetInsets(B_USE_DEFAULT_SPACING, 0.0f, 0.0f, 0.0f)
|
.SetInsets(B_USE_DEFAULT_SPACING, -1.0f, -1.0f, -1.0f)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
scrollView->ScrollBar(B_VERTICAL)->ResizeBy(0, -B_H_SCROLL_BAR_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~AboutView()
|
virtual ~AboutView()
|
||||||
@@ -494,7 +534,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BGroupLayout* fLayout;
|
|
||||||
BTextView* fDescriptionView;
|
BTextView* fDescriptionView;
|
||||||
|
|
||||||
SharedBitmap fEmailIcon;
|
SharedBitmap fEmailIcon;
|
||||||
@@ -525,12 +564,16 @@ public:
|
|||||||
fTextView = new BTextView("ratings view");
|
fTextView = new BTextView("ratings view");
|
||||||
fTextView->SetViewColor(ViewColor());
|
fTextView->SetViewColor(ViewColor());
|
||||||
fTextView->MakeEditable(false);
|
fTextView->MakeEditable(false);
|
||||||
fTextView->SetInsets(0.0f, be_plain_font->Size(), 0.0f, 0.0f);
|
const float textInset = be_plain_font->Size();
|
||||||
|
fTextView->SetInsets(textInset, textInset, textInset, 0.0f);
|
||||||
|
|
||||||
|
BScrollView* scrollView = new CustomScrollView(
|
||||||
|
"ratings scroll view", fTextView);
|
||||||
|
|
||||||
BLayoutBuilder::Group<>(fLayout)
|
BLayoutBuilder::Group<>(fLayout)
|
||||||
.Add(BSpaceLayoutItem::CreateHorizontalStrut(32.0f))
|
.Add(BSpaceLayoutItem::CreateHorizontalStrut(32.0f))
|
||||||
.Add(fTextView, 1.0f)
|
.Add(scrollView, 1.0f)
|
||||||
.SetInsets(B_USE_DEFAULT_SPACING, 0.0f, 0.0f, 0.0f)
|
.SetInsets(B_USE_DEFAULT_SPACING, -1.0f, -1.0f, -1.0f)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -594,12 +637,16 @@ public:
|
|||||||
fTextView = new BTextView("changelog view");
|
fTextView = new BTextView("changelog view");
|
||||||
fTextView->SetViewColor(ViewColor());
|
fTextView->SetViewColor(ViewColor());
|
||||||
fTextView->MakeEditable(false);
|
fTextView->MakeEditable(false);
|
||||||
fTextView->SetInsets(0.0f, be_plain_font->Size(), 0.0f, 0.0f);
|
const float textInset = be_plain_font->Size();
|
||||||
|
fTextView->SetInsets(textInset, textInset, textInset, 0.0f);
|
||||||
|
|
||||||
|
BScrollView* scrollView = new CustomScrollView(
|
||||||
|
"changelog scroll view", fTextView);
|
||||||
|
|
||||||
BLayoutBuilder::Group<>(fLayout)
|
BLayoutBuilder::Group<>(fLayout)
|
||||||
.Add(BSpaceLayoutItem::CreateHorizontalStrut(32.0f))
|
.Add(BSpaceLayoutItem::CreateHorizontalStrut(32.0f))
|
||||||
.Add(fTextView, 1.0f)
|
.Add(scrollView, 1.0f)
|
||||||
.SetInsets(B_USE_DEFAULT_SPACING, 0.0f, 0.0f, 0.0f)
|
.SetInsets(B_USE_DEFAULT_SPACING, -1.0f, -1.0f, -1.0f)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user