Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1097)

Unified Diff: chrome/browser/cocoa/location_bar/bubble_decoration.h

Issue 2805070: [Mac] First part of Omnibox decoration refactor. Enable ev bubble. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: comment clarification Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/cocoa/location_bar/bubble_decoration.h
diff --git a/chrome/browser/cocoa/location_bar/bubble_decoration.h b/chrome/browser/cocoa/location_bar/bubble_decoration.h
new file mode 100644
index 0000000000000000000000000000000000000000..03858457f6d4303d325743bae99d5c0e3dee4390
--- /dev/null
+++ b/chrome/browser/cocoa/location_bar/bubble_decoration.h
@@ -0,0 +1,62 @@
+// Copyright (c) 2010 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.
+
+#ifndef CHROME_BROWSER_COCOA_LOCATION_BAR_BUBBLE_DECORATION_H_
+#define CHROME_BROWSER_COCOA_LOCATION_BAR_BUBBLE_DECORATION_H_
+
+#import <Cocoa/Cocoa.h>
+
+#include "base/gtest_prod_util.h"
+#include "base/scoped_nsobject.h"
+#include "chrome/browser/cocoa/location_bar/location_bar_decoration.h"
+
+// Draws an outlined rounded rect, with an optional image to the left
+// and an optional text label to the right.
+
+class BubbleDecoration : public LocationBarDecoration {
+ public:
+ // |font| will be used when drawing the label, and cannot be |nil|.
+ BubbleDecoration(NSFont* font);
+ ~BubbleDecoration();
+
+ // Setup the drawing parameters.
+ void SetImage(NSImage* image);
+ void SetLabel(NSString* label);
+ void SetColors(NSColor* border_color,
+ NSColor* background_color,
+ NSColor* text_color);
+
+ // Implement |LocationBarDecoration|.
+ virtual void DrawInFrame(NSRect frame, NSView* control_view);
+ virtual CGFloat GetWidthForSpace(CGFloat width);
+
+ protected:
+ // Helper returning bubble width for the given |image| and |label|
+ // assuming |font_| (for sizing text). Arguments can be nil.
+ CGFloat GetWidthForImageAndLabel(NSImage* image, NSString* label);
+
+ private:
+ friend class SelectedKeywordDecorationTest;
+ FRIEND_TEST_ALL_PREFIXES(SelectedKeywordDecorationTest,
+ UsesPartialKeywordIfNarrow);
+
+ // Contains font attribute for drawing |label_|.
+ scoped_nsobject<NSDictionary> attributes_;
+
+ // Image drawn in the left side of the bubble.
+ scoped_nsobject<NSImage> image_;
+
+ // Label to draw to right of image. Can be |nil|.
+ scoped_nsobject<NSString> label_;
+
+ // Colors used to draw the bubble, should be set by the subclass
+ // constructor.
+ scoped_nsobject<NSColor> background_color_;
+ scoped_nsobject<NSColor> border_color_;
+ scoped_nsobject<NSColor> text_color_;
+
+ DISALLOW_COPY_AND_ASSIGN(BubbleDecoration);
+};
+
+#endif // CHROME_BROWSER_COCOA_LOCATION_BAR_BUBBLE_DECORATION_H_

Powered by Google App Engine
This is Rietveld 408576698