Cocoa/Config: turn config to the new style , Merge branch 'cocoa/config'

This commit is contained in:
rich2014 2024-08-22 00:37:58 +08:00
commit 34b10a9c25
12 changed files with 313 additions and 244 deletions

View File

@ -0,0 +1,120 @@
var
CocoaConfigGlobal: TCocoaConfigGlobal = (
// for compatiblity with LCL 1.8 release. The macOS base is 72ppi
basePPI: 96;
// if set to true, then WS would not assign icons via TCocoaWSForm SetIcon
// The icon would have to be changed manually. By default LCL behaviour is used
useIcon: False;
// some localized named might be too long to be returned properly by APIs
useLocalizedFontName: False;
);
var
CocoaConfigListView: TCocoaConfigListView = (
vsReport: (
tableViewStyle: NSTableViewStyleAutomatic;
row: ( defaultHeight: 16; imageLineSpacing: 4*2 );
column: ( controlSpacing: 4; textFieldMinWidth: 16 );
columnAutoFit: ( maxCalcRows: 100; minWidth: 20; headerAdditionalWidth: 4 );
);
vsIcon: (
interitemSpacing: 4;
lineSpacing: 4;
item: (
minSize: ( width:64; height:68 );
controlSpacing: 2;
textFieldAlignment: {$ifdef USE_IOS_VALUES}1{$else}2{$endif}; // NSTextAlignmentCenter
checkBoxOccupiedWidth: 24
);
imageView: ( minSize: ( width: 32; height: 32 ); padding: 10; );
textField: ( defaultHeight: 15 );
);
vsSmallIcon: (
interitemSpacing: 10;
lineSpacing: 0;
item: (
minSize: ( width:150; height:28 );
controlSpacing: 2;
textFieldAlignment: 0; // NSTextAlignmentLeft
checkBoxOccupiedWidth: 24
);
imageView: ( minSize: ( width: 16; height: 16 ); padding: 4; );
textField: ( iconWidthFactor: 3; baseWidth: 0; minWidth: 128 );
);
vsList: (
interitemSpacing: 0;
lineSpacing: 10;
item: (
minSize: ( width:146; height:24 );
controlSpacing: 4;
textFieldAlignment: 0; // NSTextAlignmentLeft
checkBoxOccupiedWidth: 24
);
);
);
var
CocoaConfigScroller: TCocoaConfigScroller = (
// the style of the TCocoaScrollBar managed by TCocoaManualScrollView,
// the default value is System Preferred.
// note: TCocoaScrollBar not managed by TCocoaManualScrollView is always
// Legacy Style.
preferredStyle: -1;
// fade in/out time interval, in Seconds
fadeTimeInterval: 0.02;
legacy: (
knob: (
radius: 4; // Knob Radius, in Dots
color: @getCocoaScrollerDefaultKnobColor;
pos: 3; // Knob Position, in Dots
shrunkSize: 5; // Knob Shrunk Size, in Dots
alpha: 0.25; // Knob Alpha in Normal
alphaBlack: 0.5; // Knob Alpha when mouse enters
fadeStep: 0.05; // Knob Alpha Step when fading in/out
);
);
overlay: (
bar: (
// Overly Style Scroller Auto Show Delay Time, in Seconds
// used when the Scroller is triggered by double-finger tapping the touchpad
autoShowDelayTime: 0.2;
autoHideDelayTime: 0.9; // Bar Auto Hide Delay Time, in Seconds
alpha: 0.5; // Bar Alpha in Normal
alphaFadeStep: -0.1; // Bar Alpha Step when fading out
alphaFadeTo: 0; // Bar Alpha when fade out ends
expandTimeInterval: 0.03; // Bar Expands time interval, in Seconds
expandSize: 4; // Bar Expands when the mouse enters, in Dots
);
knob: (
radius: 4; // Knob Radius, in Dots
color: @getCocoaScrollerDefaultKnobColor;
pos: 5; // Knob Position, in Dots
shrunkSize: 6; // Knob Shrunk Size, in Dots
// in extreme cases, the normally calculated Knob size of Overlay Scroller
// may be too small, keep the min size.
// min height for the Knob of VerticalScroller
// min width for the Knob of HorizontalScroller
minSize: 25;
);
);
);
var
CocoaConfigToggleBox: TCocoaConfigToggleBox = (
bezelStyle: NSRoundedBezelStyle;
buttonType: NSPushOnPushOffButton;
);
var
CocoaConfigNotification: TCocoaConfigNotification = (
// by default on macOS, Notification is only Presented when the APP is
// in the background.
// when CocoaAlwaysPresentNotification is set to True, Notification is
// always Presented.
alwaysPresent: True;
);

