mirror of
https://github.com/LNH-team/pico-launcher.git
synced 2026-06-02 09:06:54 +02:00
Add touch input support, add fast scrolling support for coverflow display mode, fix use after free bug in banner list mode
This commit is contained in:
@@ -12,7 +12,7 @@ CustomAppBarView::CustomAppBarView(int x, int y, Orientation orientation,
|
||||
{
|
||||
for (int i = 0; i < _startButtonCount + _endButtonCount; i++)
|
||||
{
|
||||
_buttons[i] = SharedPtr<IconButton3DView>::MakeShared(
|
||||
_buttons[i] = IconButton3DView::CreateShared(
|
||||
IconButtonView::Type::Tonal,
|
||||
IconButtonView::State::NoToggle,
|
||||
md::sys::color::inverseOnSurface,
|
||||
|
||||
@@ -3,14 +3,16 @@
|
||||
|
||||
class CustomAppBarView : public AppBarView
|
||||
{
|
||||
public:
|
||||
CustomAppBarView(int x, int y, Orientation orientation,
|
||||
int startButtonCount, int endButtonCount, const MaterialColorScheme* materialColorScheme,
|
||||
u32 scrimTexVramOffset, u32 scrimPlttVramOffset);
|
||||
SHARED_ONLY(CustomAppBarView)
|
||||
|
||||
public:
|
||||
void Draw(GraphicsContext& graphicsContext) override;
|
||||
|
||||
private:
|
||||
u32 _scrimTexVramOffset = 0;
|
||||
u32 _scrimPlttVramOffset = 0;
|
||||
|
||||
CustomAppBarView(int x, int y, Orientation orientation,
|
||||
int startButtonCount, int endButtonCount, const MaterialColorScheme* materialColorScheme,
|
||||
u32 scrimTexVramOffset, u32 scrimPlttVramOffset);
|
||||
};
|
||||
|
||||
@@ -31,16 +31,17 @@
|
||||
#define LINE_HEIGHT 16
|
||||
#define MAX_LINE_STRING_LENGTH 50
|
||||
|
||||
CustomBannerListItemView::CustomBannerListItemView(const CustomThemeInfo* customThemeInfo,
|
||||
const MaterialColorScheme* materialColorScheme, const IFontRepository* fontRepository,
|
||||
u32 texVramOffset, u32 plttVramOffset, u32 selectedTexVramOffset, u32 selectedPlttVramOffset,
|
||||
CustomBannerListItemView::CustomBannerListItemView(std::unique_ptr<RomBrowserItemViewModel> viewModel,
|
||||
const CustomThemeInfo* customThemeInfo, const MaterialColorScheme* materialColorScheme,
|
||||
const IFontRepository* fontRepository, u32 texVramOffset, u32 plttVramOffset,
|
||||
u32 selectedTexVramOffset, u32 selectedPlttVramOffset,
|
||||
VBlankTextureLoader* vblankTextureLoader)
|
||||
: BannerListItemView(
|
||||
std::make_unique<Label3DView>(LINE_WIDTH, LINE_HEIGHT, MAX_LINE_STRING_LENGTH,
|
||||
: BannerListItemView(std::move(viewModel),
|
||||
Label3DView::CreateShared(LINE_WIDTH, LINE_HEIGHT, MAX_LINE_STRING_LENGTH,
|
||||
fontRepository->GetFont(FontType::Medium10), vblankTextureLoader),
|
||||
std::make_unique<Label3DView>(LINE_WIDTH, LINE_HEIGHT, MAX_LINE_STRING_LENGTH,
|
||||
Label3DView::CreateShared(LINE_WIDTH, LINE_HEIGHT, MAX_LINE_STRING_LENGTH,
|
||||
fontRepository->GetFont(FontType::Regular10), vblankTextureLoader),
|
||||
std::make_unique<Label3DView>(LINE_WIDTH, LINE_HEIGHT, MAX_LINE_STRING_LENGTH,
|
||||
Label3DView::CreateShared(LINE_WIDTH, LINE_HEIGHT, MAX_LINE_STRING_LENGTH,
|
||||
fontRepository->GetFont(FontType::Regular10), vblankTextureLoader))
|
||||
, _customThemeInfo(customThemeInfo)
|
||||
, _materialColorScheme(materialColorScheme)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "gui/views/LabelView.h"
|
||||
#include "../../views/BannerListItemView.h"
|
||||
#include "romBrowser/views/BannerListItemView.h"
|
||||
|
||||
class MaterialColorScheme;
|
||||
class IFontRepository;
|
||||
@@ -8,11 +8,9 @@ class CustomThemeInfo;
|
||||
|
||||
class CustomBannerListItemView : public BannerListItemView
|
||||
{
|
||||
public:
|
||||
CustomBannerListItemView(const CustomThemeInfo* customThemeInfo, const MaterialColorScheme* materialColorScheme,
|
||||
const IFontRepository* fontRepository, u32 texVramOffset, u32 plttVramOffset,
|
||||
u32 selectedTexVramOffset, u32 selectedPlttVramOffset, VBlankTextureLoader* vblankTextureLoader);
|
||||
SHARED_ONLY(CustomBannerListItemView)
|
||||
|
||||
public:
|
||||
void Draw(GraphicsContext& graphicsContext) override;
|
||||
|
||||
Rectangle GetBounds() const override
|
||||
@@ -27,4 +25,9 @@ private:
|
||||
u32 _plttVramOffset = 0;
|
||||
u32 _selectedTexVramOffset = 0;
|
||||
u32 _selectedPlttVramOffset = 0;
|
||||
|
||||
CustomBannerListItemView(std::unique_ptr<RomBrowserItemViewModel> viewModel, const CustomThemeInfo* customThemeInfo,
|
||||
const MaterialColorScheme* materialColorScheme, const IFontRepository* fontRepository,
|
||||
u32 texVramOffset, u32 plttVramOffset, u32 selectedTexVramOffset, u32 selectedPlttVramOffset,
|
||||
VBlankTextureLoader* vblankTextureLoader);
|
||||
};
|
||||
|
||||
@@ -6,26 +6,30 @@
|
||||
#include "CustomFileInfoView.h"
|
||||
|
||||
CustomFileInfoView::CustomFileInfoView(const CustomThemeInfo* customThemeInfo, const IFontRepository* fontRepository)
|
||||
: _firstLine(customThemeInfo->topBannerTextLine0Info.GetWidth(), 16, 50, fontRepository->GetFont(FontType::Medium11))
|
||||
, _secondLine(customThemeInfo->topBannerTextLine1Info.GetWidth(), 16, 50, fontRepository->GetFont(FontType::Regular10))
|
||||
, _thirdLine(customThemeInfo->topBannerTextLine2Info.GetWidth(), 16, 50, fontRepository->GetFont(FontType::Regular10))
|
||||
, _filenameLabelView(customThemeInfo->topFileNameTextInfo.GetWidth(), 16, 256, fontRepository->GetFont(FontType::Medium7_5))
|
||||
: _firstLine(Label2DView::CreateShared(
|
||||
customThemeInfo->topBannerTextLine0Info.GetWidth(), 16, 50, fontRepository->GetFont(FontType::Medium11)))
|
||||
, _secondLine(Label2DView::CreateShared(
|
||||
customThemeInfo->topBannerTextLine1Info.GetWidth(), 16, 50, fontRepository->GetFont(FontType::Regular10)))
|
||||
, _thirdLine(Label2DView::CreateShared(
|
||||
customThemeInfo->topBannerTextLine2Info.GetWidth(), 16, 50, fontRepository->GetFont(FontType::Regular10)))
|
||||
, _filenameLabelView(Label2DView::CreateShared(
|
||||
customThemeInfo->topFileNameTextInfo.GetWidth(), 16, 256, fontRepository->GetFont(FontType::Medium7_5)))
|
||||
, _customThemeInfo(customThemeInfo)
|
||||
{
|
||||
AddChildTail(&_firstLine);
|
||||
AddChildTail(&_secondLine);
|
||||
AddChildTail(&_thirdLine);
|
||||
_filenameLabelView.SetEllipsisStyle(LabelView::EllipsisStyle::Marquee);
|
||||
AddChildTail(&_filenameLabelView);
|
||||
AddChildTail(_firstLine.GetPointer());
|
||||
AddChildTail(_secondLine.GetPointer());
|
||||
AddChildTail(_thirdLine.GetPointer());
|
||||
_filenameLabelView->SetEllipsisStyle(LabelView::EllipsisStyle::Marquee);
|
||||
AddChildTail(_filenameLabelView.GetPointer());
|
||||
}
|
||||
|
||||
void CustomFileInfoView::Update()
|
||||
{
|
||||
BannerView::Update();
|
||||
_firstLine.SetPosition(_customThemeInfo->topBannerTextLine0Info.GetPosition());
|
||||
_secondLine.SetPosition(_customThemeInfo->topBannerTextLine1Info.GetPosition());
|
||||
_thirdLine.SetPosition(_customThemeInfo->topBannerTextLine2Info.GetPosition());
|
||||
_filenameLabelView.SetPosition(_customThemeInfo->topFileNameTextInfo.GetPosition());
|
||||
_firstLine->SetPosition(_customThemeInfo->topBannerTextLine0Info.GetPosition());
|
||||
_secondLine->SetPosition(_customThemeInfo->topBannerTextLine1Info.GetPosition());
|
||||
_thirdLine->SetPosition(_customThemeInfo->topBannerTextLine2Info.GetPosition());
|
||||
_filenameLabelView->SetPosition(_customThemeInfo->topFileNameTextInfo.GetPosition());
|
||||
if (_icon)
|
||||
{
|
||||
_icon->SetPosition(_customThemeInfo->topIconInfo.GetPosition());
|
||||
@@ -35,14 +39,14 @@ void CustomFileInfoView::Update()
|
||||
|
||||
void CustomFileInfoView::Draw(GraphicsContext& graphicsContext)
|
||||
{
|
||||
_firstLine.SetBackgroundColor(_customThemeInfo->topBannerTextLine0Info.GetBlendColor());
|
||||
_firstLine.SetForegroundColor(_customThemeInfo->topBannerTextLine0Info.GetTextColor());
|
||||
_secondLine.SetBackgroundColor(_customThemeInfo->topBannerTextLine1Info.GetBlendColor());
|
||||
_secondLine.SetForegroundColor(_customThemeInfo->topBannerTextLine1Info.GetTextColor());
|
||||
_thirdLine.SetBackgroundColor(_customThemeInfo->topBannerTextLine2Info.GetBlendColor());
|
||||
_thirdLine.SetForegroundColor(_customThemeInfo->topBannerTextLine2Info.GetTextColor());
|
||||
_filenameLabelView.SetBackgroundColor(_customThemeInfo->topFileNameTextInfo.GetBlendColor());
|
||||
_filenameLabelView.SetForegroundColor(_customThemeInfo->topFileNameTextInfo.GetTextColor());
|
||||
_firstLine->SetBackgroundColor(_customThemeInfo->topBannerTextLine0Info.GetBlendColor());
|
||||
_firstLine->SetForegroundColor(_customThemeInfo->topBannerTextLine0Info.GetTextColor());
|
||||
_secondLine->SetBackgroundColor(_customThemeInfo->topBannerTextLine1Info.GetBlendColor());
|
||||
_secondLine->SetForegroundColor(_customThemeInfo->topBannerTextLine1Info.GetTextColor());
|
||||
_thirdLine->SetBackgroundColor(_customThemeInfo->topBannerTextLine2Info.GetBlendColor());
|
||||
_thirdLine->SetForegroundColor(_customThemeInfo->topBannerTextLine2Info.GetTextColor());
|
||||
_filenameLabelView->SetBackgroundColor(_customThemeInfo->topFileNameTextInfo.GetBlendColor());
|
||||
_filenameLabelView->SetForegroundColor(_customThemeInfo->topFileNameTextInfo.GetTextColor());
|
||||
|
||||
BannerView::Draw(graphicsContext);
|
||||
|
||||
|
||||
@@ -9,53 +9,53 @@ class CustomThemeInfo;
|
||||
|
||||
class CustomFileInfoView : public BannerView
|
||||
{
|
||||
public:
|
||||
CustomFileInfoView(const CustomThemeInfo* customThemeInfo, const IFontRepository* fontRepository);
|
||||
SHARED_ONLY(CustomFileInfoView)
|
||||
|
||||
public:
|
||||
void Update() override;
|
||||
void Draw(GraphicsContext& graphicsContext) override;
|
||||
|
||||
void SetFirstLineAsync(TaskQueueBase* taskQueue, const char* firstLine, bool ellipsis) override
|
||||
{
|
||||
_firstLine.SetEllipsisStyle(ellipsis ? LabelView::EllipsisStyle::Ellipsis : LabelView::EllipsisStyle::None);
|
||||
_firstLine->SetEllipsisStyle(ellipsis ? LabelView::EllipsisStyle::Ellipsis : LabelView::EllipsisStyle::None);
|
||||
if (taskQueue)
|
||||
_firstLine.SetTextAsync(taskQueue, firstLine);
|
||||
_firstLine->SetTextAsync(taskQueue, firstLine);
|
||||
else
|
||||
_firstLine.SetText(firstLine);
|
||||
_firstLine->SetText(firstLine);
|
||||
}
|
||||
|
||||
void SetFirstLineAsync(TaskQueueBase* taskQueue, const char16_t* firstLine, u32 length, bool ellipsis) override
|
||||
{
|
||||
_firstLine.SetEllipsisStyle(ellipsis ? LabelView::EllipsisStyle::Ellipsis : LabelView::EllipsisStyle::None);
|
||||
_firstLine->SetEllipsisStyle(ellipsis ? LabelView::EllipsisStyle::Ellipsis : LabelView::EllipsisStyle::None);
|
||||
if (taskQueue)
|
||||
_firstLine.SetTextAsync(taskQueue, firstLine, length);
|
||||
_firstLine->SetTextAsync(taskQueue, firstLine, length);
|
||||
else
|
||||
_firstLine.SetText(firstLine, length);
|
||||
_firstLine->SetText(firstLine, length);
|
||||
}
|
||||
|
||||
void SetSecondLineAsync(TaskQueueBase* taskQueue, const char16_t* secondLine, u32 length) override
|
||||
{
|
||||
if (taskQueue)
|
||||
_secondLine.SetTextAsync(taskQueue, secondLine, length);
|
||||
_secondLine->SetTextAsync(taskQueue, secondLine, length);
|
||||
else
|
||||
_secondLine.SetText(secondLine, length);
|
||||
_secondLine->SetText(secondLine, length);
|
||||
}
|
||||
|
||||
void SetThirdLineAsync(TaskQueueBase* taskQueue, const char16_t* thirdLine, u32 length) override
|
||||
{
|
||||
if (taskQueue)
|
||||
_thirdLine.SetTextAsync(taskQueue, thirdLine, length);
|
||||
_thirdLine->SetTextAsync(taskQueue, thirdLine, length);
|
||||
else
|
||||
_thirdLine.SetText(thirdLine, length);
|
||||
_thirdLine->SetText(thirdLine, length);
|
||||
}
|
||||
|
||||
void SetFileNameAsync(TaskQueueBase* taskQueue, const TCHAR* fileName, bool useAsTitle) override
|
||||
{
|
||||
BannerView::SetFileNameAsync(taskQueue, fileName, useAsTitle);
|
||||
if (taskQueue)
|
||||
_filenameLabelView.SetTextAsync(taskQueue, fileName);
|
||||
_filenameLabelView->SetTextAsync(taskQueue, fileName);
|
||||
else
|
||||
_filenameLabelView.SetText(fileName);
|
||||
_filenameLabelView->SetText(fileName);
|
||||
}
|
||||
|
||||
Rectangle GetBounds() const override
|
||||
@@ -64,9 +64,11 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
Label2DView _firstLine;
|
||||
Label2DView _secondLine;
|
||||
Label2DView _thirdLine;
|
||||
Label2DView _filenameLabelView;
|
||||
SharedPtr<Label2DView> _firstLine;
|
||||
SharedPtr<Label2DView> _secondLine;
|
||||
SharedPtr<Label2DView> _thirdLine;
|
||||
SharedPtr<Label2DView> _filenameLabelView;
|
||||
const CustomThemeInfo* _customThemeInfo;
|
||||
|
||||
CustomFileInfoView(const CustomThemeInfo* customThemeInfo, const IFontRepository* fontRepository);
|
||||
};
|
||||
|
||||
@@ -26,8 +26,8 @@ void CustomIconGridItemView::Draw(GraphicsContext& graphicsContext)
|
||||
false, false, false, GX_DEPTH_FUNC_LESS, false, 31, 0);
|
||||
Gx::Color(0x7FFF);
|
||||
|
||||
u32 tex = _isFocused ? _selectedTexVramOffset : _texVramOffset;
|
||||
u32 pltt = _isFocused ? _selectedPlttVramOffset : _plttVramOffset;
|
||||
u32 tex = (_isFocused || _inputHandler.IsPenDown()) ? _selectedTexVramOffset : _texVramOffset;
|
||||
u32 pltt = (_isFocused || _inputHandler.IsPenDown()) ? _selectedPlttVramOffset : _plttVramOffset;
|
||||
Gx::TexImageParam(tex >> 3, false, false, false, false, GX_TEXSIZE_64,
|
||||
GX_TEXSIZE_64, GX_TEXFMT_A3I5, false, GX_TEXGEN_NONE);
|
||||
Gx::TexPlttBase(pltt >> 4);
|
||||
|
||||
@@ -5,12 +5,9 @@ class CustomThemeInfo;
|
||||
|
||||
class CustomIconGridItemView : public IconGridItemView
|
||||
{
|
||||
public:
|
||||
CustomIconGridItemView(const CustomThemeInfo* customThemeInfo, u32 texVramOffset, u32 plttVramOffset,
|
||||
u32 selectedTexVramOffset, u32 selectedPlttVramOffset)
|
||||
: _customThemeInfo(customThemeInfo), _texVramOffset(texVramOffset), _plttVramOffset(plttVramOffset)
|
||||
, _selectedTexVramOffset(selectedTexVramOffset), _selectedPlttVramOffset(selectedPlttVramOffset) { }
|
||||
SHARED_ONLY(CustomIconGridItemView)
|
||||
|
||||
public:
|
||||
void Draw(GraphicsContext& graphicsContext) override;
|
||||
|
||||
Rectangle GetBounds() const override
|
||||
@@ -24,4 +21,9 @@ private:
|
||||
u32 _plttVramOffset;
|
||||
u32 _selectedTexVramOffset;
|
||||
u32 _selectedPlttVramOffset;
|
||||
|
||||
CustomIconGridItemView(std::unique_ptr<RomBrowserItemViewModel> viewModel, const CustomThemeInfo* customThemeInfo,
|
||||
u32 texVramOffset, u32 plttVramOffset, u32 selectedTexVramOffset, u32 selectedPlttVramOffset)
|
||||
: IconGridItemView(std::move(viewModel)), _customThemeInfo(customThemeInfo), _texVramOffset(texVramOffset), _plttVramOffset(plttVramOffset)
|
||||
, _selectedTexVramOffset(selectedTexVramOffset), _selectedPlttVramOffset(selectedPlttVramOffset) { }
|
||||
};
|
||||
@@ -21,15 +21,16 @@ public:
|
||||
const IFontRepository* fontRepository)
|
||||
: _customThemeInfo(customThemeInfo), _materialColorScheme(materialColorScheme), _fontRepository(fontRepository) { }
|
||||
|
||||
SharedPtr<IconGridItemView> CreateIconGridItemView() const override
|
||||
SharedPtr<IconGridItemView> CreateIconGridItemView(std::unique_ptr<RomBrowserItemViewModel> viewModel) const override
|
||||
{
|
||||
return SharedPtr<CustomIconGridItemView>::MakeShared(_customThemeInfo, _gridCellTexVramOffset, _gridCellPlttVramOffset,
|
||||
return CustomIconGridItemView::CreateShared(std::move(viewModel), _customThemeInfo, _gridCellTexVramOffset, _gridCellPlttVramOffset,
|
||||
_gridCellSelectedTexVramOffset, _gridCellSelectedPlttVramOffset);
|
||||
}
|
||||
|
||||
SharedPtr<BannerListItemView> CreateBannerListItemView(VBlankTextureLoader* vblankTextureLoader) const override
|
||||
SharedPtr<BannerListItemView> CreateBannerListItemView(std::unique_ptr<RomBrowserItemViewModel> viewModel,
|
||||
VBlankTextureLoader* vblankTextureLoader) const override
|
||||
{
|
||||
return SharedPtr<CustomBannerListItemView>::MakeShared(_customThemeInfo, _materialColorScheme, _fontRepository,
|
||||
return CustomBannerListItemView::CreateShared(std::move(viewModel), _customThemeInfo, _materialColorScheme, _fontRepository,
|
||||
_bannerListCellTexVramOffset, _bannerListCellPlttVramOffset,
|
||||
_bannerListCellSelectedTexVramOffset, _bannerListCellSelectedPlttVramOffset, vblankTextureLoader);
|
||||
}
|
||||
@@ -39,16 +40,16 @@ public:
|
||||
return BannerListItemView::VramToken(0);
|
||||
}
|
||||
|
||||
std::unique_ptr<AppBarView> CreateAppBarView(int x, int y, AppBarView::Orientation orientation,
|
||||
SharedPtr<AppBarView> CreateAppBarView(int x, int y, AppBarView::Orientation orientation,
|
||||
int startButtonCount, int endButtonCount) const override
|
||||
{
|
||||
return std::make_unique<CustomAppBarView>(x, y, orientation, startButtonCount, endButtonCount, _materialColorScheme,
|
||||
return CustomAppBarView::CreateShared(x, y, orientation, startButtonCount, endButtonCount, _materialColorScheme,
|
||||
_scrimTexVramOffset, _scrimPlttVramOffset);
|
||||
}
|
||||
|
||||
std::unique_ptr<BannerView> CreateFileInfoView() const override
|
||||
SharedPtr<BannerView> CreateFileInfoView() const override
|
||||
{
|
||||
return std::make_unique<CustomFileInfoView>(_customThemeInfo, _fontRepository);
|
||||
return CustomFileInfoView::CreateShared(_customThemeInfo, _fontRepository);
|
||||
}
|
||||
|
||||
SharedPtr<RecyclerViewBase> CreateCoverFlowRecyclerView() const override
|
||||
@@ -60,7 +61,7 @@ public:
|
||||
RomBrowserViewModel* viewModel, const IThemeFileIconFactory* themeFileIconFactory,
|
||||
VBlankTextureLoader* vblankTextureLoader) const override
|
||||
{
|
||||
return SharedPtr<CoverFlowFileRecyclerAdapter>::MakeShared(
|
||||
return SharedPtr<CoverFlowFileRecyclerAdapter>::MakeShared(viewModel->GetRomBrowserController(),
|
||||
&viewModel->GetFileInfoManager(), viewModel->GetIoTaskQueue(),
|
||||
themeFileIconFactory, this, vblankTextureLoader, &viewModel->GetCoverRepository());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user