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

Side by Side Diff: chrome/browser/speech/speech_input_bubble_views.cc

Issue 8863009: Fix alignment of avatar bubbles in the NTP (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 9 years 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/speech/speech_input_bubble.h" 5 #include "chrome/browser/speech/speech_input_bubble.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 TabContents* tab_contents); 47 TabContents* tab_contents);
48 48
49 void UpdateLayout(SpeechInputBubbleBase::DisplayMode mode, 49 void UpdateLayout(SpeechInputBubbleBase::DisplayMode mode,
50 const string16& message_text, 50 const string16& message_text,
51 const SkBitmap& image); 51 const SkBitmap& image);
52 void SetImage(const SkBitmap& image); 52 void SetImage(const SkBitmap& image);
53 53
54 // views::BubbleDelegateView methods. 54 // views::BubbleDelegateView methods.
55 virtual void OnWidgetActivationChanged(views::Widget* widget, 55 virtual void OnWidgetActivationChanged(views::Widget* widget,
56 bool active) OVERRIDE; 56 bool active) OVERRIDE;
57 virtual gfx::Point GetAnchorPoint() OVERRIDE; 57 virtual gfx::Rect GetAnchorRect() OVERRIDE;
58 virtual void Init() OVERRIDE; 58 virtual void Init() OVERRIDE;
59 59
60 // views::ButtonListener methods. 60 // views::ButtonListener methods.
61 virtual void ButtonPressed(views::Button* source, const views::Event& event); 61 virtual void ButtonPressed(views::Button* source, const views::Event& event);
62 62
63 // views::LinkListener methods. 63 // views::LinkListener methods.
64 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; 64 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
65 65
66 // views::View overrides. 66 // views::View overrides.
67 virtual gfx::Size GetPreferredSize(); 67 virtual gfx::Size GetPreferredSize();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 set_close_on_deactivate(false); 101 set_close_on_deactivate(false);
102 } 102 }
103 103
104 void SpeechInputBubbleView::OnWidgetActivationChanged(views::Widget* widget, 104 void SpeechInputBubbleView::OnWidgetActivationChanged(views::Widget* widget,
105 bool active) { 105 bool active) {
106 if (widget == GetWidget() && !active) 106 if (widget == GetWidget() && !active)
107 delegate_->InfoBubbleFocusChanged(); 107 delegate_->InfoBubbleFocusChanged();
108 BubbleDelegateView::OnWidgetActivationChanged(widget, active); 108 BubbleDelegateView::OnWidgetActivationChanged(widget, active);
109 } 109 }
110 110
111 gfx::Point SpeechInputBubbleView::GetAnchorPoint() { 111 gfx::Rect SpeechInputBubbleView::GetAnchorRect() {
112 gfx::Rect container_rect; 112 gfx::Rect container_rect;
113 tab_contents_->GetContainerBounds(&container_rect); 113 tab_contents_->GetContainerBounds(&container_rect);
114 gfx::Point anchor(container_rect.x() + element_rect_.CenterPoint().x(), 114 gfx::Point anchor(container_rect.x() + element_rect_.CenterPoint().x(),
115 container_rect.y() + element_rect_.bottom()); 115 container_rect.y() + element_rect_.bottom());
116 if (!container_rect.Contains(anchor)) 116 if (!container_rect.Contains(anchor))
117 return BubbleDelegateView::GetAnchorPoint(); 117 return BubbleDelegateView::GetAnchorRect();
118 return anchor; 118 return gfx::Rect(anchor, gfx::Size());
119 } 119 }
120 120
121 void SpeechInputBubbleView::Init() { 121 void SpeechInputBubbleView::Init() {
122 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 122 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
123 const gfx::Font& font = rb.GetFont(ResourceBundle::MediumFont); 123 const gfx::Font& font = rb.GetFont(ResourceBundle::MediumFont);
124 124
125 heading_ = new views::Label( 125 heading_ = new views::Label(
126 l10n_util::GetStringUTF16(IDS_SPEECH_INPUT_BUBBLE_HEADING)); 126 l10n_util::GetStringUTF16(IDS_SPEECH_INPUT_BUBBLE_HEADING));
127 heading_->set_border(views::Border::CreateEmptyBorder( 127 heading_->set_border(views::Border::CreateEmptyBorder(
128 kBubbleHeadingVertMargin, 0, kBubbleHeadingVertMargin, 0)); 128 kBubbleHeadingVertMargin, 0, kBubbleHeadingVertMargin, 0));
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 } 367 }
368 368
369 } // namespace 369 } // namespace
370 370
371 SpeechInputBubble* SpeechInputBubble::CreateNativeBubble( 371 SpeechInputBubble* SpeechInputBubble::CreateNativeBubble(
372 TabContents* tab_contents, 372 TabContents* tab_contents,
373 SpeechInputBubble::Delegate* delegate, 373 SpeechInputBubble::Delegate* delegate,
374 const gfx::Rect& element_rect) { 374 const gfx::Rect& element_rect) {
375 return new SpeechInputBubbleImpl(tab_contents, delegate, element_rect); 375 return new SpeechInputBubbleImpl(tab_contents, delegate, element_rect);
376 } 376 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/setting_level_bubble.cc ('k') | chrome/browser/ui/views/avatar_menu_bubble_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698