[vlc-commits] macosx: Complete bar drawing for VLCHUDSliderCell
Marvin Scholz
git at videolan.org
Tue Jul 19 15:36:40 CEST 2016
vlc | branch: master | Marvin Scholz <epirat07 at gmail.com> | Tue Jul 19 15:34:37 2016 +0200| [f3e0abf8b34c08dc336ac2aa4aea861a868afcc9] | committer: Marvin Scholz
macosx: Complete bar drawing for VLCHUDSliderCell
Bar drawing was only working for horizontal cells completely,
this adds bar drawing for the active/inactive parts for vertical
cells as well.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f3e0abf8b34c08dc336ac2aa4aea861a868afcc9
---
modules/gui/macosx/VLCHUDSliderCell.m | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/modules/gui/macosx/VLCHUDSliderCell.m b/modules/gui/macosx/VLCHUDSliderCell.m
index 244aa2a..3413918 100644
--- a/modules/gui/macosx/VLCHUDSliderCell.m
+++ b/modules/gui/macosx/VLCHUDSliderCell.m
@@ -143,28 +143,36 @@ NSAffineTransform* RotationTransform(const CGFloat angle, const NSPoint point)
- (void)drawBarInside:(NSRect)fullRect flipped:(BOOL)flipped
{
+ NSBezierPath *path;
+
// Determine current position of knob
CGFloat knobPosition = (self.doubleValue - self.minValue) / (self.maxValue - self.minValue);
// Copy rect
NSRect activeRect = fullRect;
- // TODO: Implement active/inactive drawing for vetical sliders
- if (!self.isVertical) {
- // Calculate active rect
+ if (self.isVertical) {
+ // Calculate active rect (bottom part of slider)
+ if (flipped) {
+ activeRect.origin.y = (1 - knobPosition) * activeRect.size.height;
+ activeRect.size.height -= activeRect.origin.y - 1;
+ } else {
+ activeRect.size.height -= (1 - knobPosition) * activeRect.size.height - 1;
+ }
+ } else {
+ // Calculate active rect (left part of slider)
activeRect.size.width = knobPosition * (self.controlView.frame.size.width - 1.0);
-
- // Draw inactive bar
- [_disabledSliderColor setFill];
- NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:fullRect xRadius:2.0 yRadius:2.0];
- [path fill];
}
+ // Draw inactive bar
+ [_disabledSliderColor setFill];
+ path = [NSBezierPath bezierPathWithRoundedRect:fullRect xRadius:2.0 yRadius:2.0];
+ [path fill];
+
// Draw active bar
[_sliderColor setFill];
- NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:activeRect xRadius:2.0 yRadius:2.0];
+ path = [NSBezierPath bezierPathWithRoundedRect:activeRect xRadius:2.0 yRadius:2.0];
[path fill];
-
}
@end
More information about the vlc-commits
mailing list