View File

@ -9,6 +9,13 @@ interface
uses
CocoaAll, Cocoa_Extra, CocoaConst;
type
TCocoaConfigGlobal = record
basePPI: Integer;
useIcon: Boolean;
useLocalizedFontName: Boolean;
end;
type
TCocoaConfigSize = record
width: Double;
@ -90,51 +97,74 @@ type
vsList: TCocoaConfigCollection;
end;
var
CocoaConfigListView: TCocoaConfigListView = (
vsReport: (
tableViewStyle: NSTableViewStyleAutomatic;
row: ( defaultHeight: 16; imageLineSpacing: 4*2 );
column: ( controlSpacing: 4; textFieldMinWidth: 16 );
columnAutoFit: ( maxCalcRows: 100; minWidth: 20; headerAdditionalWidth: 4 );
);
vsIcon: (
interitemSpacing: 4;
lineSpacing: 4;
item: (
minSize: ( width:64; height:68 );
controlSpacing: 2;
textFieldAlignment: {$ifdef USE_IOS_VALUES}1{$else}2{$endif}; // NSTextAlignmentCenter
checkBoxOccupiedWidth: 24
);
imageView: ( minSize: ( width: 32; height: 32 ); padding: 10; );
textField: ( defaultHeight: 15 );
);
vsSmallIcon: (
interitemSpacing: 10;
lineSpacing: 0;
item: (
minSize: ( width:150; height:28 );
controlSpacing: 2;
textFieldAlignment: 0; // NSTextAlignmentLeft
checkBoxOccupiedWidth: 24
);
imageView: ( minSize: ( width: 16; height: 16 ); padding: 4; );
textField: ( iconWidthFactor: 3; baseWidth: 0; minWidth: 128 );
);
vsList: (
interitemSpacing: 0;
lineSpacing: 10;
item: (
minSize: ( width:146; height:24 );
controlSpacing: 4;
textFieldAlignment: 0; // NSTextAlignmentLeft
checkBoxOccupiedWidth: 24
);
);
);
type
NSColorFunction = Function(): NSColor;
function getCocoaScrollerDefaultKnobColor: NSColor;
type
TCocoaConfgiScrollerKnob = object
radius: Double;
color: NSColorFunction;
pos: Double;
shrunkSize: Double;
end;
TCocoaConfgiScrollerLegacyKnob = object( TCocoaConfgiScrollerKnob )
alpha: Double;
alphaBlack: Double;
fadeStep: Double;
end;
TCocoaConfgiScrollerOverlayKnob = object( TCocoaConfgiScrollerKnob )
minSize: Double;
end;
TCocoaConfigScrollerLegacy = record
knob: TCocoaConfgiScrollerLegacyKnob;
end;
TCocoaConfigScrollerOverlayBar = record
autoShowDelayTime: Double;
autoHideDelayTime: Double;
alpha: Double;
alphaFadeStep: Double;
alphaFadeTo: Double;
expandTimeInterval: Double;
expandSize: Double;
end;
TCocoaConfigScrollerOverlay = record
bar: TCocoaConfigScrollerOverlayBar;
knob: TCocoaConfgiScrollerOverlayKnob;
end;
TCocoaConfigScroller = record
preferredStyle: NSScrollerStyle;
fadeTimeInterval: Double;
legacy: TCocoaConfigScrollerLegacy;
overlay: TCocoaConfigScrollerOverlay;
end;
type
TCocoaConfigToggleBox = record
bezelStyle: NSBezelStyle;
buttonType: NSButtonType;
end;
type
TCocoaConfigMenu = record
defaultCheckImageName: NSString;
defaultRadioImageName: NSString;
end;
type
TCocoaConfigNotification = record
alwaysPresent: Boolean;
end;
type
{ TCocoaConfigFocusRing }
// on macOS, the FocusRing takes up extra space, which may cause strange
// display in some cases. it may block other controls, or be partially cut off.
@ -142,171 +172,72 @@ type
// Tab of TPageControl is partially cut off.
// by providing a configurable infrastructure, FocusRing can be controlled
// for different control types.
{$scopedEnums on}
TCocoaFocusRingStrategy = (
default, // by macOS Default
none, // no FoucsRing
required, // have FocusRing
border // by LCL Control Border
);
TCocoaConfigFocusRing = class
{$scopedEnums on}
type Strategy = (
default, // by macOS Default
none, // no FoucsRing
required, // have FocusRing
border // by LCL Control Border
);
private
_strategies: NSMutableDictionary;
public
constructor Create;
destructor Destroy; override;
// set the FocusRing strategy of the control according to ClassName
// (eg. 'TCocoaTabControl')
// APP can change the default setting of Cocoa WidgetSet
// by calling setCocoaControlFocusRingStrategy() too.
procedure setCocoaControlFocusRingStrategry( frs: TCocoaFocusRingStrategy; AClassName: NSString );
// set the FocusRing strategy of the control according to ClassName
// (eg. 'TCocoaTabControl')
// APP can change the default setting of Cocoa WidgetSet
// by calling setStrategy() too.
procedure setStrategy( frs: Strategy; AClassName: NSString );
// getCocoaControlFocusRingStrategy() is mainly used internally by Cocoa WidgetSet
function getCocoaControlFocusRingStrategry( AClassName: NSString ): TCocoaFocusRingStrategy;
// getStrategy() is mainly used internally by Cocoa WidgetSet
function getStrategy( AClassName: NSString ): Strategy;
end;
type
NSColorFunction = Function(): NSColor;
function getCocoaScrollerDefaultKnobColor: NSColor;
// config data is stored in CocoaConfig.inc
{$include cocoaconfig.inc}
var
// the style of the TCocoaScrollBar managed by TCocoaManualScrollView,
// the default value is System Preferred.
// note: TCocoaScrollBar not managed by TCocoaManualScrollView is always
// Legacy Style.
CocoaScrollerPreferredStyle : NSScrollerStyle = -1;
CocoaConfigMenu: TCocoaConfigMenu = (
{%H-});
// Scroller Knob Fade in/out time interval, in Seconds
CocoaScrollerKnobFadeTimeInterval : Double = 0.02;
// Scroller Knob Radius, in Dots
CocoaScrollerKnobRadius : Double = 4;
// Legacy Style Scroller Knob Color
CocoaScrollerOverlayStyleKnobColor : NSColorFunction = @getCocoaScrollerDefaultKnobColor;
// Legacy Style Scroller Knob Alpha in Normal
CocoaScrollerLegacyStyleAlpha : Double = 0.25;
// Legacy Style Scroller Knob Alpha when mouse enters
CocoaScrollerLegacyStyleAlphaBlack : Double = 0.50;
// Legacy Style Scroller Knob Alpha Step when fading in/out
CocoaScrollerLegacyStyleFadeStep : Double = 0.05;
// Legacy Style Scroller Knob Position, in Dots
CocoaScrollerLegacyStyleKnobPos : Double = 3;
// Legacy Style Scroller Knob Shrunk Size, in Dots
CocoaScrollerLegacyStyleKnobShrunkSize : Double = 5;
// Overly Style Scroller Knob Color
CocoaScrollerLegacyStyleKnobColor : NSColorFunction = @getCocoaScrollerDefaultKnobColor;
// Overly Style Scroller Auto Show Delay Time, in Seconds
// the scrollbar is not shown because the value is updated,
// but because it is triggered by other factors, such as
// double-finger tapping the touchpad
CocoaScrollerOverlayStyleAutoShowDelayTime : Double = 0.2;
// Overly Style Scroller Auto Hide Delay Time, in Seconds
CocoaScrollerOverlayStyleAutoHideDelayTime : Double = 0.9;
// Overlay Style Scroller Alpha in Normal
CocoaScrollerOverlayStyleAlpha : Double = 0.5;
// Overlay Style Scroller Alpha Step when fading out
CocoaScrollerOverlayStyleFadeStep : Double = -0.1;
// Overlay Style Scroller Alpha when fade out ends
CocoaScrollerOverlayStyleFadeTo : Double = 0;
// Overlay Style Scroller expands time interval, in Seconds
CocoaScrollerOverlayStyleExpandTimeInterval : Double = 0.03;
// Overlay Style Scroller expands when the mouse enters, in Dots
CocoaScrollerOverlayStyleExpandSize : Double = 4;
// Overlay Style Scroller Knob Position, in Dots
CocoaScrollerOverlayStyleKnobPos : Double = 5;
// Overlay Style Scroller Knob Shrunk Size, in Dots
CocoaScrollerOverlayStyleKnobShrunkSize : Double = 6;
// in extreme cases, the normally calculated Knob size of Overlay Scroller
// may be too small, keep the min size.
// min height for the Knob of VerticalScroller
// min width for the Knob of HorizontalScroller
CocoaScrollerOverlayStyleKnobMinSize : Double = 25;
// by default on macOS, Notification is only Presented when the APP is
// in the background.
// when CocoaAlwaysPresentNotification is set to True, Notification is
// always Presented.
CocoaAlwaysPresentNotification : Boolean = True;
// for compatiblity with LCL 1.8 release. The macOS base is 72ppi
CocoaBasePPI : Integer = 96;
// if set to true, then WS would not assign icons via TCocoaWSForm SetIcon
// The icon would have to be changed manually. By default LCL behaviour is used
CocoaIconUse: Boolean = false;
CocoaToggleBezel : NSBezelStyle = NSRoundedBezelStyle;
CocoaToggleType : NSButtonType = NSPushOnPushOffButton;
CocoaHideFocusNoBorder : Boolean = true;
// some localized named might be too long to be returned properly by APIs
CocoaUseLocalizedFontName : Boolean = false;
// default Image Name for MenuItem
CocoaDefaultCheckMenuImageName : NSString;
CocoaDefaultRadioMenuImageName : NSString;
{$ifdef COCOALOOPHIJACK}
// The flag is set to true once hi-jacked loop is finished (at the end of app)
// The flag is checked in Menus to avoid "double" Cmd+Q menu
LoopHiJackEnded : Boolean = false;
{$endif}
CocoaConfigFocusRing: TCocoaConfigFocusRing;
implementation
var
FocusRingStrategySetting: NSMutableDictionary;
constructor TCocoaConfigFocusRing.Create;
begin
_strategies:= NSMutableDictionary.alloc.initWithCapacity( 16 );
// FocusRing config data is stored in CocoaConfigFocusRing.inc
{$include cocoaconfigfocusring.inc}
end;
procedure setCocoaControlFocusRingStrategry( frs: TCocoaFocusRingStrategy; AClassName: NSString );
destructor TCocoaConfigFocusRing.Destroy;
begin
inherited Destroy;
_strategies.release;
end;
procedure TCocoaConfigFocusRing.setStrategy(
frs: Strategy; AClassName: NSString);
var
valueObject: NSNumber;
begin
valueObject:= NSNumber.numberWithInt( Ord(frs) );
FocusRingStrategySetting.setValue_forKey( valueObject , AClassName );
_strategies.setValue_forKey( valueObject , AClassName );
end;
function getCocoaControlFocusRingStrategry( AClassName: NSString ): TCocoaFocusRingStrategy;
function TCocoaConfigFocusRing.getStrategy(
AClassName: NSString): Strategy;
var
valueObject: NSNumber;
begin
Result:= TCocoaFocusRingStrategy.default;
valueObject:= NSNumber( FocusRingStrategySetting.valueForKey(AClassName) );
Result:= TCocoaConfigFocusRing.Strategy.default;
valueObject:= NSNumber( _strategies.valueForKey(AClassName) );
if Assigned(valueObject) then
Result:= TCocoaFocusRingStrategy(valueObject.intValue);
if Result = TCocoaFocusRingStrategy.required then
Writeln( 'required' );
end;
// no need to set TCocoaFocusRingStrategy.default control
// the controls not in FocusRingStrategySetting are TCocoaFocusRingStrategy.default
procedure initDefaultFoucsRingSetting;
begin
FocusRingStrategySetting:= NSMutableDictionary.alloc.initWithCapacity( 16 );
setCocoaControlFocusRingStrategry( TCocoaFocusRingStrategy.none, NSSTR('TCocoaTabControl') );
setCocoaControlFocusRingStrategry( TCocoaFocusRingStrategy.none, NSSTR('TCocoaButton') );
setCocoaControlFocusRingStrategry( TCocoaFocusRingStrategy.none, NSSTR('TCocoaTextField') );
setCocoaControlFocusRingStrategry( TCocoaFocusRingStrategy.none, NSSTR('TCocoaComboBox') );
setCocoaControlFocusRingStrategry( TCocoaFocusRingStrategy.none, NSSTR('TCocoaReadOnlyComboBox') );
setCocoaControlFocusRingStrategry( TCocoaFocusRingStrategy.none, NSSTR('TCocoaTableListView') );
setCocoaControlFocusRingStrategry( TCocoaFocusRingStrategy.none, NSSTR('TCocoaCollectionView') );
setCocoaControlFocusRingStrategry( TCocoaFocusRingStrategy.border, NSSTR('TCocoaTextView') );
Result:= TCocoaConfigFocusRing.Strategy(valueObject.intValue);
end;
function getCocoaScrollerDefaultKnobColor: NSColor;
@ -315,8 +246,8 @@ begin
end;
initialization
CocoaDefaultCheckMenuImageName:= NSSTR('NSMenuCheckmark');
CocoaDefaultRadioMenuImageName:= NSSTR('NSDatePickerCalendarHome');
initDefaultFoucsRingSetting;
CocoaConfigMenu.defaultCheckImageName:= NSSTR('NSMenuCheckmark');
CocoaConfigMenu.defaultRadioImageName:= NSSTR('NSDatePickerCalendarHome');
CocoaConfigFocusRing:= TCocoaConfigFocusRing.Create;
end.

