mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 12:30:36 +02:00
Cocoa/Config: turn Overlay Style Scroller Config to the new Style
This commit is contained in:
parent
3d7a79d4d0
commit
08275d757b
@ -152,14 +152,34 @@ type
|
|||||||
fadeStep: Double;
|
fadeStep: Double;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TCocoaConfgiScrollerOverlayKnob = object( TCocoaConfgiScrollerKnob )
|
||||||
|
minSize: Double;
|
||||||
|
end;
|
||||||
|
|
||||||
TCocoaConfigScrollerLegacy = record
|
TCocoaConfigScrollerLegacy = record
|
||||||
knob: TCocoaConfgiScrollerLegacyKnob;
|
knob: TCocoaConfgiScrollerLegacyKnob;
|
||||||
end;
|
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
|
TCocoaConfigScroller = record
|
||||||
preferredStyle: NSScrollerStyle;
|
preferredStyle: NSScrollerStyle;
|
||||||
fadeTimeInterval: Double;
|
fadeTimeInterval: Double;
|
||||||
legacy: TCocoaConfigScrollerLegacy;
|
legacy: TCocoaConfigScrollerLegacy;
|
||||||
|
overlay: TCocoaConfigScrollerOverlay;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -184,6 +204,31 @@ var
|
|||||||
fadeStep: 0.05; // Knob Alpha Step when fading in/out
|
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;
|
||||||
|
)
|
||||||
|
);
|
||||||
);
|
);
|
||||||
|
|
||||||
type
|
type
|
||||||
|
@ -1486,8 +1486,8 @@ end;
|
|||||||
procedure TCocoaScrollBarEffectOverlay.onDelayHidingTimer( timer:NSTimer );
|
procedure TCocoaScrollBarEffectOverlay.onDelayHidingTimer( timer:NSTimer );
|
||||||
begin
|
begin
|
||||||
self.delayTimer:= nil;
|
self.delayTimer:= nil;
|
||||||
self.fade( CocoaConfig.CocoaScrollerOverlayStyleFadeStep,
|
self.fade( CocoaConfigScroller.overlay.bar.alphaFadeStep,
|
||||||
CocoaConfig.CocoaScrollerOverlayStyleFadeTo );
|
CocoaConfigScroller.overlay.bar.alphaFadeTo );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCocoaScrollBarEffectOverlay.onExpandTimer(timer: NSTimer);
|
procedure TCocoaScrollBarEffectOverlay.onExpandTimer(timer: NSTimer);
|
||||||
@ -1499,7 +1499,7 @@ begin
|
|||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if self.expandedSize < CocoaConfig.CocoaScrollerOverlayStyleExpandSize then begin
|
if self.expandedSize < CocoaConfigScroller.overlay.bar.expandSize then begin
|
||||||
self.expandedSize:= self.expandedSize + 1;
|
self.expandedSize:= self.expandedSize + 1;
|
||||||
end else begin
|
end else begin
|
||||||
done:= True;
|
done:= True;
|
||||||
@ -1534,14 +1534,14 @@ end;
|
|||||||
procedure TCocoaScrollBarEffectOverlay.setDelayShowingTimer;
|
procedure TCocoaScrollBarEffectOverlay.setDelayShowingTimer;
|
||||||
begin
|
begin
|
||||||
self.setDelayTimer(
|
self.setDelayTimer(
|
||||||
CocoaScrollerOverlayStyleAutoShowDelayTime,
|
CocoaConfigScroller.overlay.bar.autoShowDelayTime,
|
||||||
ObjCSelector('onDelayShowingTimer:') );
|
ObjCSelector('onDelayShowingTimer:') );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCocoaScrollBarEffectOverlay.setDelayHidingTimer;
|
procedure TCocoaScrollBarEffectOverlay.setDelayHidingTimer;
|
||||||
begin
|
begin
|
||||||
self.setDelayTimer(
|
self.setDelayTimer(
|
||||||
CocoaConfig.CocoaScrollerOverlayStyleAutoHideDelayTime,
|
CocoaConfigScroller.overlay.bar.autoHideDelayTime,
|
||||||
ObjCSelector('onDelayHidingTimer:') );
|
ObjCSelector('onDelayHidingTimer:') );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1553,7 +1553,7 @@ begin
|
|||||||
self.expandTimer.invalidate;
|
self.expandTimer.invalidate;
|
||||||
|
|
||||||
self.expandTimer:= NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats(
|
self.expandTimer:= NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats(
|
||||||
CocoaConfig.CocoaScrollerOverlayStyleExpandTimeInterval,
|
CocoaConfigScroller.overlay.bar.expandTimeInterval,
|
||||||
self,
|
self,
|
||||||
ObjCSelector('onExpandTimer:'),
|
ObjCSelector('onExpandTimer:'),
|
||||||
nil,
|
nil,
|
||||||
@ -1825,23 +1825,23 @@ begin
|
|||||||
rect:= NSInsetRect(rect, 1, 1);
|
rect:= NSInsetRect(rect, 1, 1);
|
||||||
if scrollBar.IsHorizontal then begin
|
if scrollBar.IsHorizontal then begin
|
||||||
rect.origin.y:= rect.origin.y
|
rect.origin.y:= rect.origin.y
|
||||||
+ CocoaConfig.CocoaScrollerOverlayStyleKnobPos
|
+ CocoaConfigScroller.overlay.knob.pos
|
||||||
- effect.expandedSize;
|
- effect.expandedSize;
|
||||||
rect.size.height:= rect.size.height
|
rect.size.height:= rect.size.height
|
||||||
- CocoaConfig.CocoaScrollerOverlayStyleKnobShrunkSize
|
- CocoaConfigScroller.overlay.knob.shrunkSize
|
||||||
+ effect.expandedSize;
|
+ effect.expandedSize;
|
||||||
end else begin
|
end else begin
|
||||||
rect.origin.x:= rect.origin.x
|
rect.origin.x:= rect.origin.x
|
||||||
+ CocoaConfig.CocoaScrollerOverlayStyleKnobPos
|
+ CocoaConfigScroller.overlay.knob.pos
|
||||||
- effect.expandedSize;
|
- effect.expandedSize;
|
||||||
rect.size.width:= rect.size.width
|
rect.size.width:= rect.size.width
|
||||||
- CocoaConfig.CocoaScrollerOverlayStyleKnobShrunkSize
|
- CocoaConfigScroller.overlay.knob.shrunkSize
|
||||||
+ effect.expandedSize;
|
+ effect.expandedSize;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
radius:= CocoaConfig.CocoaScrollerKnobRadius + effect.expandedSize/2;
|
radius:= CocoaConfigScroller.overlay.knob.radius + effect.expandedSize/2;
|
||||||
path:= NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius( rect, radius, radius );
|
path:= NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius( rect, radius, radius );
|
||||||
CocoaConfig.CocoaScrollerOverlayStyleKnobColor().set_;
|
CocoaConfigScroller.overlay.knob.color().set_;
|
||||||
path.fill;
|
path.fill;
|
||||||
|
|
||||||
if scroller.knobProportion < 1 then
|
if scroller.knobProportion < 1 then
|
||||||
@ -1879,11 +1879,11 @@ begin
|
|||||||
else
|
else
|
||||||
slotSize:= slotRect.size.height;
|
slotSize:= slotRect.size.height;
|
||||||
|
|
||||||
if knobProportion*slotSize <= CocoaConfig.CocoaScrollerOverlayStyleKnobMinSize then begin
|
if knobProportion*slotSize <= CocoaConfigScroller.overlay.knob.minSize then begin
|
||||||
if slotSize<=CocoaConfig.CocoaScrollerOverlayStyleKnobMinSize then
|
if slotSize<=CocoaConfigScroller.overlay.knob.minSize then
|
||||||
knobProportion:= 0.99
|
knobProportion:= 0.99
|
||||||
else
|
else
|
||||||
knobProportion:= CocoaConfig.CocoaScrollerOverlayStyleKnobMinSize/slotSize;
|
knobProportion:= CocoaConfigScroller.overlay.knob.minSize/slotSize;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (effect.currentKnobPosition=knobPosition) and (effect.currentKnobProportion=knobProportion) then
|
if (effect.currentKnobPosition=knobPosition) and (effect.currentKnobProportion=knobProportion) then
|
||||||
@ -1929,7 +1929,7 @@ begin
|
|||||||
effect.manager:= self;
|
effect.manager:= self;
|
||||||
effect.currentKnobPosition:= -1;
|
effect.currentKnobPosition:= -1;
|
||||||
effect.currentKnobProportion:= -1;
|
effect.currentKnobProportion:= -1;
|
||||||
effect.currentAlpha:= CocoaConfig.CocoaScrollerOverlayStyleAlpha;
|
effect.currentAlpha:= CocoaConfigScroller.overlay.bar.alpha;
|
||||||
Result:= effect;
|
Result:= effect;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1976,7 +1976,7 @@ begin
|
|||||||
// on old versions of macOS, alpha=0 is considered hidden.
|
// 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.
|
// 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.
|
// 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.setAlphaValue( effect.currentAlpha );
|
||||||
scroller.setHidden( False );
|
scroller.setHidden( False );
|
||||||
scroller.setNeedsDisplay_( true );
|
scroller.setNeedsDisplay_( true );
|
||||||
|
Loading…
Reference in New Issue
Block a user