HaikuDepot: Fix Scrollbar
The scrollbar on some areas is misaligned with the window frame. This change will fix this. The class that implements the scroll- view is also shaded by two class definitions. This is also fixed by breaking the definition into its own file. Fixes #16169 Change-Id: I71372906e165672c9b697ab98181ecfb1b09fb43 Reviewed-on: https://review.haiku-os.org/c/haiku/+/4849 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
parent
7323d0a21d
commit
c580ec7312
@ -122,6 +122,7 @@ local applicationSources =
|
||||
DeskbarLink.cpp
|
||||
FeaturedPackagesView.cpp
|
||||
FilterView.cpp
|
||||
GeneralContentScrollView.cpp
|
||||
IconTarPtr.cpp
|
||||
IncrementViewCounterProcess.cpp
|
||||
JobStateListener.cpp
|
||||
|
40
src/apps/haikudepot/ui/GeneralContentScrollView.cpp
Normal file
40
src/apps/haikudepot/ui/GeneralContentScrollView.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
|
||||
* Copyright 2018-2022, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include "GeneralContentScrollView.h"
|
||||
|
||||
|
||||
GeneralContentScrollView::GeneralContentScrollView(
|
||||
const char* name, BView* target)
|
||||
:
|
||||
BScrollView(name, target, 0, false, true, B_NO_BORDER)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GeneralContentScrollView::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;
|
||||
|
||||
scrollBar->MoveTo(rect.left, rect.top);
|
||||
scrollBar->ResizeTo(rect.Width(), rect.Height());
|
||||
}
|
||||
}
|
23
src/apps/haikudepot/ui/GeneralContentScrollView.h
Normal file
23
src/apps/haikudepot/ui/GeneralContentScrollView.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
|
||||
* Copyright 2019-2022, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef GENERAL_CONTENT_SCROLL_VIEW_H
|
||||
#define GENERAL_CONTENT_SCROLL_VIEW_H
|
||||
|
||||
#include <ScrollView.h>
|
||||
|
||||
|
||||
/*! Layouts the scrollbar so it looks nice with no border and the
|
||||
document window look.
|
||||
*/
|
||||
|
||||
class GeneralContentScrollView : public BScrollView {
|
||||
public:
|
||||
GeneralContentScrollView(const char* name, BView* target);
|
||||
|
||||
virtual void DoLayout();
|
||||
};
|
||||
|
||||
#endif // GENERAL_CONTENT_SCROLL_VIEW_H
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2015, TigerKid001.
|
||||
* Copyright 2020, Andrew Lindesay <apl@lindesay.co.nz>
|
||||
* Copyright 2020-2022, Andrew Lindesay <apl@lindesay.co.nz>
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
#include <StringFormat.h>
|
||||
#include <StringItem.h>
|
||||
|
||||
#include "GeneralContentScrollView.h"
|
||||
#include "Logger.h"
|
||||
|
||||
#include <package/PackageDefs.h>
|
||||
@ -42,40 +43,6 @@ using BPackageKit::BHPKG::BPackageReader;
|
||||
#define B_TRANSLATION_CONTEXT "PackageContentsView"
|
||||
|
||||
|
||||
//! 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 - PackageEntryItem
|
||||
|
||||
|
||||
@ -237,8 +204,8 @@ PackageContentsView::PackageContentsView(const char* name)
|
||||
fContentListView = new BOutlineListView("content list view",
|
||||
B_SINGLE_SELECTION_LIST);
|
||||
|
||||
BScrollView* scrollView = new CustomScrollView("contents scroll view",
|
||||
fContentListView);
|
||||
BScrollView* scrollView = new GeneralContentScrollView(
|
||||
"contents scroll view", fContentListView);
|
||||
|
||||
BLayoutBuilder::Group<>(this)
|
||||
.Add(scrollView, 1.0f)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
|
||||
* Copyright 2018-2021, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||
* Copyright 2018-2022, Andrew Lindesay <apl@lindesay.co.nz>.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
#include <package/hpkg/PackageEntry.h>
|
||||
|
||||
#include "BitmapView.h"
|
||||
#include "GeneralContentScrollView.h"
|
||||
#include "LinkView.h"
|
||||
#include "LinkedBitmapView.h"
|
||||
#include "LocaleUtils.h"
|
||||
@ -65,52 +66,17 @@ enum {
|
||||
static const float kContentTint = (B_NO_TINT + B_LIGHTEN_1_TINT) / 2.0f;
|
||||
|
||||
|
||||
//! 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());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class RatingsScrollView : public CustomScrollView {
|
||||
class RatingsScrollView : public GeneralContentScrollView {
|
||||
public:
|
||||
RatingsScrollView(const char* name, BView* target)
|
||||
:
|
||||
CustomScrollView(name, target)
|
||||
GeneralContentScrollView(name, target)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void DoLayout()
|
||||
{
|
||||
CustomScrollView::DoLayout();
|
||||
GeneralContentScrollView::DoLayout();
|
||||
|
||||
BScrollBar* scrollBar = ScrollBar(B_VERTICAL);
|
||||
BView* target = Target();
|
||||
@ -685,7 +651,7 @@ public:
|
||||
fDescriptionView->SetViewUIColor(ViewUIColor(), kContentTint);
|
||||
fDescriptionView->SetInsets(be_plain_font->Size());
|
||||
|
||||
BScrollView* scrollView = new CustomScrollView(
|
||||
BScrollView* scrollView = new GeneralContentScrollView(
|
||||
"description scroll view", fDescriptionView);
|
||||
|
||||
BFont smallFont;
|
||||
@ -1165,7 +1131,7 @@ public:
|
||||
fTextView->SetLowUIColor(ViewUIColor());
|
||||
fTextView->SetInsets(be_plain_font->Size());
|
||||
|
||||
BScrollView* scrollView = new CustomScrollView(
|
||||
BScrollView* scrollView = new GeneralContentScrollView(
|
||||
"changelog scroll view", fTextView);
|
||||
|
||||
BLayoutBuilder::Group<>(this)
|
||||
|
Loading…
Reference in New Issue
Block a user