GradientBackgroundView.m 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*****************************************************************************
  2. * Copyright (C) 2007-2012 Pierre d'Herbemont and VideoLAN
  3. *
  4. * Authors: Pierre d'Herbemont
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  19. *****************************************************************************/
  20. #import "GradientBackgroundView.h"
  21. /**********************************************************
  22. * Why not drawing something nice?
  23. */
  24. @implementation GradientBackgroundView
  25. - (void)awakeFromNib
  26. {
  27. /* Buggy nib files... Force us to be on the back of the view hierarchy */
  28. NSView * superView;
  29. [self retain];
  30. superView = [self superview];
  31. [self removeFromSuperview];
  32. [superView addSubview:self positioned: NSWindowBelow relativeTo:nil];
  33. }
  34. - (void)drawRect:(NSRect)rect
  35. {
  36. NSColor * topGradient = [NSColor colorWithCalibratedWhite:.12f alpha:1.0];
  37. NSColor * bottomGradient = [NSColor colorWithCalibratedWhite:0.55f alpha:0.9];
  38. NSGradient * gradient = [[NSGradient alloc] initWithColorsAndLocations:bottomGradient, 0.f, bottomGradient, 0.1f, topGradient, 1.f, nil];
  39. [gradient drawInRect:self.bounds angle:90.0];
  40. [super drawRect:rect];
  41. }
  42. @end