Skip to content

Commit

Permalink
added ROM image widget to tab order and moved event handling into it
Browse files Browse the repository at this point in the history
added launcher list paging events for controllers
  • Loading branch information
thrust26 committed Sep 1, 2023
1 parent 68833dc commit 2ab1fc7
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 59 deletions.
18 changes: 6 additions & 12 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2107,23 +2107,17 @@ <h2><b><a name="Hotkeys">Hotkeys</a></b></h2>
<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>
Expand Down
2 changes: 2 additions & 0 deletions src/emucore/Settings.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
91 changes: 46 additions & 45 deletions src/gui/LauncherDialog.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -909,50 +900,60 @@ 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)
{
case Event::UINavPrev:
if(myUseMinimalUI)
switch(event)
{
case Event::UINavPrev:
// convert unused previous item event into page-up event
e = Event::UIPgUp;
else
myRomImageWidget->disableImageZoom();
break;
event = Event::UIPgUp;
break;

case Event::UINavNext:
if(myUseMinimalUI)
case Event::UINavNext:
// convert unused next item event into page-down event
e = Event::UIPgDown;
else
myRomImageWidget->disableImageZoom();
break;
event = Event::UIPgDown;
break;

case Event::UITabPrev:
if(myList->isHighlighted())
case Event::UITabPrev:
myRomImageWidget->changeImage(-1);
myEventHandled = true;
break;
myEventHandled = true;
break;

case Event::UITabNext:
if(myList->isHighlighted())
case Event::UITabNext:
myRomImageWidget->changeImage(1);
myEventHandled = true;
break;
myEventHandled = true;
break;

case Event::UIOK:
if(myList->isHighlighted())
case Event::UIOK:
case Event::UICancel:
myRomImageWidget->toggleImageZoom();
myEventHandled = true;
break;
myEventHandled = true;
break;

default:
break;
default:
break;
}
}
else
{
switch(event)
{
case Event::UITabPrev:
event = Event::UIPgUp;
break;

case Event::UITabNext:
event = Event::UIPgDown;
break;

return e;
default:
break;
}
}
return event;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down
2 changes: 1 addition & 1 deletion src/gui/NavigationWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
30 changes: 29 additions & 1 deletion src/gui/RomImageWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions src/gui/RomImageWidget.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2ab1fc7

Please sign in to comment.