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

Side by Side Diff: chrome/browser/ui/views/dropdown_bar_view.cc

Issue 6913026: Compact Navigation prototype (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/views/dropdown_bar_view.h"
6
7 #include "chrome/browser/themes/theme_service.h"
8 #include "chrome/browser/ui/view_ids.h"
9 #include "chrome/browser/ui/views/frame/browser_view.h"
10 #include "grit/generated_resources.h"
11 #include "grit/theme_resources_standard.h"
12 #include "ui/base/resource/resource_bundle.h"
13 #include "ui/gfx/canvas.h"
14 #include "views/background.h"
15 #include "views/widget/widget.h"
16
17 namespace {
18 // When we are animating, we draw only the top part of the left and right
sky 2011/05/03 18:38:32 newlines between 17/18 and 21/22.
SteveT 2011/05/06 18:48:43 Done.
19 // edges to give the illusion that the find dialog is attached to the
20 // window during this animation; this is the height of the items we draw.
21 const int kAnimatingEdgeHeight = 5;
22 }
sky 2011/05/03 18:38:32 // namespace
SteveT 2011/05/06 18:48:43 Done.
23
24 ////////////////////////////////////////////////////////////////////////////////
25 // DropDownBarView, public:
26
27 void DropdownBarView::set_animation_offset(int offset) {
28 animation_offset_ = offset;
29 }
30
31 ////////////////////////////////////////////////////////////////////////////////
32 // DropDownBarView, protected:
33
34 void DropdownBarView::SetDialogBorderBitmaps(const SkBitmap* dialog_left,
35 const SkBitmap* dialog_middle,
36 const SkBitmap* dialog_right) {
37 dialog_left_ = dialog_left;
38 dialog_middle_ = dialog_middle;
39 dialog_right_ = dialog_right;
40 }
41
42 gfx::Rect DropdownBarView::PaintOffsetToolbarBackground(gfx::Canvas* canvas) {
43 // Determine the find bar size as well as the offset from which to tile the
44 // toolbar background image. First, get the widget bounds.
45 gfx::Rect bounds = GetWidget()->GetWindowScreenBounds();
46 // Now convert from screen to parent coordinates.
47 gfx::Point origin(bounds.origin());
48 BrowserView* browser_view = host()->browser_view();
49 ConvertPointToView(NULL, browser_view, &origin);
50 bounds.set_origin(origin);
51 // Finally, calculate the background image tiling offset.
52 origin = browser_view->OffsetPointForToolbarBackgroundImage(origin);
53
54 // First, we draw the background image for the whole dialog (3 images: left,
55 // middle and right). Note, that the window region has been set by the
56 // controller, so the whitespace in the left and right background images is
57 // actually outside the window region and is therefore not drawn. See
58 // FindInPageWidgetWin::CreateRoundedWindowEdges() for details.
59 ui::ThemeProvider* tp = GetThemeProvider();
60 canvas->TileImageInt(*tp->GetBitmapNamed(IDR_THEME_TOOLBAR), origin.x(),
61 origin.y(), 0, 0, bounds.width(), bounds.height());
62 return bounds;
63 }
64
65 void DropdownBarView::PaintDialogBorder(gfx::Canvas* canvas,
66 const gfx::Rect& bounds) const {
67 DCHECK(dialog_left_);
68 DCHECK(dialog_middle_);
69 DCHECK(dialog_right_);
70
71 canvas->DrawBitmapInt(*dialog_left_, 0, 0);
72
73 // Stretch the middle background to cover all of the area between the two
74 // other images.
75 canvas->TileImageInt(*dialog_middle_, dialog_left_->width(), 0,
76 bounds.width() - dialog_left_->width() - dialog_right_->width(),
77 dialog_middle_->height());
78
79 canvas->DrawBitmapInt(*dialog_right_, bounds.width() - dialog_right_->width(),
80 0);
81 }
82
83 void DropdownBarView::PaintAnimatingEdges(gfx::Canvas* canvas,
84 const gfx::Rect& bounds) const {
85 if (animation_offset() > 0) {
86 // While animating we draw the curved edges at the point where the
87 // controller told us the top of the window is: |animation_offset()|.
88 canvas->TileImageInt(*dialog_left_, bounds.x(), animation_offset(),
89 dialog_left_->width(), kAnimatingEdgeHeight);
90 canvas->TileImageInt(*dialog_right_,
91 bounds.width() - dialog_right_->width(), animation_offset(),
92 dialog_right_->width(), kAnimatingEdgeHeight);
93 }
94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698