mirror of
https://github.com/LNH-team/pico-launcher.git
synced 2026-06-02 00:56:55 +02:00
Initial commit
This commit is contained in:
98
arm9/source/romBrowser/views/IconButtonView.cpp
Normal file
98
arm9/source/romBrowser/views/IconButtonView.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
#include "common.h"
|
||||
#include "gui/input/InputProvider.h"
|
||||
#include "IconButtonView.h"
|
||||
|
||||
bool IconButtonView::HandleInput(const InputProvider& inputProvider, FocusManager& focusManager)
|
||||
{
|
||||
if (inputProvider.Triggered(InputKey::A))
|
||||
{
|
||||
if (_action)
|
||||
_action(this, _actionArg);
|
||||
return true;
|
||||
}
|
||||
return View::HandleInput(inputProvider, focusManager);
|
||||
}
|
||||
|
||||
bool IconButtonView::IsCircleBackgroundVisible() const
|
||||
{
|
||||
switch (_type)
|
||||
{
|
||||
case Type::Standard:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
case Type::Filled:
|
||||
case Type::Tonal:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// shouldn't happen
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
md::sys::color IconButtonView::GetCircleBackgroundColor() const
|
||||
{
|
||||
switch (_type)
|
||||
{
|
||||
case Type::Standard:
|
||||
{
|
||||
return _backgroundColor;
|
||||
}
|
||||
case Type::Filled:
|
||||
{
|
||||
if (_state == State::ToggleUnselected)
|
||||
return md::sys::color::surfaceContainerHighest;
|
||||
else
|
||||
return md::sys::color::primary;
|
||||
}
|
||||
case Type::Tonal:
|
||||
{
|
||||
if (_state == State::ToggleUnselected)
|
||||
return md::sys::color::surfaceContainerHighest;
|
||||
else
|
||||
return md::sys::color::secondaryContainer;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// shouldn't happen
|
||||
return md::sys::color::onSurfaceVariant;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
md::sys::color IconButtonView::GetForegroundColor() const
|
||||
{
|
||||
switch (_type)
|
||||
{
|
||||
case Type::Standard:
|
||||
{
|
||||
if (_state == State::ToggleSelected)
|
||||
return md::sys::color::primary;
|
||||
else
|
||||
return md::sys::color::onSurfaceVariant;
|
||||
}
|
||||
case Type::Filled:
|
||||
{
|
||||
if (_state == State::ToggleUnselected)
|
||||
return md::sys::color::primary;
|
||||
else
|
||||
return md::sys::color::onPrimary;
|
||||
}
|
||||
case Type::Tonal:
|
||||
{
|
||||
if (_state == State::ToggleUnselected)
|
||||
return md::sys::color::onSurfaceVariant;
|
||||
else
|
||||
return md::sys::color::onSecondaryContainer;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// shouldn't happen
|
||||
return md::sys::color::onSurfaceVariant;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user