This source file includes following definitions.
- initial_position_
- GetClassName
- GetCursor
- OnMousePressed
- OnMouseDragged
- OnMouseReleased
- OnMouseCaptureLost
- GetAccessibleState
- ReportResizeAmount
#include "ui/views/controls/resize_area.h"
#include "base/logging.h"
#include "ui/accessibility/ax_view_state.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/views/controls/resize_area_delegate.h"
namespace views {
const char ResizeArea::kViewClassName[] = "ResizeArea";
ResizeArea::ResizeArea(ResizeAreaDelegate* delegate)
: delegate_(delegate),
initial_position_(0) {
}
ResizeArea::~ResizeArea() {
}
const char* ResizeArea::GetClassName() const {
return kViewClassName;
}
gfx::NativeCursor ResizeArea::GetCursor(const ui::MouseEvent& event) {
return enabled() ? ui::kCursorEastWestResize : gfx::kNullCursor;
}
bool ResizeArea::OnMousePressed(const ui::MouseEvent& event) {
if (!event.IsOnlyLeftMouseButton())
return false;
gfx::Point point(event.x(), 0);
View::ConvertPointToScreen(this, &point);
initial_position_ = point.x();
return true;
}
bool ResizeArea::OnMouseDragged(const ui::MouseEvent& event) {
if (!event.IsLeftMouseButton())
return false;
ReportResizeAmount(event.x(), false);
return true;
}
void ResizeArea::OnMouseReleased(const ui::MouseEvent& event) {
ReportResizeAmount(event.x(), true);
}
void ResizeArea::OnMouseCaptureLost() {
ReportResizeAmount(initial_position_, true);
}
void ResizeArea::GetAccessibleState(ui::AXViewState* state) {
state->role = ui::AX_ROLE_SPLITTER;
}
void ResizeArea::ReportResizeAmount(int resize_amount, bool last_update) {
gfx::Point point(resize_amount, 0);
View::ConvertPointToScreen(this, &point);
resize_amount = point.x() - initial_position_;
delegate_->OnResize(base::i18n::IsRTL() ? -resize_amount : resize_amount,
last_update);
}
}