mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-01-17 20:58:28 +01:00
Update to v092r05 release.
byuu says: This release should be polished enough for a general release. This release should be polished enough for a general release. Anyone with a real, clean Mac up for posting compiled binaries? Preferably compile with "make profile=balanced" In fact, I'd like it if someone were willing to host a "higan for Mac" page, with binaries of each of the latest releases. Only really needed for major official releases, but it'd be preferable to have the builds updated as soon as possible after I post new builds. Changelog: - no more keyboard chimes when pressing keys - status bar added, fully functional - Label::minimumSize() takes frame into account (but note a few places hard-code raw Font::size(), so a few text labels are still clipped) - resizing the main window looks smooth regardless of whether a game is running or not - currently, resizing the window pauses the emulation. Allowing it to run the main loop was lagging out the window resize process too much to be worth it Additional OS X integration enhancements: - closing the main window unloads the current game, but does not quit the application (quit via the main menu or the dock menu) - clicking the icon in the dock will (re)display the main menu
This commit is contained in:
parent
fdd3ea490e
commit
5b4bbf5045
@ -3,10 +3,18 @@
|
||||
|
||||
namespace Emulator {
|
||||
static const char Name[] = "higan";
|
||||
static const char Version[] = "092.04";
|
||||
static const char Version[] = "092.05";
|
||||
static const char Author[] = "byuu";
|
||||
static const char License[] = "GPLv3";
|
||||
static const char Website[] = "http://byuu.org/";
|
||||
|
||||
#if defined(PROFILE_ACCURACY)
|
||||
static const char Profile[] = "Accuracy";
|
||||
#elif defined(PROFILE_BALANCED)
|
||||
static const char Profile[] = "Balanced";
|
||||
#elif defined(PROFILE_PERFORMANCE)
|
||||
static const char Profile[] = "Performance";
|
||||
#endif
|
||||
}
|
||||
|
||||
#include <nall/platform.hpp>
|
||||
|
@ -2,7 +2,7 @@ namespace phoenix {
|
||||
|
||||
struct pAction : public pObject {
|
||||
Action &action;
|
||||
NSMenuItem *cocoaAction;
|
||||
NSMenuItem *cocoaAction = nullptr;
|
||||
|
||||
void setEnabled(bool enabled);
|
||||
void setVisible(bool visible);
|
||||
|
@ -1,6 +1,6 @@
|
||||
@implementation CocoaCheckItem : NSMenuItem
|
||||
|
||||
-(id) initWith :(phoenix::CheckItem&)checkItemReference {
|
||||
-(id) initWith:(phoenix::CheckItem&)checkItemReference {
|
||||
if(self = [super initWithTitle:@"" action:@selector(activate) keyEquivalent:@""]) {
|
||||
checkItem = &checkItemReference;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
@public
|
||||
phoenix::CheckItem *checkItem;
|
||||
}
|
||||
-(id) initWith :(phoenix::CheckItem&)checkItem;
|
||||
-(id) initWith:(phoenix::CheckItem&)checkItem;
|
||||
-(void) activate;
|
||||
@end
|
||||
|
||||
@ -10,7 +10,7 @@ namespace phoenix {
|
||||
|
||||
struct pCheckItem : public pAction {
|
||||
CheckItem &checkItem;
|
||||
CocoaCheckItem *cocoaCheckItem;
|
||||
CocoaCheckItem *cocoaCheckItem = nullptr;
|
||||
|
||||
bool checked();
|
||||
void setChecked(bool checked);
|
||||
|
@ -1,6 +1,6 @@
|
||||
@implementation CocoaItem : NSMenuItem
|
||||
|
||||
-(id) initWith :(phoenix::Item&)itemReference {
|
||||
-(id) initWith:(phoenix::Item&)itemReference {
|
||||
if(self = [super initWithTitle:@"" action:@selector(activate) keyEquivalent:@""]) {
|
||||
item = &itemReference;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
@public
|
||||
phoenix::Item *item;
|
||||
}
|
||||
-(id) initWith :(phoenix::Item&)item;
|
||||
-(id) initWith:(phoenix::Item&)item;
|
||||
-(void) activate;
|
||||
@end
|
||||
|
||||
@ -10,7 +10,7 @@ namespace phoenix {
|
||||
|
||||
struct pItem : public pAction {
|
||||
Item &item;
|
||||
CocoaItem *cocoaItem;
|
||||
CocoaItem *cocoaItem = nullptr;
|
||||
|
||||
void setImage(const image &image);
|
||||
void setText(const string &text);
|
||||
|
@ -1,6 +1,6 @@
|
||||
@implementation CocoaMenu : NSMenuItem
|
||||
|
||||
-(id) initWith :(phoenix::Menu&)menuReference {
|
||||
-(id) initWith:(phoenix::Menu&)menuReference {
|
||||
if(self = [super initWithTitle:@"" action:nil keyEquivalent:@""]) {
|
||||
menu = &menuReference;
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
phoenix::Menu *menu;
|
||||
NSMenu *cocoaMenu;
|
||||
}
|
||||
-(id) initWith :(phoenix::Menu&)menu;
|
||||
-(id) initWith:(phoenix::Menu&)menu;
|
||||
-(NSMenu*) cocoaMenu;
|
||||
@end
|
||||
|
||||
@ -11,7 +11,7 @@ namespace phoenix {
|
||||
|
||||
struct pMenu : public pAction {
|
||||
Menu &menu;
|
||||
CocoaMenu *cocoaMenu;
|
||||
CocoaMenu *cocoaMenu = nullptr;
|
||||
|
||||
void append(Action &action);
|
||||
void remove(Action &action);
|
||||
|
@ -1,6 +1,6 @@
|
||||
@implementation CocoaRadioItem : NSMenuItem
|
||||
|
||||
-(id) initWith :(phoenix::RadioItem&)radioItemReference {
|
||||
-(id) initWith:(phoenix::RadioItem&)radioItemReference {
|
||||
if(self = [super initWithTitle:@"" action:@selector(activate) keyEquivalent:@""]) {
|
||||
radioItem = &radioItemReference;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
@public
|
||||
phoenix::RadioItem *radioItem;
|
||||
}
|
||||
-(id) initWith :(phoenix::RadioItem&)radioItem;
|
||||
-(id) initWith:(phoenix::RadioItem&)radioItem;
|
||||
-(void) activate;
|
||||
@end
|
||||
|
||||
@ -10,7 +10,7 @@ namespace phoenix {
|
||||
|
||||
struct pRadioItem : public pAction {
|
||||
RadioItem &radioItem;
|
||||
CocoaRadioItem *cocoaRadioItem;
|
||||
CocoaRadioItem *cocoaRadioItem = nullptr;
|
||||
|
||||
bool checked();
|
||||
void setChecked();
|
||||
|
@ -2,7 +2,7 @@ namespace phoenix {
|
||||
|
||||
struct pSeparator : public pAction {
|
||||
Separator &separator;
|
||||
NSMenuItem *cocoaSeparator;
|
||||
NSMenuItem *cocoaSeparator = nullptr;
|
||||
|
||||
pSeparator(Separator &separator) : pAction(separator), separator(separator) {}
|
||||
void constructor();
|
||||
|
@ -1,13 +1,19 @@
|
||||
@implementation CocoaDelegate : NSObject
|
||||
|
||||
-(NSApplicationTerminateReply) applicationShouldTerminate :(NSApplication*)sender {
|
||||
-(NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication*)sender {
|
||||
using phoenix::Application;
|
||||
if(Application::Cocoa::onQuit) Application::Cocoa::onQuit();
|
||||
else Application::quit();
|
||||
return NSTerminateCancel;
|
||||
}
|
||||
|
||||
-(void) run :(NSTimer*)timer {
|
||||
-(BOOL) applicationShouldHandleReopen:(NSApplication*)application hasVisibleWindows:(BOOL)flag {
|
||||
using phoenix::Application;
|
||||
if(Application::Cocoa::onActivate) Application::Cocoa::onActivate();
|
||||
return NO;
|
||||
}
|
||||
|
||||
-(void) run:(NSTimer*)timer {
|
||||
using phoenix::Application;
|
||||
if(Application::main) Application::main();
|
||||
}
|
||||
@ -21,6 +27,9 @@ namespace phoenix {
|
||||
void pApplication::run() {
|
||||
if(Application::main) {
|
||||
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:0.0 target:cocoaDelegate selector:@selector(run:) userInfo:nil repeats:YES];
|
||||
|
||||
//below line is needed to run application during window resize; however it has a large performance penalty on the resize smoothness
|
||||
//[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSEventTrackingRunLoopMode];
|
||||
}
|
||||
@autoreleasepool {
|
||||
[NSApp run];
|
||||
|
@ -1,7 +1,8 @@
|
||||
@interface CocoaDelegate : NSObject <NSApplicationDelegate> {
|
||||
}
|
||||
-(NSApplicationTerminateReply) applicationShouldTerminate :(NSApplication*)sender;
|
||||
-(void) run :(NSTimer*)timer;
|
||||
-(NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication*)sender;
|
||||
-(BOOL) applicationShouldHandleReopen:(NSApplication*)application hasVisibleWindows:(BOOL)flag;
|
||||
-(void) run:(NSTimer*)timer;
|
||||
@end
|
||||
|
||||
namespace phoenix {
|
||||
|
9
higan/phoenix/cocoa/object.cpp
Normal file
9
higan/phoenix/cocoa/object.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
namespace phoenix {
|
||||
|
||||
void pObject::constructor() {
|
||||
}
|
||||
|
||||
void pObject::destructor() {
|
||||
}
|
||||
|
||||
}
|
@ -7,8 +7,8 @@ struct pObject {
|
||||
pObject(Object &object) : object(object), locked(false) {}
|
||||
virtual ~pObject() {}
|
||||
|
||||
void constructor() {}
|
||||
void destructor() {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
#include "platform.hpp"
|
||||
#include "utility.cpp"
|
||||
|
||||
#include "font.cpp"
|
||||
#include "desktop.cpp"
|
||||
#include "keyboard.cpp"
|
||||
#include "mouse.cpp"
|
||||
#include "browser-window.cpp"
|
||||
#include "message-window.cpp"
|
||||
#include "font.cpp"
|
||||
#include "object.cpp"
|
||||
#include "timer.cpp"
|
||||
#include "window.cpp"
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
@implementation CocoaTimer : NSObject
|
||||
|
||||
-(id) initWith :(phoenix::Timer&)timerReference {
|
||||
-(id) initWith:(phoenix::Timer&)timerReference {
|
||||
if(self = [super init]) {
|
||||
timer = &timerReference;
|
||||
instance = nil;
|
||||
@ -24,7 +24,7 @@
|
||||
];
|
||||
}
|
||||
|
||||
-(void) run :(NSTimer*)instance {
|
||||
-(void) run:(NSTimer*)instance {
|
||||
if(timer->onActivate) timer->onActivate();
|
||||
}
|
||||
|
||||
|
@ -3,17 +3,17 @@
|
||||
phoenix::Timer *timer;
|
||||
NSTimer *instance;
|
||||
}
|
||||
-(id) initWith :(phoenix::Timer&)timer;
|
||||
-(id) initWith:(phoenix::Timer&)timer;
|
||||
-(NSTimer*) instance;
|
||||
-(void) update;
|
||||
-(void) run :(NSTimer*)instance;
|
||||
-(void) run:(NSTimer*)instance;
|
||||
@end
|
||||
|
||||
namespace phoenix {
|
||||
|
||||
struct pTimer : public pObject {
|
||||
Timer &timer;
|
||||
CocoaTimer *cocoaTimer;
|
||||
CocoaTimer *cocoaTimer = nullptr;
|
||||
|
||||
void setEnabled(bool enabled);
|
||||
void setInterval(unsigned milliseconds);
|
||||
|
@ -1,6 +1,6 @@
|
||||
@implementation CocoaButton : NSButton
|
||||
|
||||
-(id) initWith :(phoenix::Button&)buttonReference {
|
||||
-(id) initWith:(phoenix::Button&)buttonReference {
|
||||
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) {
|
||||
button = &buttonReference;
|
||||
[self setTarget:self];
|
||||
@ -11,7 +11,7 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
-(IBAction) activate :(id)sender {
|
||||
-(IBAction) activate:(id)sender {
|
||||
if(button->onActivate) button->onActivate();
|
||||
}
|
||||
|
||||
|
@ -2,15 +2,15 @@
|
||||
@public
|
||||
phoenix::Button *button;
|
||||
}
|
||||
-(id) initWith :(phoenix::Button&)button;
|
||||
-(IBAction) activate :(id)sender;
|
||||
-(id) initWith:(phoenix::Button&)button;
|
||||
-(IBAction) activate:(id)sender;
|
||||
@end
|
||||
|
||||
namespace phoenix {
|
||||
|
||||
struct pButton : public pWidget {
|
||||
Button &button;
|
||||
CocoaButton *cocoaButton;
|
||||
CocoaButton *cocoaButton = nullptr;
|
||||
|
||||
Size minimumSize();
|
||||
void setImage(const image &image, Orientation orientation);
|
||||
|
@ -1,6 +1,6 @@
|
||||
@implementation CocoaCanvas : NSImageView
|
||||
|
||||
-(id) initWith :(phoenix::Canvas&)canvasReference {
|
||||
-(id) initWith:(phoenix::Canvas&)canvasReference {
|
||||
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) {
|
||||
canvas = &canvasReference;
|
||||
[self setEditable:NO]; //disable image drag-and-drop functionality
|
||||
@ -13,7 +13,7 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void) mouseButton :(NSEvent*)event down:(BOOL)isDown {
|
||||
-(void) mouseButton:(NSEvent*)event down:(BOOL)isDown {
|
||||
if(auto &callback = isDown ? canvas->onMousePress : canvas->onMouseRelease) {
|
||||
switch([event buttonNumber]) {
|
||||
case 0: return callback(phoenix::Mouse::Button::Left);
|
||||
@ -23,49 +23,49 @@
|
||||
}
|
||||
}
|
||||
|
||||
-(void) mouseExited :(NSEvent*)event {
|
||||
-(void) mouseExited:(NSEvent*)event {
|
||||
if(canvas->onMouseLeave) canvas->onMouseLeave();
|
||||
}
|
||||
|
||||
-(void) mouseMove :(NSEvent*)event {
|
||||
-(void) mouseMove:(NSEvent*)event {
|
||||
if([event window] == nil) return;
|
||||
NSPoint location = [self convertPoint:[event locationInWindow] fromView:nil];
|
||||
if(canvas->onMouseMove) canvas->onMouseMove({location.x, [self frame].size.height - 1 - location.y});
|
||||
}
|
||||
|
||||
-(void) mouseDown :(NSEvent*)event {
|
||||
-(void) mouseDown:(NSEvent*)event {
|
||||
[self mouseButton:event down:YES];
|
||||
}
|
||||
|
||||
-(void) mouseUp :(NSEvent*)event {
|
||||
-(void) mouseUp:(NSEvent*)event {
|
||||
[self mouseButton:event down:NO];
|
||||
}
|
||||
|
||||
-(void) mouseDragged :(NSEvent*)event {
|
||||
-(void) mouseDragged:(NSEvent*)event {
|
||||
[self mouseMove:event];
|
||||
}
|
||||
|
||||
-(void) rightMouseDown :(NSEvent*)event {
|
||||
-(void) rightMouseDown:(NSEvent*)event {
|
||||
[self mouseButton:event down:YES];
|
||||
}
|
||||
|
||||
-(void) rightMouseUp :(NSEvent*)event {
|
||||
-(void) rightMouseUp:(NSEvent*)event {
|
||||
[self mouseButton:event down:NO];
|
||||
}
|
||||
|
||||
-(void) rightMouseDragged :(NSEvent*)event {
|
||||
-(void) rightMouseDragged:(NSEvent*)event {
|
||||
[self mouseMove:event];
|
||||
}
|
||||
|
||||
-(void) otherMouseDown :(NSEvent*)event {
|
||||
-(void) otherMouseDown:(NSEvent*)event {
|
||||
[self mouseButton:event down:YES];
|
||||
}
|
||||
|
||||
-(void) otherMouseUp :(NSEvent*)event {
|
||||
-(void) otherMouseUp:(NSEvent*)event {
|
||||
[self mouseButton:event down:NO];
|
||||
}
|
||||
|
||||
-(void) otherMouseDragged :(NSEvent*)event {
|
||||
-(void) otherMouseDragged:(NSEvent*)event {
|
||||
[self mouseMove:event];
|
||||
}
|
||||
|
||||
|
@ -3,25 +3,25 @@
|
||||
phoenix::Canvas *canvas;
|
||||
}
|
||||
-(id) initWith:(phoenix::Canvas&)canvas;
|
||||
-(void) mouseButton :(NSEvent*)event down:(BOOL)isDown;
|
||||
-(void) mouseExited :(NSEvent*)event;
|
||||
-(void) mouseMove :(NSEvent*)event;
|
||||
-(void) mouseDown :(NSEvent*)event;
|
||||
-(void) mouseUp :(NSEvent*)event;
|
||||
-(void) mouseDragged :(NSEvent*)event;
|
||||
-(void) rightMouseDown :(NSEvent*)event;
|
||||
-(void) rightMouseUp :(NSEvent*)event;
|
||||
-(void) rightMouseDragged :(NSEvent*)event;
|
||||
-(void) otherMouseDown :(NSEvent*)event;
|
||||
-(void) otherMouseUp :(NSEvent*)event;
|
||||
-(void) otherMouseDragged :(NSEvent*)event;
|
||||
-(void) mouseButton:(NSEvent*)event down:(BOOL)isDown;
|
||||
-(void) mouseExited:(NSEvent*)event;
|
||||
-(void) mouseMove:(NSEvent*)event;
|
||||
-(void) mouseDown:(NSEvent*)event;
|
||||
-(void) mouseUp:(NSEvent*)event;
|
||||
-(void) mouseDragged:(NSEvent*)event;
|
||||
-(void) rightMouseDown:(NSEvent*)event;
|
||||
-(void) rightMouseUp:(NSEvent*)event;
|
||||
-(void) rightMouseDragged:(NSEvent*)event;
|
||||
-(void) otherMouseDown:(NSEvent*)event;
|
||||
-(void) otherMouseUp:(NSEvent*)event;
|
||||
-(void) otherMouseDragged:(NSEvent*)event;
|
||||
@end
|
||||
|
||||
namespace phoenix {
|
||||
|
||||
struct pCanvas : public pWidget {
|
||||
Canvas &canvas;
|
||||
CocoaCanvas *cocoaCanvas;
|
||||
CocoaCanvas *cocoaCanvas = nullptr;
|
||||
|
||||
void setSize(const Size &size);
|
||||
void update();
|
||||
|
@ -1,6 +1,6 @@
|
||||
@implementation CocoaCheckButton : NSButton
|
||||
|
||||
-(id) initWith :(phoenix::CheckButton&)checkButtonReference {
|
||||
-(id) initWith:(phoenix::CheckButton&)checkButtonReference {
|
||||
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) {
|
||||
checkButton = &checkButtonReference;
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
-(IBAction) activate :(id)sender {
|
||||
-(IBAction) activate:(id)sender {
|
||||
checkButton->state.checked = [self state] != NSOffState;
|
||||
if(checkButton->onToggle) checkButton->onToggle();
|
||||
}
|
||||
|
@ -2,15 +2,15 @@
|
||||
@public
|
||||
phoenix::CheckButton *checkButton;
|
||||
}
|
||||
-(id) initWith :(phoenix::CheckButton&)checkButton;
|
||||
-(IBAction) activate :(id)sender;
|
||||
-(id) initWith:(phoenix::CheckButton&)checkButton;
|
||||
-(IBAction) activate:(id)sender;
|
||||
@end
|
||||
|
||||
namespace phoenix {
|
||||
|
||||
struct pCheckButton : public pWidget {
|
||||
CheckButton &checkButton;
|
||||
CocoaCheckButton *cocoaCheckButton;
|
||||
CocoaCheckButton *cocoaCheckButton = nullptr;
|
||||
|
||||
bool checked();
|
||||
Size minimumSize();
|
||||
|
@ -1,6 +1,6 @@
|
||||
@implementation CocoaComboButton : NSPopUpButton
|
||||
|
||||
-(id) initWith :(phoenix::ComboButton&)comboButtonReference {
|
||||
-(id) initWith:(phoenix::ComboButton&)comboButtonReference {
|
||||
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0) pullsDown:NO]) {
|
||||
comboButton = &comboButtonReference;
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
-(IBAction) activate :(id)sender {
|
||||
-(IBAction) activate:(id)sender {
|
||||
if(comboButton->onChange) comboButton->onChange();
|
||||
}
|
||||
|
||||
|
@ -2,15 +2,15 @@
|
||||
@public
|
||||
phoenix::ComboButton *comboButton;
|
||||
}
|
||||
-(id) initWith :(phoenix::ComboButton&)comboButton;
|
||||
-(IBAction) activate :(id)sender;
|
||||
-(id) initWith:(phoenix::ComboButton&)comboButton;
|
||||
-(IBAction) activate:(id)sender;
|
||||
@end
|
||||
|
||||
namespace phoenix {
|
||||
|
||||
struct pComboButton : public pWidget {
|
||||
ComboButton &comboButton;
|
||||
CocoaComboButton *cocoaComboButton;
|
||||
CocoaComboButton *cocoaComboButton = nullptr;
|
||||
|
||||
void append(const string &text);
|
||||
Size minimumSize();
|
||||
|
@ -1,6 +1,6 @@
|
||||
@implementation CocoaHexEdit : NSScrollView
|
||||
|
||||
-(id) initWith :(phoenix::HexEdit&)hexEditReference {
|
||||
-(id) initWith:(phoenix::HexEdit&)hexEditReference {
|
||||
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) {
|
||||
hexEdit = &hexEditReference;
|
||||
}
|
||||
|
@ -2,14 +2,14 @@
|
||||
@public
|
||||
phoenix::HexEdit *hexEdit;
|
||||
}
|
||||
-(id) initWith :(phoenix::HexEdit&)hexEdit;
|
||||
-(id) initWith:(phoenix::HexEdit&)hexEdit;
|
||||
@end
|
||||
|
||||
namespace phoenix {
|
||||
|
||||
struct pHexEdit : public pWidget {
|
||||
HexEdit &hexEdit;
|
||||
CocoaHexEdit *cocoaHexEdit;
|
||||
CocoaHexEdit *cocoaHexEdit = nullptr;
|
||||
|
||||
void setColumns(unsigned columns);
|
||||
void setLength(unsigned length);
|
||||
|
@ -1,6 +1,6 @@
|
||||
@implementation CocoaHorizontalScroller : NSScroller
|
||||
|
||||
-(id) initWith :(phoenix::HorizontalScroller&)horizontalScrollerReference {
|
||||
-(id) initWith:(phoenix::HorizontalScroller&)horizontalScrollerReference {
|
||||
if(self = [super initWithFrame:NSMakeRect(0, 0, 1, 0)]) {
|
||||
horizontalScroller = &horizontalScrollerReference;
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
[self setKnobProportion:d];
|
||||
}
|
||||
|
||||
-(IBAction) scroll :(id)sender {
|
||||
-(IBAction) scroll:(id)sender {
|
||||
auto &state = horizontalScroller->state;
|
||||
|
||||
switch([self hitPart]) {
|
||||
|
@ -2,16 +2,16 @@
|
||||
@public
|
||||
phoenix::HorizontalScroller *horizontalScroller;
|
||||
}
|
||||
-(id) initWith :(phoenix::HorizontalScroller&)horizontalScroller;
|
||||
-(id) initWith:(phoenix::HorizontalScroller&)horizontalScroller;
|
||||
-(void) update;
|
||||
-(IBAction) scroll :(id)sender;
|
||||
-(IBAction) scroll:(id)sender;
|
||||
@end
|
||||
|
||||
namespace phoenix {
|
||||
|
||||
struct pHorizontalScroller : public pWidget {
|
||||
HorizontalScroller &horizontalScroller;
|
||||
CocoaHorizontalScroller *cocoaHorizontalScroller;
|
||||
CocoaHorizontalScroller *cocoaHorizontalScroller = nullptr;
|
||||
|
||||
Size minimumSize();
|
||||
unsigned position();
|
||||
|
@ -1,6 +1,6 @@
|
||||
@implementation CocoaHorizontalSlider : NSSlider
|
||||
|
||||
-(id) initWith :(phoenix::HorizontalSlider&)horizontalSliderReference {
|
||||
-(id) initWith:(phoenix::HorizontalSlider&)horizontalSliderReference {
|
||||
if(self = [super initWithFrame:NSMakeRect(0, 0, 1, 0)]) {
|
||||
horizontalSlider = &horizontalSliderReference;
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
-(IBAction) activate :(id)sender {
|
||||
-(IBAction) activate:(id)sender {
|
||||
horizontalSlider->state.position = [self doubleValue];
|
||||
if(horizontalSlider->onChange) horizontalSlider->onChange();
|
||||
}
|
||||
|
@ -2,15 +2,15 @@
|
||||
@public
|
||||
phoenix::HorizontalSlider *horizontalSlider;
|
||||
}
|
||||
-(id) initWith :(phoenix::HorizontalSlider&)horizontalSlider;
|
||||
-(IBAction) activate :(id)sender;
|
||||
-(id) initWith:(phoenix::HorizontalSlider&)horizontalSlider;
|
||||
-(IBAction) activate:(id)sender;
|
||||
@end
|
||||
|
||||
namespace phoenix {
|
||||
|
||||
struct pHorizontalSlider : public pWidget {
|
||||
HorizontalSlider &horizontalSlider;
|
||||
CocoaHorizontalSlider *cocoaHorizontalSlider;
|
||||
CocoaHorizontalSlider *cocoaHorizontalSlider = nullptr;
|
||||
|
||||
Size minimumSize();
|
||||
unsigned position();
|
||||
|
@ -1,6 +1,6 @@
|
||||
@implementation CocoaLabel : NSTextField
|
||||
|
||||
-(id) initWith :(phoenix::Label&)labelReference {
|
||||
-(id) initWith:(phoenix::Label&)labelReference {
|
||||
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) {
|
||||
label = &labelReference;
|
||||
|
||||
@ -18,7 +18,7 @@ namespace phoenix {
|
||||
|
||||
Size pLabel::minimumSize() {
|
||||
Size size = Font::size(label.font(), label.state.text);
|
||||
return {size.width, size.height};
|
||||
return {size.width + 6, size.height};
|
||||
}
|
||||
|
||||
void pLabel::setText(const string &text) {
|
||||
|
@ -2,14 +2,14 @@
|
||||
@public
|
||||
phoenix::Label *label;
|
||||
}
|
||||
-(id) initWith :(phoenix::Label&)label;
|
||||
-(id) initWith:(phoenix::Label&)label;
|
||||
@end
|
||||
|
||||
namespace phoenix {
|
||||
|
||||
struct pLabel : public pWidget {
|
||||
Label &label;
|
||||
CocoaLabel *cocoaLabel;
|
||||
CocoaLabel *cocoaLabel = nullptr;
|
||||
|
||||
Size minimumSize();
|
||||
void setText(const string &text);
|
||||
|
@ -1,6 +1,6 @@
|
||||
@implementation CocoaLineEdit : NSTextField
|
||||
|
||||
-(id) initWith :(phoenix::LineEdit&)lineEditReference {
|
||||
-(id) initWith:(phoenix::LineEdit&)lineEditReference {
|
||||
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) {
|
||||
lineEdit = &lineEditReference;
|
||||
|
||||
@ -14,11 +14,11 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void) textDidChange :(NSNotification*)n {
|
||||
-(void) textDidChange:(NSNotification*)n {
|
||||
if(lineEdit->onChange) lineEdit->onChange();
|
||||
}
|
||||
|
||||
-(IBAction) activate :(id)sender {
|
||||
-(IBAction) activate:(id)sender {
|
||||
if(lineEdit->onActivate) lineEdit->onActivate();
|
||||
}
|
||||
|
||||
|
@ -2,16 +2,16 @@
|
||||
@public
|
||||
phoenix::LineEdit *lineEdit;
|
||||
}
|
||||
-(id) initWith :(phoenix::LineEdit&)lineEdit;
|
||||
-(void) textDidChange :(NSNotification*)n;
|
||||
-(IBAction) activate :(id)sender;
|
||||
-(id) initWith:(phoenix::LineEdit&)lineEdit;
|
||||
-(void) textDidChange:(NSNotification*)n;
|
||||
-(IBAction) activate:(id)sender;
|
||||
@end
|
||||
|
||||
namespace phoenix {
|
||||
|
||||
struct pLineEdit : public pWidget {
|
||||
LineEdit &lineEdit;
|
||||
CocoaLineEdit *cocoaLineEdit;
|
||||
CocoaLineEdit *cocoaLineEdit = nullptr;
|
||||
|
||||
Size minimumSize();
|
||||
void setEditable(bool editable);
|
||||
|
@ -1,6 +1,6 @@
|
||||
@implementation CocoaListView : NSScrollView
|
||||
|
||||
-(id) initWith :(phoenix::ListView&)listViewReference {
|
||||
-(id) initWith:(phoenix::ListView&)listViewReference {
|
||||
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) {
|
||||
listView = &listViewReference;
|
||||
content = [[CocoaListViewContent alloc] initWithFrame:NSMakeRect(0, 0, 0, 0)];
|
||||
@ -12,14 +12,14 @@
|
||||
[content setDataSource:self];
|
||||
[content setDelegate:self];
|
||||
[content setTarget:self];
|
||||
[content setDoubleAction:@selector(activate:)];
|
||||
[content setDoubleAction:@selector(doubleAction:)];
|
||||
|
||||
[content setAllowsColumnReordering:NO];
|
||||
[content setAllowsColumnResizing:YES];
|
||||
[content setAllowsColumnSelection:NO];
|
||||
[content setAllowsEmptySelection:YES];
|
||||
[content setAllowsMultipleSelection:NO];
|
||||
[content setColumnAutoresizingStyle:NSTableViewNoColumnAutoresizing];
|
||||
[content setColumnAutoresizingStyle:NSTableViewLastColumnOnlyAutoresizingStyle];
|
||||
|
||||
font = nil;
|
||||
[self setFont:nil];
|
||||
@ -41,7 +41,7 @@
|
||||
return font;
|
||||
}
|
||||
|
||||
-(void) setFont :(NSFont*)fontPointer {
|
||||
-(void) setFont:(NSFont*)fontPointer {
|
||||
if(!fontPointer) fontPointer = [NSFont systemFontOfSize:12];
|
||||
[fontPointer retain];
|
||||
if(font) [font release];
|
||||
@ -94,11 +94,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
-(NSInteger) numberOfRowsInTableView :(NSTableView*)table {
|
||||
-(NSInteger) numberOfRowsInTableView:(NSTableView*)table {
|
||||
return listView->state.text.size();
|
||||
}
|
||||
|
||||
-(id) tableView :(NSTableView*)table objectValueForTableColumn :(NSTableColumn*)tableColumn row:(NSInteger)row {
|
||||
-(id) tableView:(NSTableView*)table objectValueForTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row {
|
||||
if([[tableColumn identifier] isEqualToString:@"check"]) {
|
||||
auto checked = listView->state.checked(row) ? NSOnState : NSOffState;
|
||||
return [NSNumber numberWithInteger:checked];
|
||||
@ -114,37 +114,53 @@
|
||||
return @{ @"text":text };
|
||||
}
|
||||
|
||||
-(void) tableView :(NSTableView*)table setObjectValue:(id)object forTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row {
|
||||
-(BOOL) tableView:(NSTableView*)table shouldShowCellExpansionForTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row {
|
||||
return NO;
|
||||
}
|
||||
|
||||
-(NSString*) tableView:(NSTableView*)table toolTipForCell:(NSCell*)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row mouseLocation:(NSPoint)mouseLocation {
|
||||
return nil;
|
||||
}
|
||||
|
||||
-(void) tableView:(NSTableView*)table setObjectValue:(id)object forTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row {
|
||||
if([[tableColumn identifier] isEqualToString:@"check"]) {
|
||||
listView->state.checked(row) = [object integerValue] != NSOffState;
|
||||
if(listView->onToggle) listView->onToggle(row);
|
||||
}
|
||||
}
|
||||
|
||||
-(void) tableView :(NSTableView*)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row {
|
||||
-(void) tableView:(NSTableView*)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row {
|
||||
[cell setFont:[self font]];
|
||||
}
|
||||
|
||||
-(void) tableViewSelectionDidChange :(NSNotification*)notification {
|
||||
-(void) tableViewSelectionDidChange:(NSNotification*)notification {
|
||||
if(listView->onChange) listView->onChange();
|
||||
}
|
||||
|
||||
-(IBAction) activate :(id)sender {
|
||||
if([content clickedRow] < 0) return;
|
||||
-(IBAction) activate:(id)sender {
|
||||
if(listView->onActivate) listView->onActivate();
|
||||
}
|
||||
|
||||
-(IBAction) doubleAction:(id)sender {
|
||||
if([content clickedRow] >= 0) {
|
||||
[self activate:self];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CocoaListViewContent : NSTableView
|
||||
|
||||
-(void) keyDown :(NSEvent*)event {
|
||||
[super keyDown:event];
|
||||
|
||||
-(void) keyDown:(NSEvent*)event {
|
||||
auto character = [[event characters] characterAtIndex:0];
|
||||
if(character == NSEnterCharacter || character == NSCarriageReturnCharacter) {
|
||||
if([self selectedRow] >= 0) {
|
||||
[[self delegate] activate:self];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[super keyDown:event];
|
||||
}
|
||||
|
||||
@end
|
||||
@ -156,7 +172,7 @@
|
||||
return [[self objectValue] objectForKey:@"text"];
|
||||
}
|
||||
|
||||
-(void) drawWithFrame :(NSRect)frame inView:(NSView*)view {
|
||||
-(void) drawWithFrame:(NSRect)frame inView:(NSView*)view {
|
||||
NSString *text = [[self objectValue] objectForKey:@"text"];
|
||||
NSImage *image = [[self objectValue] objectForKey:@"image"];
|
||||
unsigned textDisplacement = 0;
|
||||
@ -206,7 +222,7 @@ void pListView::autoSizeColumns() {
|
||||
}
|
||||
|
||||
unsigned height = [[cocoaView content] rowHeight];
|
||||
for(unsigned column = 0; column < listView.state.headerText.size(); column++) {
|
||||
for(unsigned column = 0; column < max(1u, listView.state.headerText.size()); column++) {
|
||||
NSTableColumn *tableColumn = [[cocoaView content] tableColumnWithIdentifier:[[NSNumber numberWithInteger:column] stringValue]];
|
||||
unsigned minimumWidth = pFont::size([[tableColumn headerCell] font], listView.state.headerText(column)).width + 4;
|
||||
for(unsigned row = 0; row < listView.state.text.size(); row++) {
|
||||
@ -216,6 +232,8 @@ void pListView::autoSizeColumns() {
|
||||
}
|
||||
[tableColumn setWidth:minimumWidth];
|
||||
}
|
||||
|
||||
[[cocoaView content] sizeLastColumnToFit];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,36 +6,39 @@
|
||||
CocoaListViewContent *content;
|
||||
NSFont *font;
|
||||
}
|
||||
-(id) initWith :(phoenix::ListView&)listView;
|
||||
-(id) initWith:(phoenix::ListView&)listView;
|
||||
-(void) dealloc;
|
||||
-(CocoaListViewContent*) content;
|
||||
-(NSFont*) font;
|
||||
-(void) setFont :(NSFont*)font;
|
||||
-(void) setFont:(NSFont*)font;
|
||||
-(void) reloadColumns;
|
||||
-(NSInteger) numberOfRowsInTableView :(NSTableView*)table;
|
||||
-(id) tableView :(NSTableView*)table objectValueForTableColumn :(NSTableColumn*)tableColumn row:(NSInteger)row;
|
||||
-(void) tableView :(NSTableView*)table setObjectValue:(id)object forTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row;
|
||||
-(void) tableView :(NSTableView*)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row;
|
||||
-(void) tableViewSelectionDidChange :(NSNotification*)notification;
|
||||
-(IBAction) activate :(id)sender;
|
||||
-(NSInteger) numberOfRowsInTableView:(NSTableView*)table;
|
||||
-(id) tableView:(NSTableView*)table objectValueForTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row;
|
||||
-(BOOL) tableView:(NSTableView*)table shouldShowCellExpansionForTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row;
|
||||
-(NSString*) tableView:(NSTableView*)table toolTipForCell:(NSCell*)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row mouseLocation:(NSPoint)mouseLocation;
|
||||
-(void) tableView:(NSTableView*)table setObjectValue:(id)object forTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row;
|
||||
-(void) tableView:(NSTableView*)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row;
|
||||
-(void) tableViewSelectionDidChange:(NSNotification*)notification;
|
||||
-(IBAction) activate:(id)sender;
|
||||
-(IBAction) doubleAction:(id)sender;
|
||||
@end
|
||||
|
||||
@interface CocoaListViewContent : NSTableView {
|
||||
}
|
||||
-(void) keyDown :(NSEvent*)event;
|
||||
-(void) keyDown:(NSEvent*)event;
|
||||
@end
|
||||
|
||||
@interface CocoaListViewCell : NSTextFieldCell {
|
||||
}
|
||||
-(NSString*) stringValue;
|
||||
-(void) drawWithFrame :(NSRect)frame inView:(NSView*)view;
|
||||
-(void) drawWithFrame:(NSRect)frame inView:(NSView*)view;
|
||||
@end
|
||||
|
||||
namespace phoenix {
|
||||
|
||||
struct pListView : public pWidget {
|
||||
ListView &listView;
|
||||
CocoaListView *cocoaListView;
|
||||
CocoaListView *cocoaListView = nullptr;
|
||||
|
||||
void append(const lstring &text);
|
||||
void autoSizeColumns();
|
||||
|
@ -1,6 +1,6 @@
|
||||
@implementation CocoaProgressBar : NSProgressIndicator
|
||||
|
||||
-(id) initWith :(phoenix::ProgressBar&)progressBarReference {
|
||||
-(id) initWith:(phoenix::ProgressBar&)progressBarReference {
|
||||
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) {
|
||||
progressBar = &progressBarReference;
|
||||
|
||||
|
@ -2,14 +2,14 @@
|
||||
@public
|
||||
phoenix::ProgressBar *progressBar;
|
||||
}
|
||||
-(id) initWith :(phoenix::ProgressBar&)progressBar;
|
||||
-(id) initWith:(phoenix::ProgressBar&)progressBar;
|
||||
@end
|
||||
|
||||
namespace phoenix {
|
||||
|
||||
struct pProgressBar : public pWidget {
|
||||
ProgressBar &progressBar;
|
||||
CocoaProgressBar *cocoaProgressBar;
|
||||
CocoaProgressBar *cocoaProgressBar = nullptr;
|
||||
|
||||
void setPosition(unsigned position);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
@implementation CocoaRadioButton : NSButton
|
||||
|
||||
-(id) initWith :(phoenix::RadioButton&)radioButtonReference {
|
||||
-(id) initWith:(phoenix::RadioButton&)radioButtonReference {
|
||||
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) {
|
||||
radioButton = &radioButtonReference;
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
-(IBAction) activate :(id)sender {
|
||||
-(IBAction) activate:(id)sender {
|
||||
radioButton->setChecked();
|
||||
if(radioButton->onActivate) radioButton->onActivate();
|
||||
}
|
||||
|
@ -2,14 +2,15 @@
|
||||
@public
|
||||
phoenix::RadioButton *radioButton;
|
||||
}
|
||||
-(id) initWith :(phoenix::RadioButton&)radioButton;
|
||||
-(id) initWith:(phoenix::RadioButton&)radioButton;
|
||||
-(IBAction) activate:(id)sender;
|
||||
@end
|
||||
|
||||
namespace phoenix {
|
||||
|
||||
struct pRadioButton : public pWidget {
|
||||
RadioButton &radioButton;
|
||||
CocoaRadioButton *cocoaRadioButton;
|
||||
CocoaRadioButton *cocoaRadioButton = nullptr;
|
||||
|
||||
bool checked();
|
||||
Size minimumSize();
|
||||
|
@ -1,6 +1,6 @@
|
||||
@implementation CocoaTextEdit : NSScrollView
|
||||
|
||||
-(id) initWith :(phoenix::TextEdit&)textEditReference {
|
||||
-(id) initWith:(phoenix::TextEdit&)textEditReference {
|
||||
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) {
|
||||
textEdit = &textEditReference;
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
[self setHasVerticalScroller:YES];
|
||||
}
|
||||
|
||||
-(void) textDidChange :(NSNotification*)notification {
|
||||
-(void) textDidChange:(NSNotification*)notification {
|
||||
textEdit->state.text = [[content string] UTF8String];
|
||||
if(textEdit->onChange) textEdit->onChange();
|
||||
}
|
||||
|
@ -3,17 +3,17 @@
|
||||
phoenix::TextEdit *textEdit;
|
||||
NSTextView *content;
|
||||
}
|
||||
-(id) initWith :(phoenix::TextEdit&)textEdit;
|
||||
-(id) initWith:(phoenix::TextEdit&)textEdit;
|
||||
-(NSTextView*) content;
|
||||
-(void) configure;
|
||||
-(void) textDidChange :(NSNotification*)notification;
|
||||
-(void) textDidChange:(NSNotification*)notification;
|
||||
@end
|
||||
|
||||
namespace phoenix {
|
||||
|
||||
struct pTextEdit : public pWidget {
|
||||
TextEdit &textEdit;
|
||||
CocoaTextEdit *cocoaTextEdit;
|
||||
CocoaTextEdit *cocoaTextEdit = nullptr;
|
||||
|
||||
void setCursorPosition(unsigned position);
|
||||
void setEditable(bool editable);
|
||||
|
@ -1,6 +1,6 @@
|
||||
@implementation CocoaVerticalScroller : NSScroller
|
||||
|
||||
-(id) initWith :(phoenix::VerticalScroller&)verticalScrollerReference {
|
||||
-(id) initWith:(phoenix::VerticalScroller&)verticalScrollerReference {
|
||||
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 1)]) {
|
||||
verticalScroller = &verticalScrollerReference;
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
[self setKnobProportion:d];
|
||||
}
|
||||
|
||||
-(IBAction) scroll :(id)sender {
|
||||
-(IBAction) scroll:(id)sender {
|
||||
auto &state = verticalScroller->state;
|
||||
|
||||
switch([self hitPart]) {
|
||||
|
@ -2,14 +2,16 @@
|
||||
@public
|
||||
phoenix::VerticalScroller *verticalScroller;
|
||||
}
|
||||
-(id) initWith :(phoenix::VerticalScroller&)verticalScroller;
|
||||
-(id) initWith:(phoenix::VerticalScroller&)verticalScroller;
|
||||
-(void) update;
|
||||
-(IBAction) scroll:(id)sender;
|
||||
@end
|
||||
|
||||
namespace phoenix {
|
||||
|
||||
struct pVerticalScroller : public pWidget {
|
||||
VerticalScroller &verticalScroller;
|
||||
CocoaVerticalScroller *cocoaVerticalScroller;
|
||||
CocoaVerticalScroller *cocoaVerticalScroller = nullptr;
|
||||
|
||||
Size minimumSize();
|
||||
unsigned position();
|
||||
|
@ -1,6 +1,6 @@
|
||||
@implementation CocoaVerticalSlider : NSSlider
|
||||
|
||||
-(id) initWith :(phoenix::VerticalSlider&)verticalSliderReference {
|
||||
-(id) initWith:(phoenix::VerticalSlider&)verticalSliderReference {
|
||||
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 1)]) {
|
||||
verticalSlider = &verticalSliderReference;
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
-(IBAction) activate :(id)sender {
|
||||
-(IBAction) activate:(id)sender {
|
||||
verticalSlider->state.position = [self doubleValue];
|
||||
if(verticalSlider->onChange) verticalSlider->onChange();
|
||||
}
|
||||
|
@ -2,15 +2,15 @@
|
||||
@public
|
||||
phoenix::VerticalSlider *verticalSlider;
|
||||
}
|
||||
-(id) initWith :(phoenix::VerticalSlider&)verticalSlider;
|
||||
-(IBAction) activate :(id)sender;
|
||||
-(id) initWith:(phoenix::VerticalSlider&)verticalSlider;
|
||||
-(IBAction) activate:(id)sender;
|
||||
@end
|
||||
|
||||
namespace phoenix {
|
||||
|
||||
struct pVerticalSlider : public pWidget {
|
||||
VerticalSlider &verticalSlider;
|
||||
CocoaVerticalSlider *cocoaVerticalSlider;
|
||||
CocoaVerticalSlider *cocoaVerticalSlider = nullptr;
|
||||
|
||||
Size minimumSize();
|
||||
unsigned position();
|
||||
|
@ -1,16 +1,25 @@
|
||||
@implementation CocoaViewport : NSView
|
||||
|
||||
-(id) initWith :(phoenix::Viewport&)viewportReference {
|
||||
-(id) initWith:(phoenix::Viewport&)viewportReference {
|
||||
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) {
|
||||
viewport = &viewportReference;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void) drawRect :(NSRect)rect {
|
||||
NSColor *background = [NSColor blackColor];
|
||||
[background set];
|
||||
NSRectFill([self bounds]);
|
||||
-(void) drawRect:(NSRect)rect {
|
||||
[[NSColor blackColor] setFill];
|
||||
NSRectFillUsingOperation(rect, NSCompositeSourceOver);
|
||||
}
|
||||
|
||||
-(BOOL) acceptsFirstResponder {
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(void) keyDown:(NSEvent*)event {
|
||||
}
|
||||
|
||||
-(void) keyUp:(NSEvent*)event {
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -2,15 +2,18 @@
|
||||
@public
|
||||
phoenix::Viewport *viewport;
|
||||
}
|
||||
-(id) initWith :(phoenix::Viewport&)viewport;
|
||||
-(void) drawRect :(NSRect)rect;
|
||||
-(id) initWith:(phoenix::Viewport&)viewport;
|
||||
-(void) drawRect:(NSRect)rect;
|
||||
-(BOOL) acceptsFirstResponder;
|
||||
-(void) keyDown:(NSEvent*)event;
|
||||
-(void) keyUp:(NSEvent*)event;
|
||||
@end
|
||||
|
||||
namespace phoenix {
|
||||
|
||||
struct pViewport : public pWidget {
|
||||
Viewport &viewport;
|
||||
CocoaViewport *cocoaViewport;
|
||||
CocoaViewport *cocoaViewport = nullptr;
|
||||
|
||||
uintptr_t handle();
|
||||
|
||||
|
@ -2,7 +2,7 @@ namespace phoenix {
|
||||
|
||||
struct pWidget : public pSizable {
|
||||
Widget &widget;
|
||||
NSView *cocoaView;
|
||||
NSView *cocoaView = nullptr;
|
||||
|
||||
bool enabled();
|
||||
bool focused();
|
||||
|
@ -1,6 +1,6 @@
|
||||
@implementation CocoaWindow : NSWindow
|
||||
|
||||
-(id) initWith :(phoenix::Window&)windowReference {
|
||||
-(id) initWith:(phoenix::Window&)windowReference {
|
||||
window = &windowReference;
|
||||
|
||||
NSUInteger style = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask;
|
||||
@ -10,7 +10,6 @@
|
||||
[self setDelegate:self];
|
||||
[self setReleasedWhenClosed:NO];
|
||||
[self setAcceptsMouseMovedEvents:YES];
|
||||
[self setLevel:NSFloatingWindowLevel]; //when launched from a terminal, this places the window above it
|
||||
[self setTitle:@""];
|
||||
|
||||
menuBar = [[NSMenu alloc] init];
|
||||
@ -35,6 +34,16 @@
|
||||
text = {"Quit ", phoenix::applicationState.name};
|
||||
item = [[[NSMenuItem alloc] initWithTitle:[NSString stringWithUTF8String:text] action:@selector(menuQuit) keyEquivalent:@""] autorelease];
|
||||
[rootMenu addItem:item];
|
||||
|
||||
statusBar = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 0, 0)];
|
||||
[statusBar setAlignment:NSLeftTextAlignment];
|
||||
[statusBar setBordered:YES];
|
||||
[statusBar setBezeled:YES];
|
||||
[statusBar setBezelStyle:NSTextFieldSquareBezel];
|
||||
[statusBar setEditable:NO];
|
||||
[statusBar setHidden:YES];
|
||||
|
||||
[[self contentView] addSubview:statusBar positioned:NSWindowBelow relativeTo:nil];
|
||||
}
|
||||
|
||||
return self;
|
||||
@ -48,21 +57,21 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(void) windowDidBecomeMain :(NSNotification*)notification {
|
||||
-(void) windowDidBecomeMain:(NSNotification*)notification {
|
||||
if(window->state.menu.size() > 0) {
|
||||
[NSApp setMainMenu:menuBar];
|
||||
}
|
||||
}
|
||||
|
||||
-(void) windowDidMove :(NSNotification*)notification {
|
||||
-(void) windowDidMove:(NSNotification*)notification {
|
||||
window->p.moveEvent();
|
||||
}
|
||||
|
||||
-(void) windowDidResize :(NSNotification*)notification {
|
||||
-(void) windowDidResize:(NSNotification*)notification {
|
||||
window->p.sizeEvent();
|
||||
}
|
||||
|
||||
-(BOOL) windowShouldClose :(id)sender {
|
||||
-(BOOL) windowShouldClose:(id)sender {
|
||||
if(window->onClose) window->onClose();
|
||||
else window->setVisible(false);
|
||||
if(window->state.modal && !window->visible()) window->setModal(false);
|
||||
@ -88,6 +97,10 @@
|
||||
if(Application::Cocoa::onQuit) Application::Cocoa::onQuit();
|
||||
}
|
||||
|
||||
-(NSTextField*) statusBar {
|
||||
return statusBar;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
namespace phoenix {
|
||||
@ -102,6 +115,8 @@ void pWindow::append(Layout &layout) {
|
||||
Geometry geometry = window.state.geometry;
|
||||
geometry.x = geometry.y = 0;
|
||||
layout.setGeometry(geometry);
|
||||
|
||||
statusBarReposition();
|
||||
}
|
||||
|
||||
void pWindow::append(Menu &menu) {
|
||||
@ -117,7 +132,7 @@ void pWindow::append(Widget &widget) {
|
||||
|
||||
@autoreleasepool {
|
||||
[widget.p.cocoaView removeFromSuperview];
|
||||
[[cocoaWindow contentView] addSubview:widget.p.cocoaView positioned:NSWindowAbove relativeTo:nil];
|
||||
[[cocoaWindow contentView] addSubview:widget.p.cocoaView positioned:NSWindowBelow relativeTo:nil];
|
||||
widget.p.setGeometry(widget.geometry());
|
||||
[[cocoaWindow contentView] setNeedsDisplay:YES];
|
||||
}
|
||||
@ -151,6 +166,7 @@ Geometry pWindow::frameMargin() {
|
||||
Geometry pWindow::geometry() {
|
||||
@autoreleasepool {
|
||||
NSRect area = [cocoaWindow contentRectForFrameRect:[cocoaWindow frame]];
|
||||
area.size.height -= statusBarHeight();
|
||||
return {area.origin.x, Desktop::size().height - area.origin.y - area.size.height, area.size.width, area.size.height};
|
||||
}
|
||||
}
|
||||
@ -213,7 +229,10 @@ void pWindow::setGeometry(const Geometry &geometry) {
|
||||
@autoreleasepool {
|
||||
[cocoaWindow
|
||||
setFrame:[cocoaWindow
|
||||
frameRectForContentRect:NSMakeRect(geometry.x, Desktop::size().height - geometry.y - geometry.height, geometry.width, geometry.height)
|
||||
frameRectForContentRect:NSMakeRect(
|
||||
geometry.x, Desktop::size().height - geometry.y - geometry.height,
|
||||
geometry.width, geometry.height + statusBarHeight()
|
||||
)
|
||||
]
|
||||
display:YES
|
||||
];
|
||||
@ -223,6 +242,8 @@ void pWindow::setGeometry(const Geometry &geometry) {
|
||||
geometry.x = geometry.y = 0;
|
||||
layout.setGeometry(geometry);
|
||||
}
|
||||
|
||||
statusBarReposition();
|
||||
}
|
||||
|
||||
locked = false;
|
||||
@ -255,12 +276,23 @@ void pWindow::setResizable(bool resizable) {
|
||||
}
|
||||
|
||||
void pWindow::setStatusFont(const string &font) {
|
||||
@autoreleasepool {
|
||||
[[cocoaWindow statusBar] setFont:pFont::cocoaFont(font)];
|
||||
}
|
||||
statusBarReposition();
|
||||
}
|
||||
|
||||
void pWindow::setStatusText(const string &text) {
|
||||
@autoreleasepool {
|
||||
[[cocoaWindow statusBar] setStringValue:[NSString stringWithUTF8String:text]];
|
||||
}
|
||||
}
|
||||
|
||||
void pWindow::setStatusVisible(bool visible) {
|
||||
@autoreleasepool {
|
||||
[[cocoaWindow statusBar] setHidden:!visible];
|
||||
setGeometry(geometry());
|
||||
}
|
||||
}
|
||||
|
||||
void pWindow::setTitle(const string &text) {
|
||||
@ -271,12 +303,8 @@ void pWindow::setTitle(const string &text) {
|
||||
|
||||
void pWindow::setVisible(bool visible) {
|
||||
@autoreleasepool {
|
||||
if(visible) {
|
||||
[cocoaWindow makeKeyAndOrderFront:nil];
|
||||
[cocoaWindow setLevel:NSNormalWindowLevel];
|
||||
} else {
|
||||
[cocoaWindow orderOut:nil];
|
||||
}
|
||||
if(visible) [cocoaWindow makeKeyAndOrderFront:nil];
|
||||
else [cocoaWindow orderOut:nil];
|
||||
}
|
||||
}
|
||||
|
||||
@ -320,9 +348,24 @@ void pWindow::sizeEvent() {
|
||||
layout.setGeometry(geometry);
|
||||
}
|
||||
|
||||
statusBarReposition();
|
||||
|
||||
if(locked == false) {
|
||||
if(window.onSize) window.onSize();
|
||||
}
|
||||
}
|
||||
|
||||
unsigned pWindow::statusBarHeight() {
|
||||
if(!window.state.statusVisible) return 0;
|
||||
return Font::size(window.state.statusFont, " ").height + 6;
|
||||
}
|
||||
|
||||
void pWindow::statusBarReposition() {
|
||||
@autoreleasepool {
|
||||
NSRect area = [cocoaWindow contentRectForFrameRect:[cocoaWindow frame]];
|
||||
[[cocoaWindow statusBar] setFrame:NSMakeRect(0, 0, area.size.width, statusBarHeight())];
|
||||
[[cocoaWindow contentView] setNeedsDisplay:YES];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,25 +3,27 @@
|
||||
phoenix::Window *window;
|
||||
NSMenu *menuBar;
|
||||
NSMenu *rootMenu;
|
||||
NSTextField *statusBar;
|
||||
}
|
||||
-(id) initWith :(phoenix::Window&)window;
|
||||
-(id) initWith:(phoenix::Window&)window;
|
||||
-(BOOL) canBecomeKeyWindow;
|
||||
-(BOOL) canBecomeMainWindow;
|
||||
-(void) windowDidBecomeMain :(NSNotification*)notification;
|
||||
-(void) windowDidMove :(NSNotification*)notification;
|
||||
-(void) windowDidResize :(NSNotification*)notification;
|
||||
-(BOOL) windowShouldClose :(id)sender;
|
||||
-(void) windowDidBecomeMain:(NSNotification*)notification;
|
||||
-(void) windowDidMove:(NSNotification*)notification;
|
||||
-(void) windowDidResize:(NSNotification*)notification;
|
||||
-(BOOL) windowShouldClose:(id)sender;
|
||||
-(NSMenu*) menuBar;
|
||||
-(void) menuAbout;
|
||||
-(void) menuPreferences;
|
||||
-(void) menuQuit;
|
||||
-(NSTextField*) statusBar;
|
||||
@end
|
||||
|
||||
namespace phoenix {
|
||||
|
||||
struct pWindow : public pObject {
|
||||
Window &window;
|
||||
CocoaWindow *cocoaWindow;
|
||||
CocoaWindow *cocoaWindow = nullptr;
|
||||
|
||||
static Window& none();
|
||||
|
||||
@ -55,6 +57,8 @@ struct pWindow : public pObject {
|
||||
void destructor();
|
||||
void moveEvent();
|
||||
void sizeEvent();
|
||||
unsigned statusBarHeight();
|
||||
void statusBarReposition();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -37,11 +37,12 @@ namespace phoenix {
|
||||
//Application
|
||||
//===========
|
||||
|
||||
nall::function<void ()> Application::main;
|
||||
function<void ()> Application::main;
|
||||
|
||||
nall::function<void ()> Application::Cocoa::onAbout;
|
||||
nall::function<void ()> Application::Cocoa::onPreferences;
|
||||
nall::function<void ()> Application::Cocoa::onQuit;
|
||||
function<void ()> Application::Cocoa::onAbout;
|
||||
function<void ()> Application::Cocoa::onActivate;
|
||||
function<void ()> Application::Cocoa::onPreferences;
|
||||
function<void ()> Application::Cocoa::onQuit;
|
||||
|
||||
void Application::run() {
|
||||
return pApplication::run();
|
||||
|
@ -65,6 +65,7 @@ struct Application {
|
||||
|
||||
struct Cocoa {
|
||||
static nall::function<void ()> onAbout;
|
||||
static nall::function<void ()> onActivate;
|
||||
static nall::function<void ()> onPreferences;
|
||||
static nall::function<void ()> onQuit;
|
||||
};
|
||||
|
@ -9,4 +9,7 @@ void pAction::setVisible(bool visible) {
|
||||
void pAction::constructor() {
|
||||
}
|
||||
|
||||
void pAction::destructor() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ struct pAction : public pObject {
|
||||
|
||||
pAction(Action &action) : pObject(action), action(action) {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
9
higan/phoenix/reference/object.cpp
Normal file
9
higan/phoenix/reference/object.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
namespace phoenix {
|
||||
|
||||
void pObject::constructor() {
|
||||
}
|
||||
|
||||
void pObject::destructor() {
|
||||
}
|
||||
|
||||
}
|
@ -7,8 +7,8 @@ struct pObject {
|
||||
pObject(Object &object) : object(object), locked(locked) {}
|
||||
virtual ~pObject() {}
|
||||
|
||||
void constructor() {}
|
||||
void destructor() {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
#include "platform.hpp"
|
||||
|
||||
#include "font.cpp"
|
||||
#include "desktop.cpp"
|
||||
#include "keyboard.cpp"
|
||||
#include "mouse.cpp"
|
||||
#include "browser-window.cpp"
|
||||
#include "message-window.cpp"
|
||||
#include "font.cpp"
|
||||
#include "object.cpp"
|
||||
#include "timer.cpp"
|
||||
#include "window.cpp"
|
||||
|
||||
|
@ -9,4 +9,7 @@ void pTimer::setInterval(unsigned milliseconds) {
|
||||
void pTimer::constructor() {
|
||||
}
|
||||
|
||||
void pTimer::destructor() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ struct pTimer : public pObject {
|
||||
|
||||
pTimer(Timer &timer) : pObject(timer), timer(timer) {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -9,4 +9,7 @@ void pButton::setText(const string &text) {
|
||||
void pButton::constructor() {
|
||||
}
|
||||
|
||||
void pButton::destructor() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ struct pButton : public pWidget {
|
||||
|
||||
pButton(Button &button) : pWidget(button), button(button) {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -9,4 +9,7 @@ void pCanvas::update() {
|
||||
void pCanvas::constructor() {
|
||||
}
|
||||
|
||||
void pCanvas::destructor() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ struct pCanvas : public pWidget {
|
||||
|
||||
pCanvas(Canvas &canvas) : pWidget(canvas), canvas(canvas) {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -13,4 +13,7 @@ void pCheckButton::setText(const string &text) {
|
||||
void pCheckButton::constructor() {
|
||||
}
|
||||
|
||||
void pCheckButton::destructor() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ struct pCheckButton : public pWidget {
|
||||
|
||||
pCheckButton(CheckButton &checkButton) : pWidget(checkButton), checkButton(checkButton) {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -22,4 +22,7 @@ void pComboButton::setSelection(unsigned row) {
|
||||
void pComboButton::constructor() {
|
||||
}
|
||||
|
||||
void pComboButton::destructor() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ struct pComboButton : public pWidget {
|
||||
|
||||
pComboButton(ComboButton &comboButton) : pWidget(comboButton), comboButton(comboButton) {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -18,4 +18,7 @@ void pHexEdit::update() {
|
||||
void pHexEdit::constructor() {
|
||||
}
|
||||
|
||||
void pHexEdit::destructor() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ struct pHexEdit : public pWidget {
|
||||
|
||||
pHexEdit(HexEdit &hexEdit) : pWidget(hexEdit), hexEdit(hexEdit) {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -13,4 +13,7 @@ void pHorizontalScroller::setPosition(unsigned position) {
|
||||
void pHorizontalScroller::constructor() {
|
||||
}
|
||||
|
||||
void pHorizontalScroller::destructor() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ struct pHorizontalScroller : public pWidget {
|
||||
|
||||
pHorizontalScroller(HorizontalScroller &horizontalScroller) : pWidget(horizontalScroller), horizontalScroller(horizontalScroller) {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -13,4 +13,7 @@ void pHorizontalSlider::setPosition(unsigned position) {
|
||||
void pHorizontalSlider::constructor() {
|
||||
}
|
||||
|
||||
void pHorizontalSlider::destructor() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ struct pHorizontalSlider : public pWidget {
|
||||
|
||||
pHorizontalSlider(HorizontalSlider &horizontalSlider) : pWidget(horizontalSlider), horizontalSlider(horizontalSlider) {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -6,4 +6,7 @@ void pLabel::setText(const string &text) {
|
||||
void pLabel::constructor() {
|
||||
}
|
||||
|
||||
void pLabel::destructor() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ struct pLabel : public pWidget {
|
||||
|
||||
pLabel(Label &label) : pWidget(label), label(label) {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -12,4 +12,7 @@ string pLineEdit::text() {
|
||||
void pLineEdit::constructor() {
|
||||
}
|
||||
|
||||
void pLineEdit::destructor() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ struct pLineEdit : public pWidget {
|
||||
|
||||
pLineEdit(LineEdit &lineEdit) : pWidget(lineEdit), lineEdit(lineEdit) {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -50,4 +50,7 @@ void pListView::setSelection(unsigned row) {
|
||||
void pListView::constructor() {
|
||||
}
|
||||
|
||||
void pListView::destructor() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ struct pListView : public pWidget {
|
||||
|
||||
pListView(ListView &listView) : pWidget(listView), listView(listView) {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -6,4 +6,7 @@ void pProgressBar::setPosition(unsigned position) {
|
||||
void pProgressBar::constructor() {
|
||||
}
|
||||
|
||||
void pProgressBar::destructor() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ struct pProgressBar : public pWidget {
|
||||
|
||||
pProgressBar(ProgressBar &progressBar) : pWidget(progressBar), progressBar(progressBar) {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -16,4 +16,7 @@ void pRadioButton::setText(const string &text) {
|
||||
void pRadioButton::constructor() {
|
||||
}
|
||||
|
||||
void pRadioButton::destructor() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ struct pRadioButton : public pWidget {
|
||||
|
||||
pRadioButton(RadioButton &radioButton) : pWidget(radioButton), radioButton(radioButton) {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -18,4 +18,7 @@ string pTextEdit::text() {
|
||||
void pTextEdit::constructor() {
|
||||
}
|
||||
|
||||
void pTextEdit::destructor() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ struct pTextEdit : public pWidget {
|
||||
|
||||
pTextEdit(TextEdit &textEdit) : pWidget(textEdit), textEdit(textEdit) {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -13,4 +13,7 @@ void pVerticalScroller::setPosition(unsigned position) {
|
||||
void pVerticalScroller::constructor() {
|
||||
}
|
||||
|
||||
void pVerticalScroller::destructor() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ struct pVerticalScroller : public pWidget {
|
||||
|
||||
pVerticalScroller(VerticalScroller &verticalScroller) : pWidget(verticalScroller), verticalScroller(verticalScroller) {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -13,4 +13,7 @@ void pVerticalSlider::setPosition(unsigned position) {
|
||||
void pVerticalSlider::constructor() {
|
||||
}
|
||||
|
||||
void pVerticalSlider::destructor() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ struct pVerticalSlider : public pWidget {
|
||||
|
||||
pVerticalSlider(VerticalSlider &verticalSlider) : pWidget(verticalSlider), verticalSlider(verticalSlider) {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -7,4 +7,7 @@ uintptr_t pViewport::handle() {
|
||||
void pViewport::constructor() {
|
||||
}
|
||||
|
||||
void pViewport::destructor() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ struct pViewport : public pWidget {
|
||||
|
||||
pViewport(Viewport &viewport) : pWidget(viewport), viewport(viewport) {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -30,4 +30,7 @@ void pWidget::setVisible(bool visible) {
|
||||
void pWidget::constructor() {
|
||||
}
|
||||
|
||||
void pWidget::destructor() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ struct pWidget : public pSizable {
|
||||
|
||||
pWidget(Widget &widget) : pSizable(widget), widget(widget) {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -85,4 +85,7 @@ void pWindow::setWidgetFont(const string &font) {
|
||||
void pWindow::constructor() {
|
||||
}
|
||||
|
||||
void pWindow::destructor() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ struct pWindow : public pObject {
|
||||
|
||||
pWindow(Window &window) : pObject(window), window(window) {}
|
||||
void constructor();
|
||||
void destructor();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,22 @@
|
||||
#include "opengl.hpp"
|
||||
|
||||
namespace ruby {
|
||||
class pVideoCGL;
|
||||
}
|
||||
|
||||
@interface RubyVideoCGL : NSOpenGLView {
|
||||
@public
|
||||
ruby::pVideoCGL *video;
|
||||
}
|
||||
-(id) initWith:(ruby::pVideoCGL*)video pixelFormat:(NSOpenGLPixelFormat*)pixelFormat;
|
||||
-(void) reshape;
|
||||
@end
|
||||
|
||||
namespace ruby {
|
||||
|
||||
class pVideoCGL : public OpenGL {
|
||||
public:
|
||||
NSOpenGLView *view;
|
||||
RubyVideoCGL *view;
|
||||
|
||||
struct {
|
||||
NSView *handle;
|
||||
@ -121,8 +133,8 @@ public:
|
||||
|
||||
auto size = [settings.handle frame].size;
|
||||
auto format = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attributes] autorelease];
|
||||
view = [[NSOpenGLView alloc] initWithFrame:NSMakeRect(0, 0, 0, 0) pixelFormat:format];
|
||||
|
||||
view = [[RubyVideoCGL alloc] initWith:this pixelFormat:format];
|
||||
[view setFrame:NSMakeRect(0, 0, size.width, size.height)];
|
||||
[view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||
[settings.handle addSubview:view];
|
||||
@ -140,6 +152,7 @@ public:
|
||||
[view unlockFocus];
|
||||
}
|
||||
|
||||
clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -172,3 +185,18 @@ public:
|
||||
DeclareVideo(CGL)
|
||||
|
||||
}
|
||||
|
||||
@implementation RubyVideoCGL : NSOpenGLView
|
||||
|
||||
-(id) initWith:(ruby::pVideoCGL*)videoPointer pixelFormat:(NSOpenGLPixelFormat*)pixelFormat {
|
||||
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0) pixelFormat:pixelFormat]) {
|
||||
video = videoPointer;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void) reshape {
|
||||
video->refresh();
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -1,7 +1,3 @@
|
||||
namespace Info {
|
||||
static const char Profile[] = "Accuracy";
|
||||
}
|
||||
|
||||
#include <sfc/cpu/cpu.hpp>
|
||||
#include <sfc/smp/smp.hpp>
|
||||
#include <sfc/dsp/dsp.hpp>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user