This source file includes following definitions.
- GetTopCornerRadiusWhenRestored
- GetIconXOffset
- GetDefaultIconSize
- GetThemeBackgroundXInset
- GetTitleBounds
- CanAnimateActivation
#include "ash/frame/header_painter_util.h"
#include <algorithm>
#include "ui/aura/window.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animator.h"
#include "ui/gfx/font_list.h"
#include "ui/gfx/rect.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
namespace {
const int kTopCornerRadiusWhenRestored = 2;
const int kIconXOffset = 9;
const int kDefaultIconSize = 16;
const int kTitleCaptionButtonSpacing = 5;
const int kTitleIconOffsetX = 5;
const int kTitleNoIconOffsetX = 8;
const int kThemeFrameImageInsetX = 5;
}
namespace ash {
int HeaderPainterUtil::GetTopCornerRadiusWhenRestored() {
return kTopCornerRadiusWhenRestored;
}
int HeaderPainterUtil::GetIconXOffset() {
return kIconXOffset;
}
int HeaderPainterUtil::GetDefaultIconSize() {
return kDefaultIconSize;
}
int HeaderPainterUtil::GetThemeBackgroundXInset() {
return kThemeFrameImageInsetX;
}
gfx::Rect HeaderPainterUtil::GetTitleBounds(
const views::View* icon,
const views::View* caption_button_container,
const gfx::FontList& title_font_list) {
int x = icon ?
icon->bounds().right() + kTitleIconOffsetX : kTitleNoIconOffsetX;
int height = title_font_list.GetHeight();
int y = std::max(0, (caption_button_container->height() / 2) - (height / 2));
int width = std::max(
0, caption_button_container->x() - kTitleCaptionButtonSpacing - x);
return gfx::Rect(x, y, width, height);
}
bool HeaderPainterUtil::CanAnimateActivation(views::Widget* widget) {
aura::Window* window = widget->GetNativeWindow();
if (!window->parent())
return true;
ui::LayerAnimator* parent_layer_animator =
window->parent()->layer()->GetAnimator();
return !parent_layer_animator->IsAnimatingProperty(
ui::LayerAnimationElement::OPACITY) &&
!parent_layer_animator->IsAnimatingProperty(
ui::LayerAnimationElement::VISIBILITY);
}
}