View File

@ -0,0 +1,11 @@
// no need to set TCocoaConfigFocusRing.Strategy.default control
// the controls not in StrategySetting are TCocoaConfigFocusRing.Strategy.default
setStrategy( TCocoaConfigFocusRing.Strategy.none, NSSTR('TCocoaTabControl') );
setStrategy( TCocoaConfigFocusRing.Strategy.none, NSSTR('TCocoaButton') );
setStrategy( TCocoaConfigFocusRing.Strategy.none, NSSTR('TCocoaTextField') );
setStrategy( TCocoaConfigFocusRing.Strategy.none, NSSTR('TCocoaComboBox') );
setStrategy( TCocoaConfigFocusRing.Strategy.none, NSSTR('TCocoaReadOnlyComboBox') );
setStrategy( TCocoaConfigFocusRing.Strategy.none, NSSTR('TCocoaTableListView') );
setStrategy( TCocoaConfigFocusRing.Strategy.none, NSSTR('TCocoaCollectionView') );
setStrategy( TCocoaConfigFocusRing.Strategy.border, NSSTR('TCocoaTextView') );

View File

@ -32,8 +32,8 @@ begin
DebugLn('TCocoaWidgetSet.AppInit');
{$ENDIF}
WakeMainThread := @OnWakeMainThread;
ScreenInfo.PixelsPerInchX := CocoaBasePPI;
ScreenInfo.PixelsPerInchY := CocoaBasePPI;
ScreenInfo.PixelsPerInchX := CocoaConfigGlobal.basePPI;
ScreenInfo.PixelsPerInchY := CocoaConfigGlobal.basePPI;
{ Creates the application NSApp object }
FNSApp := InitApplication;

View File

@ -354,6 +354,12 @@ var
// todo: this should be a threadvar
TrackedControl : NSObject = nil;
{$ifdef COCOALOOPHIJACK}
// The flag is set to true once hi-jacked loop is finished (at the end of app)
// The flag is checked in Menus to avoid "double" Cmd+Q menu
LoopHiJackEnded : Boolean = false;
{$endif}
function isCallbackForSameObject(cb1, cb2: ICommonCallback): Boolean;
function NSViewIsLCLEnabled(v: NSView): Boolean;

View File

@ -612,7 +612,7 @@ var
begin
oldManager:= _manager;
style:= CocoaConfig.CocoaScrollerPreferredStyle;
style:= CocoaConfigScroller.preferredStyle;
if style < 0 then
style:= NSScroller.preferredScrollerStyle;
@ -1460,7 +1460,7 @@ begin
self.stepAlpha:= inc;
self.maxAlpha:= max;
self.alphaTimer:= NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats(
CocoaConfig.CocoaScrollerKnobFadeTimeInterval,
CocoaConfigScroller.fadeTimeInterval,
self,
ObjCSelector('onAlphaTimer:'),
nil,
@ -1486,8 +1486,8 @@ end;
procedure TCocoaScrollBarEffectOverlay.onDelayHidingTimer( timer:NSTimer );
begin
self.delayTimer:= nil;
self.fade( CocoaConfig.CocoaScrollerOverlayStyleFadeStep,
CocoaConfig.CocoaScrollerOverlayStyleFadeTo );
self.fade( CocoaConfigScroller.overlay.bar.alphaFadeStep,
CocoaConfigScroller.overlay.bar.alphaFadeTo );
end;
procedure TCocoaScrollBarEffectOverlay.onExpandTimer(timer: NSTimer);
@ -1499,7 +1499,7 @@ begin
Exit;
end;
if self.expandedSize < CocoaConfig.CocoaScrollerOverlayStyleExpandSize then begin
if self.expandedSize < CocoaConfigScroller.overlay.bar.expandSize then begin
self.expandedSize:= self.expandedSize + 1;
end else begin
done:= True;
@ -1534,14 +1534,14 @@ end;
procedure TCocoaScrollBarEffectOverlay.setDelayShowingTimer;
begin
self.setDelayTimer(
CocoaScrollerOverlayStyleAutoShowDelayTime,
CocoaConfigScroller.overlay.bar.autoShowDelayTime,
ObjCSelector('onDelayShowingTimer:') );
end;
procedure TCocoaScrollBarEffectOverlay.setDelayHidingTimer;
begin
self.setDelayTimer(
CocoaConfig.CocoaScrollerOverlayStyleAutoHideDelayTime,
CocoaConfigScroller.overlay.bar.autoHideDelayTime,
ObjCSelector('onDelayHidingTimer:') );
end;
@ -1553,7 +1553,7 @@ begin
self.expandTimer.invalidate;
self.expandTimer:= NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats(
CocoaConfig.CocoaScrollerOverlayStyleExpandTimeInterval,
CocoaConfigScroller.overlay.bar.expandTimeInterval,
self,
ObjCSelector('onExpandTimer:'),
nil,
@ -1683,7 +1683,7 @@ begin
effect:= TCocoaScrollBarEffectAlpha.alloc.Init;
effect.scroller:= scroller;
effect.manager:= self;
effect.currentAlpha:= CocoaConfig.CocoaScrollerLegacyStyleAlpha;
effect.currentAlpha:= CocoaConfigScroller.legacy.knob.alpha;
Result:= effect;
end;
@ -1745,19 +1745,19 @@ begin
rect:= scrollBar.rectForPart(NSScrollerKnob);
rect:= NSInsetRect(rect, 1, 1);
if scrollBar.IsHorizontal then begin
rect.origin.y:= rect.origin.y + CocoaConfig.CocoaScrollerLegacyStyleKnobPos;
rect.size.height:= rect.size.height - CocoaConfig.CocoaScrollerLegacyStyleKnobShrunkSize;
rect.origin.y:= rect.origin.y + CocoaConfigScroller.legacy.knob.pos;
rect.size.height:= rect.size.height - CocoaConfigScroller.legacy.knob.shrunkSize;
end else begin
rect.origin.x:= rect.origin.x + CocoaConfig.CocoaScrollerLegacyStyleKnobPos;
rect.size.width:= rect.size.width - CocoaConfig.CocoaScrollerLegacyStyleKnobShrunkSize;
rect.origin.x:= rect.origin.x + CocoaConfigScroller.legacy.knob.pos;
rect.size.width:= rect.size.width - CocoaConfigScroller.legacy.knob.shrunkSize;
end;
alpha:= TCocoaScrollBarEffectAlpha(scrollBar.effect).currentAlpha;
path:= NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius(
rect,
CocoaConfig.CocoaScrollerKnobRadius,
CocoaConfig.CocoaScrollerKnobRadius );
color:= CIColor.alloc.initWithColor( CocoaConfig.CocoaScrollerLegacyStyleKnobColor() );
CocoaConfigScroller.legacy.knob.radius,
CocoaConfigScroller.legacy.knob.radius );
color:= CIColor.alloc.initWithColor( CocoaConfigScroller.legacy.knob.color() );
NSColor.colorWithRed_green_blue_alpha(
color.red,
color.green,
@ -1788,8 +1788,8 @@ var
effect: TCocoaScrollBarEffectAlpha;
begin
effect:= TCocoaScrollBarEffectAlpha(TCocoaScrollBar(scroller).effect);
effect.fade( CocoaConfig.CocoaScrollerLegacyStyleFadeStep,
CocoaConfig.CocoaScrollerLegacyStyleAlphaBlack );
effect.fade( CocoaConfigScroller.legacy.knob.fadeStep,
CocoaConfigScroller.legacy.knob.alphaBlack );
end;
procedure TCocoaScrollStyleManagerLegacy.onMouseExited(scroller: NSScroller
@ -1798,8 +1798,8 @@ var
effect: TCocoaScrollBarEffectAlpha;
begin
effect:= TCocoaScrollBarEffectAlpha(TCocoaScrollBar(scroller).effect);
effect.fade( -CocoaConfig.CocoaScrollerLegacyStyleFadeStep,
CocoaConfig.CocoaScrollerLegacyStyleAlpha );
effect.fade( -CocoaConfigScroller.legacy.knob.fadeStep,
CocoaConfigScroller.legacy.knob.alpha );
end;
{ TCocoaScrollStyleManagerOverlay }
@ -1825,23 +1825,23 @@ begin
rect:= NSInsetRect(rect, 1, 1);
if scrollBar.IsHorizontal then begin
rect.origin.y:= rect.origin.y
+ CocoaConfig.CocoaScrollerOverlayStyleKnobPos
+ CocoaConfigScroller.overlay.knob.pos
- effect.expandedSize;
rect.size.height:= rect.size.height
- CocoaConfig.CocoaScrollerOverlayStyleKnobShrunkSize
- CocoaConfigScroller.overlay.knob.shrunkSize
+ effect.expandedSize;
end else begin
rect.origin.x:= rect.origin.x
+ CocoaConfig.CocoaScrollerOverlayStyleKnobPos
+ CocoaConfigScroller.overlay.knob.pos
- effect.expandedSize;
rect.size.width:= rect.size.width
- CocoaConfig.CocoaScrollerOverlayStyleKnobShrunkSize
- CocoaConfigScroller.overlay.knob.shrunkSize
+ effect.expandedSize;
end;
radius:= CocoaConfig.CocoaScrollerKnobRadius + effect.expandedSize/2;
radius:= CocoaConfigScroller.overlay.knob.radius + effect.expandedSize/2;
path:= NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius( rect, radius, radius );
CocoaConfig.CocoaScrollerOverlayStyleKnobColor().set_;
CocoaConfigScroller.overlay.knob.color().set_;
path.fill;
if scroller.knobProportion < 1 then
@ -1879,11 +1879,11 @@ begin
else
slotSize:= slotRect.size.height;
if knobProportion*slotSize <= CocoaConfig.CocoaScrollerOverlayStyleKnobMinSize then begin
if slotSize<=CocoaConfig.CocoaScrollerOverlayStyleKnobMinSize then
if knobProportion*slotSize <= CocoaConfigScroller.overlay.knob.minSize then begin
if slotSize<=CocoaConfigScroller.overlay.knob.minSize then
knobProportion:= 0.99
else
knobProportion:= CocoaConfig.CocoaScrollerOverlayStyleKnobMinSize/slotSize;
knobProportion:= CocoaConfigScroller.overlay.knob.minSize/slotSize;
end;
if (effect.currentKnobPosition=knobPosition) and (effect.currentKnobProportion=knobProportion) then
@ -1929,7 +1929,7 @@ begin
effect.manager:= self;
effect.currentKnobPosition:= -1;
effect.currentKnobProportion:= -1;
effect.currentAlpha:= CocoaConfig.CocoaScrollerOverlayStyleAlpha;
effect.currentAlpha:= CocoaConfigScroller.overlay.bar.alpha;
Result:= effect;
end;
@ -1976,7 +1976,7 @@ begin
// on old versions of macOS, alpha=0 is considered hidden.
// that is, to be truly visible, not only Hidden=false, but Alpha must also be set.
// otherwise it is considered hidden and setNeedsDisplay() does not take effect.
effect.currentAlpha:= CocoaConfig.CocoaScrollerOverlayStyleAlpha;
effect.currentAlpha:= CocoaConfigScroller.overlay.bar.alpha;
scroller.setAlphaValue( effect.currentAlpha );
scroller.setHidden( False );
scroller.setNeedsDisplay_( true );

View File

@ -202,7 +202,7 @@ begin
message.setSoundName( NSUserNotificationDefaultSoundName );
nc:= NSUserNotificationCenter.defaultUserNotificationCenter;
if CocoaConfig.CocoaAlwaysPresentNotification then begin
if CocoaConfigNotification.alwaysPresent then begin
if NOT Assigned(nc.delegate) then
nc.setDelegate( TCocoaUserNotificationCenterDelegate.new );
end;

View File

@ -786,7 +786,7 @@ begin
// See apple's documentation for "availableMembersOfFontFamily:"
// for the contents of "sub" NSArray
sysname := NSString(sub.objectAtIndex(1));
if CocoaUseLocalizedFontName then
if CocoaConfigGlobal.useLocalizedFontName then
begin
nm := fm.localizedNameForFamily_face(fname, sysname);
if not Assigned(nm) then

View File

@ -263,16 +263,16 @@ const
NSFocusRingTypeDefault // bsSingle
);
var
frs: CocoaConfig.TCocoaFocusRingStrategy;
frs: TCocoaConfigFocusRing.Strategy;
borderStyle: TBorderStyle;
begin
frs:= CocoaConfig.getCocoaControlFocusRingStrategry( cocoaControl.className );
frs:= CocoaConfigFocusRing.getStrategy( cocoaControl.className );
case frs of
TCocoaFocusRingStrategy.none:
TCocoaConfigFocusRing.Strategy.none:
cocoaControl.setFocusRingType( NSFocusRingTypeNone );
TCocoaFocusRingStrategy.required:
TCocoaConfigFocusRing.Strategy.required:
cocoaControl.setFocusRingType( NSFocusRingTypeExterior );
TCocoaFocusRingStrategy.border: begin
TCocoaConfigFocusRing.Strategy.border: begin
borderStyle:= TWinControlAccess(lclControl).BorderStyle;
cocoaControl.setFocusRingType( NSFocusRing[borderStyle] );
end;

View File

@ -657,17 +657,17 @@ begin
SetWindowButtonState(NSWindowZoomButton, (biMaximize in ABorderIcons) and (ABorderStyle in [bsSizeable, bsSizeToolWin]), (ABorderStyle in [bsSingle, bsSizeable]) and (biSystemMenu in ABorderIcons));
SetWindowButtonState(NSWindowCloseButton, True, (ABorderStyle <> bsNone) and (biSystemMenu in ABorderIcons));
if not CocoaConfig.CocoaIconUse then
if CocoaConfigGlobal.useIcon then
Exit;
btn := AWindow.standardWindowButton(NSWindowDocumentIconButton);
url := nil;
if isIconVisible[ABorderStyle] then
begin
btn := AWindow.standardWindowButton(NSWindowDocumentIconButton);
url := nil;
if isIconVisible[ABorderStyle] then
begin
b := NSBundle.mainBundle;
if Assigned(b) then url := b.bundleURL;
end;
AWindow.setRepresentedURL(url);
b := NSBundle.mainBundle;
if Assigned(b) then url := b.bundleURL;
end;
AWindow.setRepresentedURL(url);
end;
class procedure TCocoaWSCustomForm.UpdateWindowMask(AWindow: NSWindow;
@ -1078,7 +1078,7 @@ var
trg : NSImage;
btn : NSButton;
begin
if CocoaConfig.CocoaIconUse then Exit;
if CocoaConfigGlobal.useIcon then Exit;
if not AForm.HandleAllocated then Exit;
win := TCocoaWindowContent(AForm.Handle).lclOwnWindow;

View File

@ -161,12 +161,12 @@ end;
// used from the MenuMadness example
class function TCocoaWSMenuItem.NSMenuCheckmark: NSImage;
begin
Result:=NSImage.imageNamed(CocoaConfig.CocoaDefaultCheckMenuImageName);
Result:=NSImage.imageNamed(CocoaConfigMenu.defaultCheckImageName);
end;
class function TCocoaWSMenuItem.NSMenuRadio: NSImage;
begin
Result:=NSImage.imageNamed(CocoaConfig.CocoaDefaultRadioMenuImageName)
Result:=NSImage.imageNamed(CocoaConfigMenu.defaultRadioImageName);
end;
class function TCocoaWSMenuItem.isSeparator(const ACaption: AnsiString): Boolean;

View File

@ -2275,7 +2275,8 @@ var
btn: NSButton;
cl: NSButtonCell;
begin
btn := AllocButton(AWinControl, TLCLCheckBoxCallback, AParams, CocoaToggleBezel, CocoaToggleType);
btn := AllocButton(AWinControl, TLCLCheckBoxCallback, AParams,
CocoaConfigToggleBox.bezelStyle, CocoaConfigToggleBox.buttonType);
cl := NSButtonCell(NSButton(btn).cell);
cl.setShowsStateBy(cl.showsStateBy or NSContentsCellMask);
Result := TLCLHandle(btn);