summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/cocoa/omnibox/omnibox_popup_separator_view.mm
blob: 49f9a0df1fa639660a01f6adf533dd1ff55a50dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_separator_view.h"

#include "grit/theme_resources.h"
#import "ui/base/cocoa/nsview_additions.h"
#include "ui/base/resource/resource_bundle.h"

@implementation OmniboxPopupTopSeparatorView

+ (CGFloat)preferredHeight {
  return 1;
}

- (void)drawRect:(NSRect)rect {
  NSRect separatorRect = [self bounds];
  separatorRect.size.height = [self cr_lineWidth];
  [[self strokeColor] set];
  NSRectFillUsingOperation(separatorRect, NSCompositeSourceOver);
}

@end

@implementation OmniboxPopupBottomSeparatorView

+ (CGFloat)preferredHeight {
  ResourceBundle& rb = ResourceBundle::GetSharedInstance();
  NSImage* shadowImage =
      rb.GetNativeImageNamed(IDR_OVERLAY_DROP_SHADOW).ToNSImage();
  return [shadowImage size].height;
}

- (void)drawRect:(NSRect)rect {
  ResourceBundle& rb = ResourceBundle::GetSharedInstance();
  NSRect bounds = [self bounds];

  // Draw the shadow.
  NSImage* shadowImage =
      rb.GetNativeImageNamed(IDR_OVERLAY_DROP_SHADOW).ToNSImage();
  [shadowImage drawInRect:bounds
                 fromRect:NSZeroRect
                operation:NSCompositeSourceOver
                 fraction:1.0];
}

@end