mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-10 23:34:01 +02:00
Update to v096r01 release.
byuu says: Changelog: - restructured the project and removed a whole bunch of old/dead directives from higan/GNUmakefile - huge amounts of work on hiro/cocoa (compiles but ~70% of the functionality is commented out) - fixed a masking error in my ARM CPU disassembler [Lioncash] - SFC: decided to change board cic=(411,413) back to board region=(ntsc,pal) ... the former was too obtuse If you rename Boolean (it's a problem with an include from ruby, not from hiro) and disable all the ruby drivers, you can compile an OS X binary, but obviously it's not going to do anything. It's a boring WIP, I just wanted to push out the project structure change now at the start of this WIP cycle.
This commit is contained in:
93
hiro/cocoa/widget/horizontal-scroll-bar.cpp
Normal file
93
hiro/cocoa/widget/horizontal-scroll-bar.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
#if defined(Hiro_HorizontalScrollBar)
|
||||
|
||||
@implementation CocoaHorizontalScrollBar : NSScroller
|
||||
|
||||
-(id) initWith:(hiro::mHorizontalScrollBar&)horizontalScrollBarReference {
|
||||
if(self = [super initWithFrame:NSMakeRect(0, 0, 1, 0)]) {
|
||||
horizontalScrollBar = &horizontalScrollBarReference;
|
||||
|
||||
[self setTarget:self];
|
||||
[self setAction:@selector(scroll:)];
|
||||
|
||||
[self setControlSize:NSRegularControlSize];
|
||||
[self setScrollerStyle:NSScrollerStyleLegacy];
|
||||
[self setEnabled:YES];
|
||||
|
||||
[self update];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void) update {
|
||||
double d = 1.0 / horizontalScrollBar->state.length;
|
||||
double f = d * horizontalScrollBar->state.position;
|
||||
|
||||
[self setDoubleValue:f];
|
||||
[self setKnobProportion:d];
|
||||
}
|
||||
|
||||
-(IBAction) scroll:(id)sender {
|
||||
auto& state = horizontalScrollBar->state;
|
||||
|
||||
switch([self hitPart]) {
|
||||
case NSScrollerIncrementLine:
|
||||
case NSScrollerIncrementPage:
|
||||
if(state.position < state.length - 1) state.position++;
|
||||
[self update];
|
||||
break;
|
||||
|
||||
case NSScrollerDecrementLine:
|
||||
case NSScrollerDecrementPage:
|
||||
if(state.position) state.position--;
|
||||
[self update];
|
||||
break;
|
||||
|
||||
case NSScrollerKnob:
|
||||
state.position = [self doubleValue] * state.length;
|
||||
break;
|
||||
}
|
||||
|
||||
horizontalScrollBar->doChange();
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
namespace hiro {
|
||||
|
||||
auto pHorizontalScrollBar::construct() -> void {
|
||||
@autoreleasepool {
|
||||
cocoaView = cocoaHorizontalScrollBar = [[CocoaHorizontalScrollBar alloc] initWith:self()];
|
||||
pWidget::construct();
|
||||
|
||||
setLength(state().length);
|
||||
setPosition(state().position);
|
||||
}
|
||||
}
|
||||
|
||||
auto pHorizontalScrollBar::destruct() -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaView release];
|
||||
}
|
||||
}
|
||||
|
||||
auto pHorizontalScrollBar::minimumSize() const -> Size {
|
||||
@autoreleasepool {
|
||||
return {32, (int)[NSScroller scrollerWidthForControlSize:NSRegularControlSize scrollerStyle:NSScrollerStyleLegacy]};
|
||||
}
|
||||
}
|
||||
|
||||
auto pHorizontalScrollBar::setLength(uint length) -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaView update];
|
||||
}
|
||||
}
|
||||
|
||||
auto pHorizontalScrollBar::setPosition(uint position) -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaView update];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user