mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
Add a whole line scroll mode to make breakpoints/watchpoints header work nicely
This commit is contained in:
parent
deaf2eef30
commit
3047ba4982
@ -17,7 +17,7 @@
|
||||
@implementation MAMEBreakpointsView
|
||||
|
||||
- (id)initWithFrame:(NSRect)f machine:(running_machine &)m {
|
||||
if (!(self = [super initWithFrame:f type:DVT_BREAK_POINTS machine:m]))
|
||||
if (!(self = [super initWithFrame:f type:DVT_BREAK_POINTS machine:m wholeLineScroll:YES]))
|
||||
return nil;
|
||||
return self;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
@implementation MAMEConsoleView
|
||||
|
||||
- (id)initWithFrame:(NSRect)f machine:(running_machine &)m {
|
||||
if (!(self = [super initWithFrame:f type:DVT_CONSOLE machine:m]))
|
||||
if (!(self = [super initWithFrame:f type:DVT_CONSOLE machine:m wholeLineScroll:NO]))
|
||||
return nil;
|
||||
return self;
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
int type;
|
||||
running_machine *machine;
|
||||
debug_view *view;
|
||||
BOOL wholeLineScroll;
|
||||
|
||||
INT32 totalWidth, totalHeight, originTop;
|
||||
|
||||
@ -35,7 +36,7 @@
|
||||
|
||||
+ (NSFont *)defaultFont;
|
||||
|
||||
- (id)initWithFrame:(NSRect)f type:(debug_view_type)t machine:(running_machine &)m;
|
||||
- (id)initWithFrame:(NSRect)f type:(debug_view_type)t machine:(running_machine &)m wholeLineScroll:(BOOL)w;
|
||||
|
||||
- (void)update;
|
||||
|
||||
|
@ -168,6 +168,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
||||
// this gets all the lines that are at least partially visible
|
||||
debug_view_xy origin(0, 0), size(totalWidth, totalHeight);
|
||||
[self convertBounds:[self visibleRect] toFirstAffectedLine:&origin.y count:&size.y];
|
||||
size.y = MIN(size.y, totalHeight - origin.y);
|
||||
|
||||
// tell the underlying view how much real estate is available
|
||||
view->set_visible_size(size);
|
||||
@ -196,9 +197,12 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
||||
|
||||
- (void)adjustSizeAndRecomputeVisible {
|
||||
NSSize const clip = [[[self enclosingScrollView] contentView] bounds].size;
|
||||
NSSize const content = NSMakeSize((fontWidth * totalWidth) + (2 * [textContainer lineFragmentPadding]),
|
||||
fontHeight * totalHeight);
|
||||
[self setFrameSize:NSMakeSize(MAX(clip.width, content.width), MAX(clip.height, content.height))];
|
||||
NSSize content = NSMakeSize((fontWidth * totalWidth) + (2 * [textContainer lineFragmentPadding]),
|
||||
fontHeight * totalHeight);
|
||||
if (wholeLineScroll)
|
||||
content.height += (fontHeight * 2) - 1;
|
||||
[self setFrameSize:NSMakeSize(ceil(MAX(clip.width, content.width)),
|
||||
ceil(MAX(clip.height, content.height)))];
|
||||
[self recomputeVisible];
|
||||
}
|
||||
|
||||
@ -208,7 +212,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
||||
}
|
||||
|
||||
|
||||
- (id)initWithFrame:(NSRect)f type:(debug_view_type)t machine:(running_machine &)m {
|
||||
- (id)initWithFrame:(NSRect)f type:(debug_view_type)t machine:(running_machine &)m wholeLineScroll:(BOOL)w {
|
||||
if (!(self = [super initWithFrame:f]))
|
||||
return nil;
|
||||
type = t;
|
||||
@ -218,7 +222,10 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
totalWidth = totalHeight = 0;
|
||||
wholeLineScroll = w;
|
||||
debug_view_xy const size = view->total_size();
|
||||
totalWidth = size.x;
|
||||
totalHeight = size.y;
|
||||
originTop = 0;
|
||||
|
||||
text = [[NSTextStorage alloc] init];
|
||||
@ -258,10 +265,12 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
||||
if (scroller)
|
||||
{
|
||||
NSSize const clip = [[scroller contentView] bounds].size;
|
||||
NSSize const content = NSMakeSize((fontWidth * newSize.x) + (2 * [textContainer lineFragmentPadding]),
|
||||
fontHeight * newSize.y);
|
||||
[self setFrameSize:NSMakeSize(MAX(clip.width, content.width), MAX(clip.height, content.height))];
|
||||
[self recomputeVisible];
|
||||
NSSize content = NSMakeSize((fontWidth * newSize.x) + (2 * [textContainer lineFragmentPadding]),
|
||||
fontHeight * newSize.y);
|
||||
if (wholeLineScroll)
|
||||
content.height += (fontHeight * 2) - 1;
|
||||
[self setFrameSize:NSMakeSize(ceil(MAX(clip.width, content.width)),
|
||||
ceil(MAX(clip.height, content.height)))];
|
||||
}
|
||||
totalWidth = newSize.x;
|
||||
totalHeight = newSize.y;
|
||||
@ -273,8 +282,6 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
||||
{
|
||||
NSRect const visible = [self visibleRect];
|
||||
NSPoint scroll = NSMakePoint(visible.origin.x, newOrigin.y * fontHeight);
|
||||
if ((newOrigin.y + view->visible_size().y) == totalHeight)
|
||||
scroll.y += (view->visible_size().y * fontHeight) - visible.size.height;
|
||||
[self scrollPoint:scroll];
|
||||
originTop = newOrigin.y;
|
||||
}
|
||||
@ -287,7 +294,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
||||
- (NSSize)maximumFrameSize {
|
||||
debug_view_xy const max = view->total_size();
|
||||
return NSMakeSize(ceil((max.x * fontWidth) + (2 * [textContainer lineFragmentPadding])),
|
||||
ceil(max.y * fontHeight));
|
||||
ceil((max.y + (wholeLineScroll ? 1 : 0)) * fontHeight));
|
||||
}
|
||||
|
||||
|
||||
@ -519,6 +526,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
||||
selector:@selector(viewFrameDidChange:)
|
||||
name:NSViewFrameDidChangeNotification
|
||||
object:[scroller contentView]];
|
||||
[self adjustSizeAndRecomputeVisible];
|
||||
}
|
||||
}
|
||||
|
||||
@ -558,6 +566,17 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
||||
}
|
||||
|
||||
|
||||
- (NSRect)adjustScroll:(NSRect)proposedVisibleRect {
|
||||
if (wholeLineScroll)
|
||||
{
|
||||
CGFloat const clamp = [self bounds].size.height - fontHeight - proposedVisibleRect.size.height;
|
||||
proposedVisibleRect.origin.y = MIN(proposedVisibleRect.origin.y, MAX(clamp, 0));
|
||||
proposedVisibleRect.origin.y -= fmod(proposedVisibleRect.origin.y, fontHeight);
|
||||
}
|
||||
return proposedVisibleRect;
|
||||
}
|
||||
|
||||
|
||||
- (void)drawRect:(NSRect)dirtyRect {
|
||||
// work out what's available
|
||||
[self recomputeVisible];
|
||||
|
@ -17,7 +17,7 @@
|
||||
@implementation MAMEDisassemblyView
|
||||
|
||||
- (id)initWithFrame:(NSRect)f machine:(running_machine &)m {
|
||||
if (!(self = [super initWithFrame:f type:DVT_DISASSEMBLY machine:m]))
|
||||
if (!(self = [super initWithFrame:f type:DVT_DISASSEMBLY machine:m wholeLineScroll:NO]))
|
||||
return nil;
|
||||
return self;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
@implementation MAMEErrorLogView
|
||||
|
||||
- (id)initWithFrame:(NSRect)f machine:(running_machine &)m {
|
||||
if (!(self = [super initWithFrame:f type:DVT_LOG machine:m]))
|
||||
if (!(self = [super initWithFrame:f type:DVT_LOG machine:m wholeLineScroll:NO]))
|
||||
return nil;
|
||||
return self;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
@implementation MAMEMemoryView
|
||||
|
||||
- (id)initWithFrame:(NSRect)f machine:(running_machine &)m {
|
||||
if (!(self = [super initWithFrame:f type:DVT_MEMORY machine:m]))
|
||||
if (!(self = [super initWithFrame:f type:DVT_MEMORY machine:m wholeLineScroll:NO]))
|
||||
return nil;
|
||||
return self;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
@implementation MAMERegistersView
|
||||
|
||||
- (id)initWithFrame:(NSRect)f machine:(running_machine &)m {
|
||||
if (!(self = [super initWithFrame:f type:DVT_STATE machine:m]))
|
||||
if (!(self = [super initWithFrame:f type:DVT_STATE machine:m wholeLineScroll:NO]))
|
||||
return nil;
|
||||
return self;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
@implementation MAMEWatchpointsView
|
||||
|
||||
- (id)initWithFrame:(NSRect)f machine:(running_machine &)m {
|
||||
if (!(self = [super initWithFrame:f type:DVT_WATCH_POINTS machine:m]))
|
||||
if (!(self = [super initWithFrame:f type:DVT_WATCH_POINTS machine:m wholeLineScroll:YES]))
|
||||
return nil;
|
||||
return self;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user