This source file includes following definitions.
- overlay_view_
- SetFrameView
- SetOverlayView
- CanClose
- WindowClosing
- UpdateFrame
- SetInactiveRenderingDisabled
- GetWindowBoundsForClientBounds
- NonClientHitTest
- GetWindowMask
- ResetWindowControls
- UpdateWindowIcon
- UpdateWindowTitle
- LayoutFrameView
- SetAccessibleName
- GetPreferredSize
- GetMinimumSize
- GetMaximumSize
- Layout
- ViewHierarchyChanged
- GetAccessibleState
- GetClassName
- GetEventHandlerForRect
- GetTooltipHandlerForPoint
- SetInactiveRenderingDisabled
- ShouldPaintAsActive
- GetHTComponentForFrame
- HitTestRect
- GetAccessibleState
- GetClassName
- OnBoundsChanged
#include "ui/views/window/non_client_view.h"
#include "ui/accessibility/ax_view_state.h"
#include "ui/base/hit_test.h"
#include "ui/gfx/rect_conversions.h"
#include "ui/views/rect_based_targeting_utils.h"
#include "ui/views/widget/root_view.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/client_view.h"
namespace views {
const char NonClientFrameView::kViewClassName[] =
"ui/views/window/NonClientFrameView";
const char NonClientView::kViewClassName[] =
"ui/views/window/NonClientView";
static const int kFrameViewIndex = 0;
static const int kClientViewIndex = 1;
NonClientView::NonClientView()
: client_view_(NULL),
overlay_view_(NULL) {
}
NonClientView::~NonClientView() {
RemoveChildView(frame_view_.get());
}
void NonClientView::SetFrameView(NonClientFrameView* frame_view) {
frame_view->set_owned_by_client();
if (frame_view_.get())
RemoveChildView(frame_view_.get());
frame_view_.reset(frame_view);
if (parent())
AddChildViewAt(frame_view_.get(), kFrameViewIndex);
}
void NonClientView::SetOverlayView(View* view) {
if (overlay_view_)
RemoveChildView(overlay_view_);
if (!view)
return;
overlay_view_ = view;
if (parent())
AddChildView(overlay_view_);
}
bool NonClientView::CanClose() {
return client_view_->CanClose();
}
void NonClientView::WindowClosing() {
client_view_->WidgetClosing();
}
void NonClientView::UpdateFrame() {
Widget* widget = GetWidget();
SetFrameView(widget->CreateNonClientFrameView());
widget->ThemeChanged();
Layout();
SchedulePaint();
}
void NonClientView::SetInactiveRenderingDisabled(bool disable) {
frame_view_->SetInactiveRenderingDisabled(disable);
}
gfx::Rect NonClientView::GetWindowBoundsForClientBounds(
const gfx::Rect client_bounds) const {
return frame_view_->GetWindowBoundsForClientBounds(client_bounds);
}
int NonClientView::NonClientHitTest(const gfx::Point& point) {
return frame_view_->NonClientHitTest(point);
}
void NonClientView::GetWindowMask(const gfx::Size& size,
gfx::Path* window_mask) {
frame_view_->GetWindowMask(size, window_mask);
}
void NonClientView::ResetWindowControls() {
frame_view_->ResetWindowControls();
}
void NonClientView::UpdateWindowIcon() {
frame_view_->UpdateWindowIcon();
}
void NonClientView::UpdateWindowTitle() {
frame_view_->UpdateWindowTitle();
}
void NonClientView::LayoutFrameView() {
frame_view_->SetBounds(0, 0, width(), height());
frame_view_->Layout();
}
void NonClientView::SetAccessibleName(const base::string16& name) {
accessible_name_ = name;
}
gfx::Size NonClientView::GetPreferredSize() {
gfx::Rect client_bounds(gfx::Point(), client_view_->GetPreferredSize());
return GetWindowBoundsForClientBounds(client_bounds).size();
}
gfx::Size NonClientView::GetMinimumSize() {
return frame_view_->GetMinimumSize();
}
gfx::Size NonClientView::GetMaximumSize() {
return frame_view_->GetMaximumSize();
}
void NonClientView::Layout() {
LayoutFrameView();
client_view_->SetBoundsRect(frame_view_->GetBoundsForClientView());
client_view_->Layout();
if (overlay_view_ && overlay_view_->visible())
overlay_view_->SetBoundsRect(GetLocalBounds());
}
void NonClientView::ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) {
if (details.is_add && GetWidget() && details.child == this) {
AddChildViewAt(frame_view_.get(), kFrameViewIndex);
AddChildViewAt(client_view_, kClientViewIndex);
if (overlay_view_)
AddChildView(overlay_view_);
}
}
void NonClientView::GetAccessibleState(ui::AXViewState* state) {
state->role = ui::AX_ROLE_CLIENT;
state->name = accessible_name_;
}
const char* NonClientView::GetClassName() const {
return kViewClassName;
}
views::View* NonClientView::GetEventHandlerForRect(const gfx::Rect& rect) {
if (!views::UsePointBasedTargeting(rect))
return View::GetEventHandlerForRect(rect);
if (frame_view_->parent() == this) {
gfx::RectF rect_in_child_coords_f(rect);
View::ConvertRectToTarget(this, frame_view_.get(), &rect_in_child_coords_f);
gfx::Rect rect_in_child_coords = gfx::ToEnclosingRect(
rect_in_child_coords_f);
if (frame_view_->HitTestRect(rect_in_child_coords))
return frame_view_->GetEventHandlerForRect(rect_in_child_coords);
}
return View::GetEventHandlerForRect(rect);
}
views::View* NonClientView::GetTooltipHandlerForPoint(const gfx::Point& point) {
if (frame_view_->parent() == this) {
gfx::Point point_in_child_coords(point);
View::ConvertPointToTarget(this, frame_view_.get(), &point_in_child_coords);
views::View* handler =
frame_view_->GetTooltipHandlerForPoint(point_in_child_coords);
if (handler)
return handler;
}
return View::GetTooltipHandlerForPoint(point);
}
NonClientFrameView::~NonClientFrameView() {
}
void NonClientFrameView::SetInactiveRenderingDisabled(bool disable) {
if (inactive_rendering_disabled_ == disable)
return;
bool should_paint_as_active_old = ShouldPaintAsActive();
inactive_rendering_disabled_ = disable;
if (should_paint_as_active_old != ShouldPaintAsActive())
SchedulePaint();
}
bool NonClientFrameView::ShouldPaintAsActive() const {
return inactive_rendering_disabled_ || GetWidget()->IsActive();
}
int NonClientFrameView::GetHTComponentForFrame(const gfx::Point& point,
int top_resize_border_height,
int resize_border_thickness,
int top_resize_corner_height,
int resize_corner_width,
bool can_resize) {
int component;
if (point.x() < resize_border_thickness) {
if (point.y() < top_resize_corner_height)
component = HTTOPLEFT;
else if (point.y() >= (height() - resize_border_thickness))
component = HTBOTTOMLEFT;
else
component = HTLEFT;
} else if (point.x() >= (width() - resize_border_thickness)) {
if (point.y() < top_resize_corner_height)
component = HTTOPRIGHT;
else if (point.y() >= (height() - resize_border_thickness))
component = HTBOTTOMRIGHT;
else
component = HTRIGHT;
} else if (point.y() < top_resize_border_height) {
if (point.x() < resize_corner_width)
component = HTTOPLEFT;
else if (point.x() >= (width() - resize_corner_width))
component = HTTOPRIGHT;
else
component = HTTOP;
} else if (point.y() >= (height() - resize_border_thickness)) {
if (point.x() < resize_corner_width)
component = HTBOTTOMLEFT;
else if (point.x() >= (width() - resize_corner_width))
component = HTBOTTOMRIGHT;
else
component = HTBOTTOM;
} else {
return HTNOWHERE;
}
return can_resize ? component : HTBORDER;
}
bool NonClientFrameView::HitTestRect(const gfx::Rect& rect) const {
return !GetWidget()->client_view()->bounds().Intersects(rect);
}
void NonClientFrameView::GetAccessibleState(ui::AXViewState* state) {
state->role = ui::AX_ROLE_CLIENT;
}
const char* NonClientFrameView::GetClassName() const {
return kViewClassName;
}
void NonClientFrameView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
}
NonClientFrameView::NonClientFrameView() : inactive_rendering_disabled_(false) {
}
}