mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-14 04:34:08 +02:00
macOS Cocoa improvements.
This commit is contained in:
@@ -31,7 +31,7 @@ using namespace nall;
|
|||||||
|
|
||||||
namespace Emulator {
|
namespace Emulator {
|
||||||
static const string Name = "bsnes";
|
static const string Name = "bsnes";
|
||||||
static const string Version = "107.15";
|
static const string Version = "107.16";
|
||||||
static const string Author = "byuu";
|
static const string Author = "byuu";
|
||||||
static const string License = "GPLv3";
|
static const string License = "GPLv3";
|
||||||
static const string Website = "https://byuu.org";
|
static const string Website = "https://byuu.org";
|
||||||
|
@@ -39,7 +39,10 @@ ifeq ($(shell id -un),root)
|
|||||||
else ifeq ($(platform),windows)
|
else ifeq ($(platform),windows)
|
||||||
else ifeq ($(platform),macos)
|
else ifeq ($(platform),macos)
|
||||||
mkdir -p ~/Library/Application\ Support/$(name)/
|
mkdir -p ~/Library/Application\ Support/$(name)/
|
||||||
|
mkdir -p ~/Library/Application\ Support/$(name)/Database/
|
||||||
cp -R out/$(name).app /Applications/$(name).app
|
cp -R out/$(name).app /Applications/$(name).app
|
||||||
|
cp Database/* ~/Library/Application\ Support/$(name)/Database/
|
||||||
|
cp ../icarus/Database/* ~/Library/Application\ Support/$(name)/Database/
|
||||||
else ifneq ($(filter $(platform),linux bsd),)
|
else ifneq ($(filter $(platform),linux bsd),)
|
||||||
mkdir -p $(prefix)/bin/
|
mkdir -p $(prefix)/bin/
|
||||||
mkdir -p $(prefix)/share/applications/
|
mkdir -p $(prefix)/share/applications/
|
||||||
|
@@ -22,6 +22,7 @@ auto Program::create() -> void {
|
|||||||
|
|
||||||
presentation.create();
|
presentation.create();
|
||||||
presentation.setVisible();
|
presentation.setVisible();
|
||||||
|
presentation.viewport.setFocused();
|
||||||
|
|
||||||
settingsWindow.create();
|
settingsWindow.create();
|
||||||
videoSettings.create();
|
videoSettings.create();
|
||||||
|
@@ -137,7 +137,7 @@ auto EmulatorSettings::create() -> void {
|
|||||||
settings.emulator.hack.fastSuperFX = superFXClock.position() * 10 + 100;
|
settings.emulator.hack.fastSuperFX = superFXClock.position() * 10 + 100;
|
||||||
superFXValue.setText({settings.emulator.hack.fastSuperFX, "%"});
|
superFXValue.setText({settings.emulator.hack.fastSuperFX, "%"});
|
||||||
}).doChange();
|
}).doChange();
|
||||||
hacksNote.setForegroundColor({224, 0, 0}).setText("Note: some hack setting changes do not take effect until after reloading games.");
|
hacksNote.setText("Note: some hack setting changes do not take effect until after reloading games.");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto EmulatorSettings::updateConfiguration() -> void {
|
auto EmulatorSettings::updateConfiguration() -> void {
|
||||||
|
@@ -33,7 +33,7 @@ auto HotkeySettings::reloadMappings() -> void {
|
|||||||
mappingList.append(TableViewColumn().setText("Mapping").setExpandable());
|
mappingList.append(TableViewColumn().setText("Mapping").setExpandable());
|
||||||
for(auto& hotkey : inputManager.hotkeys) {
|
for(auto& hotkey : inputManager.hotkeys) {
|
||||||
mappingList.append(TableViewItem()
|
mappingList.append(TableViewItem()
|
||||||
.append(TableViewCell().setText(hotkey.name).setFont(Font().setBold()).setBackgroundColor({240, 240, 255}))
|
.append(TableViewCell().setText(hotkey.name).setFont(Font().setBold()))
|
||||||
.append(TableViewCell())
|
.append(TableViewCell())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -97,7 +97,7 @@ auto InputSettings::reloadMappings() -> void {
|
|||||||
mappingList.append(TableViewColumn().setText("Mapping").setExpandable());
|
mappingList.append(TableViewColumn().setText("Mapping").setExpandable());
|
||||||
for(auto& mapping : activeDevice().mappings) {
|
for(auto& mapping : activeDevice().mappings) {
|
||||||
mappingList.append(TableViewItem()
|
mappingList.append(TableViewItem()
|
||||||
.append(TableViewCell().setText(mapping.name).setFont(Font().setBold()).setBackgroundColor({240, 240, 255}))
|
.append(TableViewCell().setText(mapping.name).setFont(Font().setBold()))
|
||||||
.append(TableViewCell())
|
.append(TableViewCell())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,13 @@ auto NSMakeColor(const hiro::Color& color) -> NSColor* {
|
|||||||
return [NSColor colorWithRed:(color.red() / 255.0) green:(color.green() / 255.0) blue:(color.blue() / 255.0) alpha:(color.alpha() / 255.0)];
|
return [NSColor colorWithRed:(color.red() / 255.0) green:(color.green() / 255.0) blue:(color.blue() / 255.0) alpha:(color.alpha() / 255.0)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto NSMakeCursor(const hiro::MouseCursor& mouseCursor) -> NSCursor* {
|
||||||
|
if(mouseCursor == MouseCursor::Hand) return [NSCursor pointingHandCursor];
|
||||||
|
if(mouseCursor == MouseCursor::HorizontalResize) return [NSCursor resizeLeftRightCursor];
|
||||||
|
if(mouseCursor == MouseCursor::VerticalResize) return [NSCursor resizeUpDownCursor];
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
auto NSMakeImage(image icon, uint scaleWidth = 0, uint scaleHeight = 0) -> NSImage* {
|
auto NSMakeImage(image icon, uint scaleWidth = 0, uint scaleHeight = 0) -> NSImage* {
|
||||||
if(!icon) return nil;
|
if(!icon) return nil;
|
||||||
|
|
||||||
@@ -14,7 +21,7 @@ auto NSMakeImage(image icon, uint scaleWidth = 0, uint scaleHeight = 0) -> NSIma
|
|||||||
initWithBitmapDataPlanes:nil
|
initWithBitmapDataPlanes:nil
|
||||||
pixelsWide:icon.width() pixelsHigh:icon.height()
|
pixelsWide:icon.width() pixelsHigh:icon.height()
|
||||||
bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES
|
bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES
|
||||||
isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace
|
isPlanar:NO colorSpaceName:NSDeviceRGBColorSpace
|
||||||
bitmapFormat:NSAlphaNonpremultipliedBitmapFormat
|
bitmapFormat:NSAlphaNonpremultipliedBitmapFormat
|
||||||
bytesPerRow:(4 * icon.width()) bitsPerPixel:32
|
bytesPerRow:(4 * icon.width()) bitsPerPixel:32
|
||||||
] autorelease];
|
] autorelease];
|
||||||
|
@@ -15,6 +15,12 @@
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void) resetCursorRects {
|
||||||
|
if(auto mouseCursor = NSMakeCursor(label->mouseCursor())) {
|
||||||
|
[self addCursorRect:self.bounds cursor:mouseCursor];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
-(NSDragOperation) draggingEntered:(id<NSDraggingInfo>)sender {
|
-(NSDragOperation) draggingEntered:(id<NSDraggingInfo>)sender {
|
||||||
return DropPathsOperation(sender);
|
return DropPathsOperation(sender);
|
||||||
}
|
}
|
||||||
@@ -42,6 +48,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void) mouseEntered:(NSEvent*)event {
|
||||||
|
canvas->doMouseEnter();
|
||||||
|
}
|
||||||
|
|
||||||
-(void) mouseExited:(NSEvent*)event {
|
-(void) mouseExited:(NSEvent*)event {
|
||||||
canvas->doMouseLeave();
|
canvas->doMouseLeave();
|
||||||
}
|
}
|
||||||
@@ -183,7 +193,7 @@ auto pCanvas::_rasterize() -> void {
|
|||||||
initWithBitmapDataPlanes:nil
|
initWithBitmapDataPlanes:nil
|
||||||
pixelsWide:width pixelsHigh:height
|
pixelsWide:width pixelsHigh:height
|
||||||
bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES
|
bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES
|
||||||
isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace
|
isPlanar:NO colorSpaceName:NSDeviceRGBColorSpace
|
||||||
bitmapFormat:NSAlphaNonpremultipliedBitmapFormat
|
bitmapFormat:NSAlphaNonpremultipliedBitmapFormat
|
||||||
bytesPerRow:(width * 4) bitsPerPixel:32
|
bytesPerRow:(width * 4) bitsPerPixel:32
|
||||||
] autorelease];
|
] autorelease];
|
||||||
|
@@ -5,9 +5,11 @@
|
|||||||
hiro::mCanvas* canvas;
|
hiro::mCanvas* canvas;
|
||||||
}
|
}
|
||||||
-(id) initWith:(hiro::mCanvas&)canvas;
|
-(id) initWith:(hiro::mCanvas&)canvas;
|
||||||
|
-(void) resetCursorRects;
|
||||||
-(NSDragOperation) draggingEntered:(id<NSDraggingInfo>)sender;
|
-(NSDragOperation) draggingEntered:(id<NSDraggingInfo>)sender;
|
||||||
-(BOOL) performDragOperation:(id<NSDraggingInfo>)sender;
|
-(BOOL) performDragOperation:(id<NSDraggingInfo>)sender;
|
||||||
-(void) mouseButton:(NSEvent*)event down:(BOOL)isDown;
|
-(void) mouseButton:(NSEvent*)event down:(BOOL)isDown;
|
||||||
|
-(void) mouseEntered:(NSEvent*)event;
|
||||||
-(void) mouseExited:(NSEvent*)event;
|
-(void) mouseExited:(NSEvent*)event;
|
||||||
-(void) mouseMove:(NSEvent*)event;
|
-(void) mouseMove:(NSEvent*)event;
|
||||||
-(void) mouseDown:(NSEvent*)event;
|
-(void) mouseDown:(NSEvent*)event;
|
||||||
|
@@ -1,22 +1,123 @@
|
|||||||
#if defined(Hiro_Label)
|
#if defined(Hiro_Label)
|
||||||
|
|
||||||
//todo:
|
@implementation CocoaLabel : NSView
|
||||||
//* Label::onButtonPress()
|
|
||||||
//* Label::onButtonRelease()
|
|
||||||
|
|
||||||
@implementation CocoaLabel : NSTextView
|
|
||||||
|
|
||||||
-(id) initWith:(hiro::mLabel&)labelReference {
|
-(id) initWith:(hiro::mLabel&)labelReference {
|
||||||
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) {
|
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) {
|
||||||
label = &labelReference;
|
label = &labelReference;
|
||||||
|
|
||||||
[self setDrawsBackground:NO];
|
|
||||||
[self setEditable:NO];
|
|
||||||
[self setRichText:NO];
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void) resetCursorRects {
|
||||||
|
if(auto mouseCursor = NSMakeCursor(label->mouseCursor())) {
|
||||||
|
[self addCursorRect:self.bounds cursor:mouseCursor];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) drawRect:(NSRect)dirtyRect {
|
||||||
|
auto geometry = label->geometry();
|
||||||
|
NSRect rect = {{geometry.x(), geometry.y()}, {geometry.width(), geometry.height()}};
|
||||||
|
|
||||||
|
if(auto backgroundColor = label->backgroundColor()) {
|
||||||
|
NSColor* color = NSMakeColor(backgroundColor);
|
||||||
|
[color setFill];
|
||||||
|
NSRectFill(rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
NSFont* font = hiro::pFont::create(label->font(true));
|
||||||
|
NSColor* color = [NSColor textColor];
|
||||||
|
if(auto foregroundColor = label->foregroundColor()) {
|
||||||
|
color = NSMakeColor(foregroundColor);
|
||||||
|
}
|
||||||
|
NSMutableParagraphStyle* paragraphStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
|
||||||
|
paragraphStyle.alignment = NSTextAlignmentLeft;
|
||||||
|
paragraphStyle.lineBreakMode = NSLineBreakByClipping;
|
||||||
|
NSDictionary* attributes = @{
|
||||||
|
NSFontAttributeName:font,
|
||||||
|
NSForegroundColorAttributeName:color,
|
||||||
|
NSParagraphStyleAttributeName:paragraphStyle
|
||||||
|
};
|
||||||
|
|
||||||
|
auto size = hiro::pFont::size(label->font(true), label->text());
|
||||||
|
auto alignment = label->alignment();
|
||||||
|
if(!alignment) alignment = {0.0, 0.5};
|
||||||
|
|
||||||
|
rect.origin.x = max(0, (geometry.width() - size.width()) * alignment.horizontal());
|
||||||
|
rect.origin.y = max(0, (geometry.height() - size.height()) * alignment.vertical());
|
||||||
|
rect.size.width = min(geometry.width(), size.width());
|
||||||
|
rect.size.height = min(geometry.height(), size.height());
|
||||||
|
|
||||||
|
NSString* string = [NSString stringWithUTF8String:label->text()];
|
||||||
|
[string drawInRect:rect withAttributes:attributes];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) mouseButton:(NSEvent*)event down:(BOOL)isDown {
|
||||||
|
if(isDown) {
|
||||||
|
switch([event buttonNumber]) {
|
||||||
|
case 0: return label->doMousePress(hiro::Mouse::Button::Left);
|
||||||
|
case 1: return label->doMousePress(hiro::Mouse::Button::Right);
|
||||||
|
case 2: return label->doMousePress(hiro::Mouse::Button::Middle);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch([event buttonNumber]) {
|
||||||
|
case 0: return label->doMouseRelease(hiro::Mouse::Button::Left);
|
||||||
|
case 1: return label->doMouseRelease(hiro::Mouse::Button::Right);
|
||||||
|
case 2: return label->doMouseRelease(hiro::Mouse::Button::Middle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) mouseEntered:(NSEvent*)event {
|
||||||
|
label->doMouseEnter();
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) mouseExited:(NSEvent*)event {
|
||||||
|
label->doMouseLeave();
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) mouseMove:(NSEvent*)event {
|
||||||
|
if([event window] == nil) return;
|
||||||
|
NSPoint location = [self convertPoint:[event locationInWindow] fromView:nil];
|
||||||
|
label->doMouseMove({(int)location.x, (int)([self frame].size.height - 1 - location.y)});
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) mouseDown:(NSEvent*)event {
|
||||||
|
[self mouseButton:event down:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) mouseUp:(NSEvent*)event {
|
||||||
|
[self mouseButton:event down:NO];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) mouseDragged:(NSEvent*)event {
|
||||||
|
[self mouseMove:event];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) rightMouseDown:(NSEvent*)event {
|
||||||
|
[self mouseButton:event down:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) rightMouseUp:(NSEvent*)event {
|
||||||
|
[self mouseButton:event down:NO];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) rightMouseDragged:(NSEvent*)event {
|
||||||
|
[self mouseMove:event];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) otherMouseDown:(NSEvent*)event {
|
||||||
|
[self mouseButton:event down:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) otherMouseUp:(NSEvent*)event {
|
||||||
|
[self mouseButton:event down:NO];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) otherMouseDragged:(NSEvent*)event {
|
||||||
|
[self mouseMove:event];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
namespace hiro {
|
namespace hiro {
|
||||||
@@ -27,6 +128,8 @@ auto pLabel::construct() -> void {
|
|||||||
pWidget::construct();
|
pWidget::construct();
|
||||||
|
|
||||||
setAlignment(state().alignment);
|
setAlignment(state().alignment);
|
||||||
|
setBackgroundColor(state().backgroundColor());
|
||||||
|
setForegroundColor(state().foregroundColor());
|
||||||
setText(state().text);
|
setText(state().text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,43 +147,25 @@ auto pLabel::minimumSize() const -> Size {
|
|||||||
|
|
||||||
auto pLabel::setAlignment(Alignment alignment) -> void {
|
auto pLabel::setAlignment(Alignment alignment) -> void {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
NSMutableParagraphStyle* paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
[cocoaView setNeedsDisplay:YES];
|
||||||
paragraphStyle.alignment = NSTextAlignmentCenter;
|
|
||||||
if(alignment.horizontal() < 0.333) paragraphStyle.alignment = NSTextAlignmentLeft;
|
|
||||||
if(alignment.horizontal() > 0.666) paragraphStyle.alignment = NSTextAlignmentRight;
|
|
||||||
[cocoaView setDefaultParagraphStyle:paragraphStyle];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pLabel::setBackgroundColor(Color color) -> void {
|
auto pLabel::setBackgroundColor(Color color) -> void {
|
||||||
//todo
|
@autoreleasepool {
|
||||||
|
[cocoaView setNeedsDisplay:YES];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pLabel::setForegroundColor(Color color) -> void {
|
auto pLabel::setForegroundColor(Color color) -> void {
|
||||||
//todo
|
@autoreleasepool {
|
||||||
|
[cocoaView setNeedsDisplay:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pLabel::setGeometry(Geometry geometry) -> void {
|
|
||||||
//NSTextView does not support vertical text centering:
|
|
||||||
//simulate this by adjusting the geometry placement (reduce height, move view down)
|
|
||||||
uint height = pFont::size(self().font(true), state().text).height();
|
|
||||||
auto offset = geometry;
|
|
||||||
|
|
||||||
if(geometry.height() > height) {
|
|
||||||
uint diff = geometry.height() - height;
|
|
||||||
offset.setY(offset.y() + (diff >> 1));
|
|
||||||
offset.setHeight(offset.height() - (diff >> 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
pWidget::setGeometry({
|
|
||||||
offset.x() - 6, offset.y(),
|
|
||||||
offset.width() + 12, offset.height()
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pLabel::setText(const string& text) -> void {
|
auto pLabel::setText(const string& text) -> void {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[cocoaView setString:[NSString stringWithUTF8String:text]];
|
[cocoaView setNeedsDisplay:YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,10 +1,25 @@
|
|||||||
#if defined(Hiro_Label)
|
#if defined(Hiro_Label)
|
||||||
|
|
||||||
@interface CocoaLabel : NSTextView {
|
@interface CocoaLabel : NSView {
|
||||||
@public
|
@public
|
||||||
hiro::mLabel* label;
|
hiro::mLabel* label;
|
||||||
}
|
}
|
||||||
-(id) initWith:(hiro::mLabel&)label;
|
-(id) initWith:(hiro::mLabel&)label;
|
||||||
|
-(void) resetCursorRects;
|
||||||
|
-(void) drawRect:(NSRect)dirtyRect;
|
||||||
|
-(void) mouseButton:(NSEvent*)event down:(BOOL)isDown;
|
||||||
|
-(void) mouseEntered:(NSEvent*)event;
|
||||||
|
-(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
|
@end
|
||||||
|
|
||||||
namespace hiro {
|
namespace hiro {
|
||||||
@@ -16,7 +31,6 @@ struct pLabel : pWidget {
|
|||||||
auto setAlignment(Alignment alignment) -> void;
|
auto setAlignment(Alignment alignment) -> void;
|
||||||
auto setBackgroundColor(Color color) -> void;
|
auto setBackgroundColor(Color color) -> void;
|
||||||
auto setForegroundColor(Color color) -> void;
|
auto setForegroundColor(Color color) -> void;
|
||||||
auto setGeometry(Geometry geometry) -> void override;
|
|
||||||
auto setText(const string& text) -> void;
|
auto setText(const string& text) -> void;
|
||||||
|
|
||||||
CocoaLabel* cocoaLabel = nullptr;
|
CocoaLabel* cocoaLabel = nullptr;
|
||||||
|
@@ -365,7 +365,6 @@ auto pTableView::setForegroundColor(Color color) -> void {
|
|||||||
|
|
||||||
auto pTableView::setHeadered(bool headered) -> void {
|
auto pTableView::setHeadered(bool headered) -> void {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
if(headered == state().headered) return;
|
|
||||||
if(headered) {
|
if(headered) {
|
||||||
[[cocoaView content] setHeaderView:[[[NSTableHeaderView alloc] init] autorelease]];
|
[[cocoaView content] setHeaderView:[[[NSTableHeaderView alloc] init] autorelease]];
|
||||||
} else {
|
} else {
|
||||||
|
@@ -9,6 +9,12 @@
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void) resetCursorRects {
|
||||||
|
if(auto mouseCursor = NSMakeCursor(label->mouseCursor())) {
|
||||||
|
[self addCursorRect:self.bounds cursor:mouseCursor];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
-(void) drawRect:(NSRect)rect {
|
-(void) drawRect:(NSRect)rect {
|
||||||
[[NSColor blackColor] setFill];
|
[[NSColor blackColor] setFill];
|
||||||
NSRectFillUsingOperation(rect, NSCompositeSourceOver);
|
NSRectFillUsingOperation(rect, NSCompositeSourceOver);
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
hiro::mViewport* viewport;
|
hiro::mViewport* viewport;
|
||||||
}
|
}
|
||||||
-(id) initWith:(hiro::mViewport&)viewport;
|
-(id) initWith:(hiro::mViewport&)viewport;
|
||||||
|
-(void) resetCursorRects;
|
||||||
-(void) drawRect:(NSRect)rect;
|
-(void) drawRect:(NSRect)rect;
|
||||||
-(BOOL) acceptsFirstResponder;
|
-(BOOL) acceptsFirstResponder;
|
||||||
-(NSDragOperation) draggingEntered:(id<NSDraggingInfo>)sender;
|
-(NSDragOperation) draggingEntered:(id<NSDraggingInfo>)sender;
|
||||||
|
@@ -137,7 +137,11 @@ auto AboutDialog::show() -> void {
|
|||||||
websiteValue.setAlignment(0.0);
|
websiteValue.setAlignment(0.0);
|
||||||
websiteValue.setFont(Font().setBold());
|
websiteValue.setFont(Font().setBold());
|
||||||
websiteValue.setForegroundColor({0, 0, 240});
|
websiteValue.setForegroundColor({0, 0, 240});
|
||||||
websiteValue.setText(string{state.website}.trimLeft("http://", 1L).trimLeft("https://", 1L));
|
auto website = state.website;
|
||||||
|
if(0); //remove protocol prefix from displayed label:
|
||||||
|
else if(website.beginsWith("http://" )) website.trimLeft("http://" , 1L);
|
||||||
|
else if(website.beginsWith("https://")) website.trimLeft("https://", 1L);
|
||||||
|
websiteValue.setText(website);
|
||||||
//so that the hand cursor is only visible when overing over the link.
|
//so that the hand cursor is only visible when overing over the link.
|
||||||
websiteValue.setMouseCursor(MouseCursor::Hand);
|
websiteValue.setMouseCursor(MouseCursor::Hand);
|
||||||
websiteValue.onMouseRelease([&](auto button) {
|
websiteValue.onMouseRelease([&](auto button) {
|
||||||
@@ -153,6 +157,7 @@ auto AboutDialog::show() -> void {
|
|||||||
window.setDismissable();
|
window.setDismissable();
|
||||||
window.setVisible();
|
window.setVisible();
|
||||||
window.setModal();
|
window.setModal();
|
||||||
|
window.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user