mirror of https://github.com/stella-emu/stella.git
implement left button zoom and extra options in zom window (#506)
This commit is contained in:
parent
db7def887d
commit
c53fb6ab00
|
@ -104,8 +104,10 @@ void TiaOutputWidget::saveSnapshot(int execDepth, const string& execPrefix)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void TiaOutputWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
|
void TiaOutputWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
|
||||||
{
|
{
|
||||||
|
if (b == MouseButton::LEFT)
|
||||||
|
myZoom->setPos(x, y);
|
||||||
// Grab right mouse button for command context menu
|
// Grab right mouse button for command context menu
|
||||||
if(b == MouseButton::RIGHT)
|
else if(b == MouseButton::RIGHT)
|
||||||
{
|
{
|
||||||
myClickX = x;
|
myClickX = x;
|
||||||
myClickY = y;
|
myClickY = y;
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
#include "OSystem.hxx"
|
#include "OSystem.hxx"
|
||||||
#include "Console.hxx"
|
#include "Console.hxx"
|
||||||
|
#include "Debugger.hxx"
|
||||||
|
#include "DebuggerParser.hxx"
|
||||||
#include "TIA.hxx"
|
#include "TIA.hxx"
|
||||||
#include "FrameBuffer.hxx"
|
#include "FrameBuffer.hxx"
|
||||||
#include "FBSurface.hxx"
|
#include "FBSurface.hxx"
|
||||||
|
@ -49,10 +51,12 @@ TiaZoomWidget::TiaZoomWidget(GuiObject* boss, const GUI::Font& font,
|
||||||
myXOff = myYOff = 0;
|
myXOff = myYOff = 0;
|
||||||
|
|
||||||
myMouseMoving = false;
|
myMouseMoving = false;
|
||||||
myXClick = myYClick = 0;
|
myClickX = myClickY = 0;
|
||||||
|
|
||||||
// Create context menu for zoom levels
|
// Create context menu for zoom levels
|
||||||
VariantList l;
|
VariantList l;
|
||||||
|
VarList::push_back(l, "Fill to scanline", "scanline");
|
||||||
|
VarList::push_back(l, "Toggle breakpoint", "bp");
|
||||||
VarList::push_back(l, "2x zoom", "2");
|
VarList::push_back(l, "2x zoom", "2");
|
||||||
VarList::push_back(l, "4x zoom", "4");
|
VarList::push_back(l, "4x zoom", "4");
|
||||||
VarList::push_back(l, "8x zoom", "8");
|
VarList::push_back(l, "8x zoom", "8");
|
||||||
|
@ -81,10 +85,16 @@ void TiaZoomWidget::zoom(int level)
|
||||||
if(myZoomLevel == level)
|
if(myZoomLevel == level)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// TODO: zoom to center
|
||||||
|
//int x = myXOff + myNumCols / 2;
|
||||||
|
//int y = myYOff + myNumRows / 2;
|
||||||
|
|
||||||
myZoomLevel = level;
|
myZoomLevel = level;
|
||||||
myNumCols = ((_w - 4) >> 1) / myZoomLevel;
|
myNumCols = ((_w - 4) >> 1) / myZoomLevel;
|
||||||
myNumRows = (_h - 4) / myZoomLevel;
|
myNumRows = (_h - 4) / myZoomLevel;
|
||||||
|
|
||||||
|
//setPos(x, y);
|
||||||
|
|
||||||
recalc();
|
recalc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,14 +114,15 @@ void TiaZoomWidget::recalc()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void TiaZoomWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
|
void TiaZoomWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
|
||||||
{
|
{
|
||||||
|
myClickX = x;
|
||||||
|
myClickY = y;
|
||||||
|
|
||||||
// Button 1 is for 'drag'/movement of the image
|
// Button 1 is for 'drag'/movement of the image
|
||||||
// Button 2 is for context menu
|
// Button 2 is for context menu
|
||||||
if(b == MouseButton::LEFT)
|
if(b == MouseButton::LEFT)
|
||||||
{
|
{
|
||||||
// Indicate mouse drag started/in progress
|
// Indicate mouse drag started/in progress
|
||||||
myMouseMoving = true;
|
myMouseMoving = true;
|
||||||
myXClick = x;
|
|
||||||
myYClick = y;
|
|
||||||
}
|
}
|
||||||
else if(b == MouseButton::RIGHT)
|
else if(b == MouseButton::RIGHT)
|
||||||
{
|
{
|
||||||
|
@ -150,11 +161,8 @@ void TiaZoomWidget::handleMouseMoved(int x, int y)
|
||||||
// myXClick = x;
|
// myXClick = x;
|
||||||
// myYClick = y;
|
// myYClick = y;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//cerr << diffx << " " << diffy << endl;
|
//cerr << diffx << " " << diffy << endl;
|
||||||
|
|
||||||
|
|
||||||
myXOff -= diffx;
|
myXOff -= diffx;
|
||||||
myYOff -= diffy;
|
myYOff -= diffy;
|
||||||
|
|
||||||
|
@ -236,9 +244,37 @@ void TiaZoomWidget::handleCommand(CommandSender* sender, int cmd, int data, int
|
||||||
{
|
{
|
||||||
case ContextMenu::kItemSelectedCmd:
|
case ContextMenu::kItemSelectedCmd:
|
||||||
{
|
{
|
||||||
int level = myMenu->getSelectedTag().toInt();
|
uInt32 ystart = instance().console().tia().ystart();
|
||||||
if(level > 0)
|
const string& rmb = myMenu->getSelectedTag().toString();
|
||||||
zoom(level);
|
|
||||||
|
if(rmb == "scanline")
|
||||||
|
{
|
||||||
|
ostringstream command;
|
||||||
|
int lines = myClickY / myZoomLevel + myYOff + ystart - instance().console().tia().scanlines();
|
||||||
|
|
||||||
|
if (lines < 0)
|
||||||
|
lines += instance().console().tia().scanlinesLastFrame();
|
||||||
|
if(lines > 0)
|
||||||
|
{
|
||||||
|
command << "scanline #" << lines;
|
||||||
|
string message = instance().debugger().parser().run(command.str());
|
||||||
|
instance().frameBuffer().showMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(rmb == "bp")
|
||||||
|
{
|
||||||
|
ostringstream command;
|
||||||
|
int scanline = myClickY / myZoomLevel + myYOff + ystart;
|
||||||
|
command << "breakif _scan==#" << scanline;
|
||||||
|
string message = instance().debugger().parser().run(command.str());
|
||||||
|
instance().frameBuffer().showMessage(message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int level = myMenu->getSelectedTag().toInt();
|
||||||
|
if(level > 0)
|
||||||
|
zoom(level);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ class ContextMenu;
|
||||||
#include "Widget.hxx"
|
#include "Widget.hxx"
|
||||||
#include "Command.hxx"
|
#include "Command.hxx"
|
||||||
|
|
||||||
|
|
||||||
class TiaZoomWidget : public Widget, public CommandSender
|
class TiaZoomWidget : public Widget, public CommandSender
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -61,7 +60,7 @@ class TiaZoomWidget : public Widget, public CommandSender
|
||||||
int myXOff, myYOff;
|
int myXOff, myYOff;
|
||||||
|
|
||||||
bool myMouseMoving;
|
bool myMouseMoving;
|
||||||
int myXClick, myYClick;
|
int myClickX, myClickY;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
|
|
Loading…
Reference in New Issue