added ROM image widget to tab order and moved event handling into it

added launcher list paging events for controllers
This commit is contained in:
thrust26 2023-09-01 11:44:59 +02:00
parent 68833dc904
commit 2ab1fc7107
6 changed files with 85 additions and 59 deletions

View File

@ -2107,23 +2107,17 @@
<td>-</td>
</tr>
<tr>
<td>Select previous image</td>
<td>Control + Left arrow</td>
<td>Control + Left arrow</td>
<td>Move Page Up</td>
<td>Page Up</td>
<td>Page Up</td>
<td>Button 1/X + Left</td>
</tr>
<tr>
<td>Select next image</td>
<td>Control + Right arrow</td>
<td>Control + Right arrow</td>
<td>Move Page Down</td>
<td>Page Down</td>
<td>Page Down</td>
<td>Button 1/X + Right</td>
</tr>
<tr>
<td>Toogle image zoom</td>
<td>Control + Return</td>
<td>Control + Return</td>
<td>Button 1/X + Up</td>
</tr>
<tr>
<td>Remove from 'Recently Played' or 'Most Popular' folder</td>
<td>Control + X</td>

View File

@ -53,6 +53,8 @@ Settings::Settings()
setPermanent(SETTINGS_VERSION_KEY, 0);
setPermanent("stella.version", "6.2.1");
//setTemporary("minimal_ui", 1); // enable for minimal UI testing only
// Video-related options
setPermanent("video", "");
setPermanent("speed", "1.0");

View File

