Skip to content

Commit

Permalink
HaikuDepot: Scrollbars for content, document window look
Browse files Browse the repository at this point in the history
 * 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.
  • Loading branch information
stippi committed Aug 4, 2013
1 parent a8b89c6 commit 127061e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/apps/haiku-depot/MainWindow.cpp
Expand Up @@ -30,7 +30,7 @@
MainWindow::MainWindow(BRect frame)
:
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)
{
BMenuBar* menuBar = new BMenuBar(B_TRANSLATE("Main Menu"));
Expand All @@ -40,7 +40,7 @@ MainWindow::MainWindow(BRect frame)
fPackageListView = new PackageListView();
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)
.Add(menuBar)
Expand Down
77 changes: 62 additions & 15 deletions src/apps/haiku-depot/PackageInfoView.cpp
Expand Up @@ -17,6 +17,7 @@
#include <LayoutUtils.h>
#include <Message.h>
#include <TabView.h>
#include <ScrollView.h>
#include <SpaceLayoutItem.h>
#include <StringView.h>

Expand Down Expand Up @@ -111,6 +112,41 @@ class BitmapView : public BView {
};


//! 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


Expand Down Expand Up @@ -421,19 +457,20 @@ class AboutView : public BView {
AboutView()
:
BView("about view", 0),
fLayout(new BGroupLayout(B_HORIZONTAL)),
fEmailIcon("text/x-email"),
fWebsiteIcon("text/html")
{
SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
kContentTint));

SetLayout(fLayout);

fDescriptionView = new BTextView("description view");
fDescriptionView->SetViewColor(ViewColor());
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;
GetFont(&smallFont);
Expand All @@ -449,9 +486,8 @@ class AboutView : public BView {
fWebsiteLinkView->SetFont(&smallFont);
fWebsiteLinkView->SetHighColor(kLightBlack);

BLayoutBuilder::Group<>(fLayout)
.Add(BSpaceLayoutItem::CreateHorizontalStrut(32.0f))
.Add(fDescriptionView, 1.0f)
BLayoutBuilder::Group<>(this, B_HORIZONTAL, 0.0f)
// .Add(BSpaceLayoutItem::CreateHorizontalStrut(32.0f))
.AddGroup(B_VERTICAL, 0.0f)
.AddGlue()
.AddGroup(B_HORIZONTAL)
Expand All @@ -465,9 +501,13 @@ class AboutView : public BView {
.End()
.End()
.End()
.Add(scrollView, 1.0f)

.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()
Expand All @@ -494,7 +534,6 @@ class AboutView : public BView {
}

private:
BGroupLayout* fLayout;
BTextView* fDescriptionView;

SharedBitmap fEmailIcon;
Expand Down Expand Up @@ -525,12 +564,16 @@ class UserRatingsView : public BView {
fTextView = new BTextView("ratings view");
fTextView->SetViewColor(ViewColor());
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)
.Add(BSpaceLayoutItem::CreateHorizontalStrut(32.0f))
.Add(fTextView, 1.0f)
.SetInsets(B_USE_DEFAULT_SPACING, 0.0f, 0.0f, 0.0f)
.Add(scrollView, 1.0f)
.SetInsets(B_USE_DEFAULT_SPACING, -1.0f, -1.0f, -1.0f)
;
}

Expand Down Expand Up @@ -594,12 +637,16 @@ class ChangelogView : public BView {
fTextView = new BTextView("changelog view");
fTextView->SetViewColor(ViewColor());
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)
.Add(BSpaceLayoutItem::CreateHorizontalStrut(32.0f))
.Add(fTextView, 1.0f)
.SetInsets(B_USE_DEFAULT_SPACING, 0.0f, 0.0f, 0.0f)
.Add(scrollView, 1.0f)
.SetInsets(B_USE_DEFAULT_SPACING, -1.0f, -1.0f, -1.0f)
;
}

Expand Down

0 comments on commit 127061e

Please sign in to comment.