Commit bc34e176 authored by gbillock@chromium.org's avatar gbillock@chromium.org

[Views] Add a capability to the bubble delegate to be able to set the font of the title.

BUG=383947

Review URL: https://codereview.chromium.org/326963002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278045 0039d316-1c4b-4281-b951-d872f2087c98
parent 20a99a11
......@@ -5,6 +5,7 @@
#include "ui/views/bubble/bubble_delegate.h"
#include "ui/accessibility/ax_view_state.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/rect.h"
#include "ui/native_theme/native_theme.h"
......@@ -131,6 +132,9 @@ View* BubbleDelegateView::GetContentsView() {
NonClientFrameView* BubbleDelegateView::CreateNonClientFrameView(
Widget* widget) {
BubbleFrameView* frame = new BubbleFrameView(margins());
// Note: In CreateBubble, the call to SizeToContents() will cause
// the relayout that this call requires.
frame->SetTitleFontList(GetTitleFontList());
BubbleBorder::Arrow adjusted_arrow = arrow();
if (base::i18n::IsRTL())
adjusted_arrow = BubbleBorder::horizontal_mirror(adjusted_arrow);
......@@ -277,6 +281,12 @@ gfx::Rect BubbleDelegateView::GetBubbleBounds() {
GetPreferredSize(), adjust_if_offscreen_ && !anchor_minimized);
}
const gfx::FontList& BubbleDelegateView::GetTitleFontList() const {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
return rb.GetFontList(ui::ResourceBundle::MediumFont);
}
void BubbleDelegateView::UpdateColorsFromTheme(const ui::NativeTheme* theme) {
if (!color_explicitly_set_)
color_ = theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground);
......
......@@ -12,6 +12,7 @@
#include "ui/views/widget/widget_observer.h"
namespace gfx {
class FontList;
class Rect;
}
......@@ -117,6 +118,10 @@ class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView,
// Get bubble bounds from the anchor rect and client view's preferred size.
virtual gfx::Rect GetBubbleBounds();
// Return a FontList to use for the title of the bubble.
// (The default is MediumFont).
virtual const gfx::FontList& GetTitleFontList() const;
// View overrides:
virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE;
......
......@@ -163,6 +163,10 @@ void BubbleFrameView::UpdateWindowTitle() {
ResetWindowControls();
}
void BubbleFrameView::SetTitleFontList(const gfx::FontList& font_list) {
title_->SetFontList(font_list);
}
gfx::Insets BubbleFrameView::GetInsets() const {
gfx::Insets insets = content_margins_;
const int title_height = title_->text().empty() ? 0 :
......
......@@ -12,6 +12,10 @@
#include "ui/views/controls/button/button.h"
#include "ui/views/window/non_client_view.h"
namespace gfx {
class FontList;
}
namespace views {
class Label;
......@@ -43,6 +47,10 @@ class VIEWS_EXPORT BubbleFrameView : public NonClientFrameView,
virtual void UpdateWindowIcon() OVERRIDE;
virtual void UpdateWindowTitle() OVERRIDE;
// Set the FontList to be used for the title of the bubble.
// Caller must arrange to update the layout to have the call take effect.
void SetTitleFontList(const gfx::FontList& font_list);
// View overrides:
virtual gfx::Insets GetInsets() const OVERRIDE;
virtual gfx::Size GetPreferredSize() const OVERRIDE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment