From 4fc09438d22b02ea23d70ff96661e24151165ef6 Mon Sep 17 00:00:00 2001 From: jcm <6864788+jcm93@users.noreply.github.com> Date: Tue, 11 Feb 2025 14:35:46 -0600 Subject: [PATCH] misc: Address macOS deprecation warnings --- hiro/cocoa/action/menu-check-item.cpp | 4 ++-- hiro/cocoa/action/menu-radio-item.cpp | 2 +- hiro/cocoa/utility.cpp | 2 +- hiro/cocoa/widget/button.cpp | 2 +- hiro/cocoa/widget/check-button.cpp | 8 ++++---- hiro/cocoa/widget/check-label.cpp | 6 +++--- hiro/cocoa/widget/horizontal-scroll-bar.cpp | 2 -- hiro/cocoa/widget/radio-button.cpp | 6 +++--- hiro/cocoa/widget/radio-label.cpp | 4 ++-- hiro/cocoa/widget/table-view.cpp | 4 ++-- hiro/cocoa/widget/vertical-scroll-bar.cpp | 2 -- ruby/audio/audio.cpp | 9 +++++++++ ruby/video/video.cpp | 9 +++++++++ 13 files changed, 37 insertions(+), 23 deletions(-) diff --git a/hiro/cocoa/action/menu-check-item.cpp b/hiro/cocoa/action/menu-check-item.cpp index eef49bb866..ff6139558d 100644 --- a/hiro/cocoa/action/menu-check-item.cpp +++ b/hiro/cocoa/action/menu-check-item.cpp @@ -13,7 +13,7 @@ -(void) activate { menuCheckItem->state.checked = !menuCheckItem->state.checked; - auto state = menuCheckItem->state.checked ? NSOnState : NSOffState; + auto state = menuCheckItem->state.checked ? NSControlStateValueOn : NSControlStateValueOff; [self setState:state]; menuCheckItem->doToggle(); } @@ -34,7 +34,7 @@ auto pMenuCheckItem::destruct() -> void { } auto pMenuCheckItem::setChecked(bool checked) -> void { - auto state = checked ? NSOnState : NSOffState; + auto state = checked ? NSControlStateValueOn : NSControlStateValueOff; [cocoaAction setState:state]; } diff --git a/hiro/cocoa/action/menu-radio-item.cpp b/hiro/cocoa/action/menu-radio-item.cpp index a6281c9094..0e3dc91ff5 100644 --- a/hiro/cocoa/action/menu-radio-item.cpp +++ b/hiro/cocoa/action/menu-radio-item.cpp @@ -40,7 +40,7 @@ auto pMenuRadioItem::setChecked() -> void { if(auto object = weak.acquire()) { if(auto self = object->self()) { if(auto p = dynamic_cast(self)) { - auto state = this == p ? NSOnState : NSOffState; + auto state = this == p ? NSControlStateValueOn : NSControlStateValueOff; [p->cocoaAction setState:state]; } } diff --git a/hiro/cocoa/utility.cpp b/hiro/cocoa/utility.cpp index 9132143976..049a32439d 100644 --- a/hiro/cocoa/utility.cpp +++ b/hiro/cocoa/utility.cpp @@ -41,7 +41,7 @@ auto NSMakeImage(image icon, u32 scaleWidth = 0, u32 scaleHeight = 0) -> NSImage pixelsWide:icon.width() pixelsHigh:icon.height() bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO colorSpaceName:NSDeviceRGBColorSpace - bitmapFormat:NSAlphaNonpremultipliedBitmapFormat + bitmapFormat:NSBitmapFormatAlphaNonpremultiplied bytesPerRow:(4 * icon.width()) bitsPerPixel:32 ]; memory::copy([bitmap bitmapData], icon.data(), icon.width() * icon.height()); diff --git a/hiro/cocoa/widget/button.cpp b/hiro/cocoa/widget/button.cpp index e375f58f20..0bf86e902e 100644 --- a/hiro/cocoa/widget/button.cpp +++ b/hiro/cocoa/widget/button.cpp @@ -8,7 +8,7 @@ [self setTarget:self]; [self setAction:@selector(activate:)]; //NSRoundedBezelStyle has a fixed height; which breaks both icons and larger/smaller text - [self setBezelStyle:NSRegularSquareBezelStyle]; + [self setBezelStyle:NSBezelStyleFlexiblePush]; } return self; } diff --git a/hiro/cocoa/widget/check-button.cpp b/hiro/cocoa/widget/check-button.cpp index c48abe3122..d04581d145 100644 --- a/hiro/cocoa/widget/check-button.cpp +++ b/hiro/cocoa/widget/check-button.cpp @@ -8,14 +8,14 @@ [self setTarget:self]; [self setAction:@selector(activate:)]; - [self setBezelStyle:NSRegularSquareBezelStyle]; - [self setButtonType:NSOnOffButton]; + [self setBezelStyle:NSBezelStyleFlexiblePush]; + [self setButtonType:NSButtonTypeOnOff]; } return self; } -(IBAction) activate:(id)sender { - checkButton->state.checked = [self state] != NSOffState; + checkButton->state.checked = [self state] != NSControlStateValueOff; checkButton->doToggle(); } @@ -58,7 +58,7 @@ auto pCheckButton::setBordered(bool bordered) -> void { } auto pCheckButton::setChecked(bool checked) -> void { - [(CocoaCheckButton*)cocoaView setState:checked ? NSOnState : NSOffState]; + [(CocoaCheckButton*)cocoaView setState:checked ? NSControlStateValueOn : NSControlStateValueOff]; } auto pCheckButton::setGeometry(Geometry geometry) -> void { diff --git a/hiro/cocoa/widget/check-label.cpp b/hiro/cocoa/widget/check-label.cpp index d990774a7c..363ff8d5b0 100644 --- a/hiro/cocoa/widget/check-label.cpp +++ b/hiro/cocoa/widget/check-label.cpp @@ -8,13 +8,13 @@ [self setTarget:self]; [self setAction:@selector(activate:)]; - [self setButtonType:NSSwitchButton]; + [self setButtonType:NSButtonTypeSwitch]; } return self; } -(IBAction) activate:(id)sender { - checkLabel->state.checked = [self state] != NSOffState; + checkLabel->state.checked = [self state] != NSControlStateValueOff; checkLabel->doToggle(); } @@ -40,7 +40,7 @@ auto pCheckLabel::minimumSize() const -> Size { } auto pCheckLabel::setChecked(bool checked) -> void { - [(CocoaCheckLabel*)cocoaView setState:checked ? NSOnState : NSOffState]; + [(CocoaCheckLabel*)cocoaView setState:checked ? NSControlStateValueOn : NSControlStateValueOff]; } auto pCheckLabel::setGeometry(Geometry geometry) -> void { diff --git a/hiro/cocoa/widget/horizontal-scroll-bar.cpp b/hiro/cocoa/widget/horizontal-scroll-bar.cpp index 28719a4dcd..56ade2a413 100644 --- a/hiro/cocoa/widget/horizontal-scroll-bar.cpp +++ b/hiro/cocoa/widget/horizontal-scroll-bar.cpp @@ -30,13 +30,11 @@ 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]; diff --git a/hiro/cocoa/widget/radio-button.cpp b/hiro/cocoa/widget/radio-button.cpp index 22c5df7e36..7ecfce0a5f 100644 --- a/hiro/cocoa/widget/radio-button.cpp +++ b/hiro/cocoa/widget/radio-button.cpp @@ -8,8 +8,8 @@ [self setTarget:self]; [self setAction:@selector(activate:)]; - [self setBezelStyle:NSRegularSquareBezelStyle]; - [self setButtonType:NSOnOffButton]; + [self setBezelStyle:NSBezelStyleFlexiblePush]; + [self setButtonType:NSButtonTypeOnOff]; } return self; } @@ -64,7 +64,7 @@ auto pRadioButton::setChecked() -> void { if(auto object = weak.acquire()) { if(auto self = object->self()) { if(auto p = dynamic_cast(self)) { - auto state = this == p ? NSOnState : NSOffState; + auto state = this == p ? NSControlStateValueOn : NSControlStateValueOff; [(CocoaRadioButton*)p->cocoaView setState:state]; } } diff --git a/hiro/cocoa/widget/radio-label.cpp b/hiro/cocoa/widget/radio-label.cpp index 5d52a6c333..bd91a1cdb7 100644 --- a/hiro/cocoa/widget/radio-label.cpp +++ b/hiro/cocoa/widget/radio-label.cpp @@ -8,7 +8,7 @@ [self setTarget:self]; [self setAction:@selector(activate:)]; - [self setButtonType:NSRadioButton]; + [self setButtonType:NSButtonTypeRadio]; } return self; } @@ -60,7 +60,7 @@ auto pRadioLabel::setGroup(sGroup group) -> void { if(auto object = weak.acquire()) { if(auto self = object->self()) { if(auto p = dynamic_cast(self)) { - auto state = p->state().checked ? NSOnState : NSOffState; + auto state = p->state().checked ? NSControlStateValueOn : NSControlStateValueOff; [(CocoaRadioLabel*)p->cocoaView setState:state]; } } diff --git a/hiro/cocoa/widget/table-view.cpp b/hiro/cocoa/widget/table-view.cpp index fe95c8670f..74bf4ee6bb 100644 --- a/hiro/cocoa/widget/table-view.cpp +++ b/hiro/cocoa/widget/table-view.cpp @@ -202,7 +202,7 @@ if(self = [super initTextCell:@""]) { tableView = &tableViewReference; buttonCell = [[NSButtonCell alloc] initTextCell:@""]; - [buttonCell setButtonType:NSSwitchButton]; + [buttonCell setButtonType:NSButtonTypeSwitch]; [buttonCell setControlSize:NSControlSizeSmall]; [buttonCell setRefusesFirstResponder:YES]; [buttonCell setTarget:self]; @@ -222,7 +222,7 @@ if(auto tableViewCell = tableViewItem->cell([view columnAtPoint:frame.origin])) { if(tableViewCell->state.checkable) { [buttonCell setHighlighted:YES]; - [buttonCell setState:(tableViewCell->state.checked ? NSOnState : NSOffState)]; + [buttonCell setState:(tableViewCell->state.checked ? NSControlStateValueOn : NSControlStateValueOff)]; [buttonCell drawWithFrame:frame inView:view]; frame.origin.x += frame.size.height + 2; frame.size.width -= frame.size.height + 2; diff --git a/hiro/cocoa/widget/vertical-scroll-bar.cpp b/hiro/cocoa/widget/vertical-scroll-bar.cpp index 4776830c0c..f0a5367a2b 100644 --- a/hiro/cocoa/widget/vertical-scroll-bar.cpp +++ b/hiro/cocoa/widget/vertical-scroll-bar.cpp @@ -30,13 +30,11 @@ auto& state = verticalScrollBar->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]; diff --git a/ruby/audio/audio.cpp b/ruby/audio/audio.cpp index 019912e9cf..90b66da6ef 100644 --- a/ruby/audio/audio.cpp +++ b/ruby/audio/audio.cpp @@ -15,7 +15,16 @@ #endif #if defined(AUDIO_OPENAL) + #if defined(__APPLE__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #endif + #include + + #if defined(__APPLE__) + #pragma clang diagnostic pop + #endif #endif #if defined(AUDIO_OSS) diff --git a/ruby/video/video.cpp b/ruby/video/video.cpp index 6d6e11081b..f1b9bbe957 100644 --- a/ruby/video/video.cpp +++ b/ruby/video/video.cpp @@ -1,5 +1,14 @@ #if defined(VIDEO_CGL) + #if defined(__APPLE__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #endif + #include + + #if defined(__APPLE__) + #pragma clang diagnostic pop + #endif #endif #if defined(VIDEO_DIRECT3D9)