Skip to content

Commit

Permalink
misc: Address macOS deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jcm93 committed Feb 11, 2025
1 parent 192039b commit 315d84d
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 23 deletions.
4 changes: 2 additions & 2 deletions hiro/cocoa/action/menu-check-item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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];
}

Expand Down
2 changes: 1 addition & 1 deletion hiro/cocoa/action/menu-radio-item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ auto pMenuRadioItem::setChecked() -> void {
if(auto object = weak.acquire()) {
if(auto self = object->self()) {
if(auto p = dynamic_cast<pMenuRadioItem*>(self)) {
auto state = this == p ? NSOnState : NSOffState;
auto state = this == p ? NSControlStateValueOn : NSControlStateValueOff;
[p->cocoaAction setState:state];
}
}
Expand Down
2 changes: 1 addition & 1 deletion hiro/cocoa/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32>([bitmap bitmapData], icon.data(), icon.width() * icon.height());
Expand Down
2 changes: 1 addition & 1 deletion hiro/cocoa/widget/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions hiro/cocoa/widget/check-button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions hiro/cocoa/widget/check-label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions hiro/cocoa/widget/horizontal-scroll-bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
6 changes: 3 additions & 3 deletions hiro/cocoa/widget/radio-button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -64,7 +64,7 @@ auto pRadioButton::setChecked() -> void {
if(auto object = weak.acquire()) {
if(auto self = object->self()) {
if(auto p = dynamic_cast<pRadioButton*>(self)) {
auto state = this == p ? NSOnState : NSOffState;
auto state = this == p ? NSControlStateValueOn : NSControlStateValueOff;
[(CocoaRadioButton*)p->cocoaView setState:state];
}
}
Expand Down
4 changes: 2 additions & 2 deletions hiro/cocoa/widget/radio-label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

[self setTarget:self];
[self setAction:@selector(activate:)];
[self setButtonType:NSRadioButton];
[self setButtonType:NSButtonTypeRadio];
}
return self;
}
Expand Down Expand Up @@ -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<pRadioLabel*>(self)) {
auto state = p->state().checked ? NSOnState : NSOffState;
auto state = p->state().checked ? NSControlStateValueOn : NSControlStateValueOff;
[(CocoaRadioLabel*)p->cocoaView setState:state];
}
}
Expand Down
4 changes: 2 additions & 2 deletions hiro/cocoa/widget/table-view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions hiro/cocoa/widget/vertical-scroll-bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
9 changes: 9 additions & 0 deletions ruby/audio/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,16 @@
#endif

#if defined(AUDIO_OPENAL)
#if defined(__APPLE__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif

#include <ruby/audio/openal.cpp>

#if defined(__APPLE__)
#pragma clang diagnostic pop
#endif
#endif

#if defined(AUDIO_OSS)
Expand Down
9 changes: 9 additions & 0 deletions ruby/video/video.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#if defined(VIDEO_CGL)
#if defined(__APPLE__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif

#include <ruby/video/cgl.cpp>

#if defined(__APPLE__)
#pragma clang diagnostic pop
#endif
#endif

#if defined(VIDEO_DIRECT3D9)
Expand Down

0 comments on commit 315d84d

Please sign in to comment.