mirror of https://github.com/stella-emu/stella.git
changed LauncherDialog and EditableWidget ContextMenu and dialog shade surface creation to on demand
This commit is contained in:
parent
489188a2e2
commit
bf5a9e5749
|
@ -55,18 +55,6 @@ Dialog::Dialog(OSystem& instance, DialogContainer& parent, const GUI::Font& font
|
|||
_flags = Widget::FLAG_ENABLED | Widget::FLAG_BORDER | Widget::FLAG_CLEARBG;
|
||||
setTitle(title);
|
||||
|
||||
// Create shading surface
|
||||
uInt32 data = 0xff000000;
|
||||
|
||||
_shadeSurface = instance.frameBuffer().allocateSurface(
|
||||
1, 1, ScalingInterpolation::sharp, &data);
|
||||
|
||||
FBSurface::Attributes& attr = _shadeSurface->attributes();
|
||||
|
||||
attr.blending = true;
|
||||
attr.blendalpha = 25; // darken background dialogs by 25%
|
||||
_shadeSurface->applyAttributes();
|
||||
|
||||
_toolTip = make_unique<ToolTip>(*this, font);
|
||||
}
|
||||
|
||||
|
@ -267,6 +255,20 @@ void Dialog::render()
|
|||
|
||||
if(!onTop)
|
||||
{
|
||||
if(_shadeSurface == nullptr)
|
||||
{
|
||||
// Create shading surface
|
||||
uInt32 data = 0xff000000;
|
||||
|
||||
_shadeSurface = instance().frameBuffer().allocateSurface(
|
||||
1, 1, ScalingInterpolation::sharp, &data);
|
||||
|
||||
FBSurface::Attributes& attr = _shadeSurface->attributes();
|
||||
|
||||
attr.blending = true;
|
||||
attr.blendalpha = 25; // darken background dialogs by 25%
|
||||
_shadeSurface->applyAttributes();
|
||||
}
|
||||
_shadeSurface->setDstRect(_surface->dstRect());
|
||||
_shadeSurface->render();
|
||||
}
|
||||
|
|
|
@ -40,9 +40,6 @@ EditableWidget::EditableWidget(GuiObject* boss, const GUI::Font& font,
|
|||
_bgcolorlo = kDlgColor;
|
||||
_textcolor = kTextColor;
|
||||
_textcolorhi = kTextColor;
|
||||
|
||||
// add mouse context menu
|
||||
myMouseMenu = make_unique<ContextMenu>(this, font, EmptyVarList);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -143,7 +140,7 @@ int EditableWidget::toCaretPos(int x) const
|
|||
void EditableWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
|
||||
{
|
||||
// Grab right mouse button for context menu, send left to base class
|
||||
if(b == MouseButton::RIGHT && isEnabled() && !myMouseMenu->isVisible())
|
||||
if(b == MouseButton::RIGHT && isEnabled() && !mouseMenu().isVisible())
|
||||
{
|
||||
VariantList items;
|
||||
#ifndef BSPF_MACOS
|
||||
|
@ -159,10 +156,10 @@ void EditableWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount
|
|||
if(isEditable())
|
||||
VarList::push_back(items, " Paste Cmd+V ", "paste");
|
||||
#endif
|
||||
myMouseMenu->addItems(items);
|
||||
mouseMenu().addItems(items);
|
||||
|
||||
// Add menu at current x,y mouse location
|
||||
myMouseMenu->show(x + getAbsX(), y + getAbsY(), dialog().surface().dstRect());
|
||||
mouseMenu().show(x + getAbsX(), y + getAbsY(), dialog().surface().dstRect());
|
||||
return;
|
||||
}
|
||||
else if(b == MouseButton::LEFT && isEnabled())
|
||||
|
@ -179,6 +176,16 @@ void EditableWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount
|
|||
Widget::handleMouseDown(x, y, b, clickCount);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
ContextMenu& EditableWidget::mouseMenu()
|
||||
{
|
||||
// add mouse context menu
|
||||
if(myMouseMenu == nullptr)
|
||||
myMouseMenu = make_unique<ContextMenu>(this, _font, EmptyVarList);
|
||||
|
||||
return *myMouseMenu;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EditableWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount)
|
||||
{
|
||||
|
@ -205,7 +212,7 @@ void EditableWidget::handleCommand(CommandSender* sender, int cmd, int data, int
|
|||
{
|
||||
if(cmd == ContextMenu::kItemSelectedCmd)
|
||||
{
|
||||
const string& rmb = myMouseMenu->getSelectedTag().toString();
|
||||
const string& rmb = mouseMenu().getSelectedTag().toString();
|
||||
|
||||
if(rmb == "cut")
|
||||
{
|
||||
|
|
|
@ -117,6 +117,8 @@ class EditableWidget : public Widget, public CommandSender
|
|||
// internal buffer
|
||||
bool tryInsertChar(char c, int pos);
|
||||
|
||||
ContextMenu& mouseMenu();
|
||||
|
||||
private:
|
||||
unique_ptr<ContextMenu> myMouseMenu;
|
||||
bool _isDragging{false};
|
||||
|
|
|
@ -295,9 +295,6 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
|
|||
|
||||
addToFocusList(wid);
|
||||
|
||||
// Create (empty) context menu for ROM list options
|
||||
myMenu = make_unique<ContextMenu>(this, _font, EmptyVarList);
|
||||
|
||||
// since we cannot know how many files there are, use are really high value here
|
||||
myList->progress().setRange(0, 50000, 5);
|
||||
myList->progress().setMessage(" Filtering files" + ELLIPSIS + " ");
|
||||
|
@ -608,7 +605,7 @@ void LauncherDialog::loadRomInfo()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void LauncherDialog::handleContextMenu()
|
||||
{
|
||||
const string& cmd = myMenu->getSelectedTag().toString();
|
||||
const string& cmd = menu().getSelectedTag().toString();
|
||||
|
||||
if(cmd == "override")
|
||||
openGlobalProps();
|
||||
|
@ -618,6 +615,17 @@ void LauncherDialog::handleContextMenu()
|
|||
openHighScores();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
ContextMenu& LauncherDialog::menu()
|
||||
{
|
||||
if(myMenu == nullptr)
|
||||
// Create (empty) context menu for ROM list options
|
||||
myMenu = make_unique<ContextMenu>(this, _font, EmptyVarList);
|
||||
|
||||
|
||||
return *myMenu;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void LauncherDialog::showOnlyROMs(bool state)
|
||||
{
|
||||
|
@ -752,10 +760,10 @@ void LauncherDialog::handleMouseDown(int x, int y, MouseButton b, int clickCount
|
|||
if(instance().highScores().enabled())
|
||||
VarList::push_back(items, " High scores" + ELLIPSIS + " Ctrl+H", "highscores");
|
||||
VarList::push_back(items, " Reload listing Ctrl+R ", "reload");
|
||||
myMenu->addItems(items);
|
||||
menu().addItems(items);
|
||||
|
||||
// Add menu at current x,y mouse location
|
||||
myMenu->show(x + getAbsX(), y + getAbsY(), surface().dstRect());
|
||||
menu().show(x + getAbsX(), y + getAbsY(), surface().dstRect());
|
||||
}
|
||||
else
|
||||
Dialog::handleMouseDown(x, y, b, clickCount);
|
||||
|
|
|
@ -157,6 +157,8 @@ class LauncherDialog : public Dialog
|
|||
void openHighScores();
|
||||
void openWhatsNew();
|
||||
|
||||
ContextMenu& menu();
|
||||
|
||||
private:
|
||||
unique_ptr<Dialog> myDialog;
|
||||
unique_ptr<ContextMenu> myMenu;
|
||||
|
|
Loading…
Reference in New Issue