@ -83,7 +83,8 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
addPathWidgets(ypos);
addFilteringWidgets(ypos); //-- filtering widget line has file count
}
mySelectedItem = addRomWidgets(ypos) - 1; // Highlight 'Rom Listing'
mySelectedItem = addRomWidgets(ypos) - (myUseMinimalUI ? 1 : 2); // Highlight 'Rom Listing'
if(!myUseMinimalUI && bottomButtons)
addButtonWidgets(ypos);
myNavigationBar->setList(myList);
@ -105,7 +106,7 @@ void LauncherDialog::addTitleWidget(int &ypos)
#if defined(RETRON77)
ver << " for RetroN 77";
#endif
new StaticTextWidget(this, _font, 0, ypos, _w, fontHeight,
new StaticTextWidget(this, _font, 1, ypos, _w - 2, fontHeight,
ver.str(), TextAlign::Center);
ypos += fontHeight + VGAP;
}
@ -250,11 +251,11 @@ void LauncherDialog::addPathWidgets(int& ypos)
// Show the files counter
myShortCount = true;
xpos = _w - HBORDER - lwFound - LBL_GAP / 2;
myRomCount = new StaticTextWidget(this, _font, xpos, ypos,
myRomCount = new StaticTextWidget(this, _font, xpos, ypos - 1,
lwFound, fontHeight, "", TextAlign::Right);
auto* e = new EditTextWidget(this, _font, myNavigationBar->getRight() - 1,
ypos - btnYOfs, lwFound + LBL_GAP + 1, buttonHeight - 2, "");
ypos - btnYOfs, lwFound + LBL_GAP + 1, lineHeight, "");
e->setEditable(false);
e->setEnabled(false);
} else {
@ -324,6 +325,8 @@ int LauncherDialog::addRomWidgets(int ypos)
imageHeight = imgSize.h + RomImageWidget::labelHeight(*myROMInfoFont);
myRomImageWidget = new RomImageWidget(this, *myROMInfoFont,
xpos, ypos, imageWidth, imageHeight);
if(!myUseMinimalUI)
wid.push_back(myRomImageWidget);
const int yofs = imageHeight + myROMInfoFont->getFontHeight() / 2;
myRomInfoWidget = new RomInfoWidget(this, *myROMInfoFont,
@ -831,18 +834,6 @@ void LauncherDialog::handleKeyDown(StellaKey key, StellaMod mod, bool repeated)
reload();
break;
case KBDK_LEFT:
myRomImageWidget->changeImage(-1);
break;
case KBDK_RIGHT:
myRomImageWidget->changeImage(1);
break;
case KBDK_RETURN:
myRomImageWidget->toggleImageZoom();
break;
default:
handled = false;
break;
@ -909,41 +900,35 @@ void LauncherDialog::handleJoyUp(int stick, int button)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event::Type LauncherDialog::getJoyAxisEvent(int stick, JoyAxis axis, JoyDir adir, int button)
{
Event::Type e = instance().eventHandler().eventForJoyAxis(EventMode::kMenuMode, stick, axis, adir, button);
Event::Type event = instance().eventHandler().eventForJoyAxis(EventMode::kMenuMode, stick, axis, adir, button);
// map axis events for launcher
switch(e)
if(myUseMinimalUI)
{
switch(event)
{
case Event::UINavPrev:
if(myUseMinimalUI)
// convert unused previous item event into page-up event
e = Event::UIPgUp;
else
myRomImageWidget->disableImageZoom();
event = Event::UIPgUp;
break;
case Event::UINavNext:
if(myUseMinimalUI)
// convert unused next item event into page-down event
e = Event::UIPgDown;
else
myRomImageWidget->disableImageZoom();
event = Event::UIPgDown;
break;
case Event::UITabPrev:
if(myList->isHighlighted())
myRomImageWidget->changeImage(-1);
myEventHandled = true;
break;
case Event::UITabNext:
if(myList->isHighlighted())
myRomImageWidget->changeImage(1);
myEventHandled = true;
break;
case Event::UIOK:
if(myList->isHighlighted())
case Event::UICancel:
myRomImageWidget->toggleImageZoom();
myEventHandled = true;
break;
@ -951,8 +936,24 @@ Event::Type LauncherDialog::getJoyAxisEvent(int stick, JoyAxis axis, JoyDir adir
default:
break;
}
}
else
{
switch(event)
{
case Event::UITabPrev:
event = Event::UIPgUp;
break;
return e;
case Event::UITabNext:
event = Event::UIPgDown;
break;
default:
break;
}
}
return event;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -218,7 +218,7 @@ void NavigationWidget::PathWidget::setPath(string_view path)
s->setID(static_cast<uInt32>(idx));
s->setTarget(myTarget);
myFolderList.push_back(s);
_boss->addFocusWidget(s);
//_boss->addFocusWidget(s); // TODO: allow adding/inserting focus dynamically
}
x += width;
}

View File

@ -35,7 +35,7 @@ RomImageWidget::RomImageWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h)
: Widget(boss, font, x, y, w, h)
{
_flags = Widget::FLAG_ENABLED | Widget::FLAG_TRACK_MOUSE;
_flags = Widget::FLAG_ENABLED | Widget::FLAG_TRACK_MOUSE; // | FLAG_WANTS_RAWDATA;
_bgcolor = kDlgColor;
_bgcolorlo = kBGColorLo;
myImageHeight = _h - labelHeight(font);
@ -464,6 +464,34 @@ void RomImageWidget::positionSurfaces()
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool RomImageWidget::handleEvent(Event::Type event)
{
switch(event)
{
case Event::UIPgUp: // controller
case Event::UILeft: // keyboard
changeImage(-1);
return true;
case Event::UIPgDown: // controller
case Event::UIRight: // keyboard
changeImage(1);
return true;
case Event::UIOK: // controller
case Event::UICancel: // controller
case Event::UISelect: // keyboard & controller
toggleImageZoom();
return true;
default:
break;
}
return Widget::handleEvent(event);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomImageWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount)
{

View File

@ -48,6 +48,7 @@ class RomImageWidget : public Widget
protected:
#ifdef IMAGE_SUPPORT
bool handleEvent(Event::Type event) override;
void handleMouseUp(int x, int y, MouseButton b, int clickCount) override;
void handleMouseMoved(int x, int y) override;
void tick() override;