Commit 632ec8db authored by Min Chen's avatar Min Chen Committed by Commit Bot

No top drag indicator if a window is dragged from top in portrait screen orientation.

1. Added IndicatorType
   kDragAreaLeft, kCannotSnapLeft to show only left/top drag indicator,
   kDragAreaRight, kCannotSnapRight to show only right/bottom drag indicator,
   only kDragAreRight and kCannotSnapRight are used in this change, but still
   added kDragAreLeft and kCannotSnapLeft to keep consistence.

2. Move the logic to update the opacity of highlight view and label view from
   SplitViewDragIndicators to SplitViewHighligtView and RotatedImageLabelView
   instead.

see recorded video:
https://drive.google.com/file/d/0B5I0jFeLxqIiOGV3c0puTkJpTElBNUFSUlZpNEp6TElKUHJZ/view?usp=sharing

Bug: 871607
Test: SplitViewTabDraggingTest.DragIndicatorsInPortraitOrientationTest
Change-Id: I64f76766cd14dd2bca686be3f13d274993f24639
Reviewed-on: https://chromium-review.googlesource.com/1167998Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Min Chen <minch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583405}
parent a17f963e
......@@ -82,11 +82,6 @@ gfx::Point GetBoundedPosition(const gfx::Point& location_in_screen,
bounds_in_screen.y()));
}
// Transpose the given |rect|.
void TransposeRect(gfx::Rect* rect) {
rect->SetRect(rect->y(), rect->x(), rect->height(), rect->width());
}
mojom::SplitViewState ToMojomSplitViewState(SplitViewController::State state) {
switch (state) {
case SplitViewController::NO_SNAP:
......
......@@ -2299,6 +2299,49 @@ TEST_F(SplitViewTabDraggingTest, OverviewExitAnimationTest) {
EXPECT_FALSE(overview_observer->overview_animate_when_exiting());
}
// Tests that there is no top drag indicator if drag a window in portrait screen
// orientation.
TEST_F(SplitViewTabDraggingTest, DragIndicatorsInPortraitOrientationTest) {
UpdateDisplay("800x600");
int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
display::DisplayManager* display_manager = Shell::Get()->display_manager();
display::test::ScopedSetInternalDisplayId set_internal(display_manager,
display_id);
ScreenOrientationControllerTestApi test_api(
Shell::Get()->screen_orientation_controller());
ASSERT_EQ(test_api.GetCurrentOrientation(),
OrientationLockType::kLandscapePrimary);
const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> window(CreateWindow(bounds));
wm::GetWindowState(window.get())->Maximize();
EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized());
std::unique_ptr<WindowResizer> resizer =
StartDrag(window.get(), window.get());
ASSERT_TRUE(resizer.get());
EXPECT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting());
// Drag the window past the indicators threshold to show the indicators.
DragWindowTo(resizer.get(),
gfx::Point(200, GetIndicatorsThreshold(window.get())));
EXPECT_EQ(GetIndicatorState(resizer.get()), IndicatorState::kDragArea);
CompleteDrag(std::move(resizer));
EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized());
// Rotate the screen by 270 degree to portrait primary orientation.
test_api.SetDisplayRotation(display::Display::ROTATE_270,
display::Display::RotationSource::ACTIVE);
EXPECT_EQ(test_api.GetCurrentOrientation(),
OrientationLockType::kPortraitPrimary);
resizer = StartDrag(window.get(), window.get());
ASSERT_TRUE(resizer.get());
// Drag the window past the indicators threshold to show the indicators.
DragWindowTo(resizer.get(),
gfx::Point(200, GetIndicatorsThreshold(window.get())));
EXPECT_EQ(GetIndicatorState(resizer.get()), IndicatorState::kDragAreaRight);
CompleteDrag(std::move(resizer));
EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized());
}
class TestWindowDelegateWithWidget : public views::WidgetDelegate {
public:
TestWindowDelegateWithWidget(bool can_activate)
......
......@@ -67,36 +67,16 @@ gfx::Transform ComputeRotateAroundCenterTransform(const gfx::Rect& bounds,
return transform;
}
bool IsPreviewAreaState(IndicatorState indicator_state) {
return indicator_state == IndicatorState::kPreviewAreaLeft ||
indicator_state == IndicatorState::kPreviewAreaRight;
}
// Calculate whether the preview area should physically be on the left or top
// of the screen. kPreviewAreaLeft and kPreviewAreaRight correspond with
// LEFT_SNAPPED and RIGHT_SNAPPED which do not always correspond to the physical
// left and right of the screen. See split_view_controller.h for more details.
bool IsPreviewAreaOnLeftTopOfScreen(IndicatorState indicator_state) {
SplitViewController* split_view_controller =
Shell::Get()->split_view_controller();
return (indicator_state == IndicatorState::kPreviewAreaLeft &&
split_view_controller->IsCurrentScreenOrientationPrimary()) ||
(indicator_state == IndicatorState::kPreviewAreaRight &&
!split_view_controller->IsCurrentScreenOrientationPrimary());
}
// Helper function to compute the transform for the indicator labels when the
// view changes states. |main_transform| determines what ratio of the highlight
// we want to shift to. |non_transformed_bounds| represents the bounds of the
// label before its transform is applied; the centerpoint is used to calculate
// the amount of shift. One of |highlight_width| or |highlight_height| will be
// used to calculate the amount of shift as well, depending on |landscape|. If
// the label is not |left_or_top| (right or bottom) we will translate in the
// other direction.
// the amount of shift. |highlight_length| will be used to calculate the amount
// of shift as well. If the label is not |left_or_top| (right or bottom) we
// will translate in the other direction.
gfx::Transform ComputeLabelTransform(bool main_transform,
const gfx::Rect& non_transformed_bounds,
int highlight_width,
int highlight_height,
int highlight_length,
bool landscape,
bool left_or_top) {
// Compute the distance of the translation.
......@@ -106,7 +86,6 @@ gfx::Transform ComputeLabelTransform(bool main_transform,
const gfx::Point center_point = non_transformed_bounds.CenterPoint();
const int primary_axis_center =
landscape ? center_point.x() : center_point.y();
const int highlight_length = landscape ? highlight_width : highlight_height;
const float translate =
std::fabs(ratio * highlight_length - primary_axis_center);
......@@ -123,11 +102,55 @@ gfx::Transform ComputeLabelTransform(bool main_transform,
} // namespace
// static
bool SplitViewDragIndicators::IsPreviewAreaState(
IndicatorState indicator_state) {
return indicator_state == IndicatorState::kPreviewAreaLeft ||
indicator_state == IndicatorState::kPreviewAreaRight;
}
// static
bool SplitViewDragIndicators::IsLeftIndicatorState(
IndicatorState indicator_state) {
return indicator_state == IndicatorState::kDragAreaLeft ||
indicator_state == IndicatorState::kCannotSnapLeft;
}
// static
bool SplitViewDragIndicators::IsRightIndicatorState(
IndicatorState indicator_state) {
return indicator_state == IndicatorState::kDragAreaRight ||
indicator_state == IndicatorState::kCannotSnapRight;
}
// static
bool SplitViewDragIndicators::IsCannotSnapState(
IndicatorState indicator_state) {
return indicator_state == IndicatorState::kCannotSnap ||
indicator_state == IndicatorState::kCannotSnapLeft ||
indicator_state == IndicatorState::kCannotSnapRight;
}
// static
bool SplitViewDragIndicators::IsPreviewAreaOnLeftTopOfScreen(
IndicatorState indicator_state) {
SplitViewController* split_view_controller =
Shell::Get()->split_view_controller();
// kPreviewAreaLeft and kPreviewAreaRight correspond with LEFT_SNAPPED and
// RIGHT_SNAPPED which do not always correspond to the physical left and right
// of the screen. See split_view_controller.h for more details.
return (indicator_state == IndicatorState::kPreviewAreaLeft &&
split_view_controller->IsCurrentScreenOrientationPrimary()) ||
(indicator_state == IndicatorState::kPreviewAreaRight &&
!split_view_controller->IsCurrentScreenOrientationPrimary());
}
// View which contains a label and can be rotated. Used by and rotated by
// SplitViewDragIndicatorsView.
class SplitViewDragIndicators::RotatedImageLabelView : public views::View {
public:
RotatedImageLabelView() {
explicit RotatedImageLabelView(bool is_right_or_bottom)
: is_right_or_bottom_(is_right_or_bottom) {
label_ = new views::Label(base::string16(), views::style::CONTEXT_LABEL);
label_->SetPaintToLayer();
label_->layer()->SetFillsBoundsOpaquely(false);
......@@ -165,12 +188,47 @@ class SplitViewDragIndicators::RotatedImageLabelView : public views::View {
ComputeRotateAroundCenterTransform(bounds, angle));
}
// Called to update the opacity of the labels view on |indicator_state|.
void OnIndicatorTypeChanged(IndicatorState indicator_state,
IndicatorState previous_indicator_state) {
if (indicator_state == IndicatorState::kNone ||
IsPreviewAreaState(indicator_state)) {
DoSplitviewOpacityAnimation(layer(), SPLITVIEW_ANIMATION_TEXT_FADE_OUT);
return;
}
// No need to update left/top label view for right indicator state and also
// no need to update right/bottom label view for left indicator state.
if ((!is_right_or_bottom_ && IsRightIndicatorState(indicator_state)) ||
(is_right_or_bottom_ && IsLeftIndicatorState(indicator_state))) {
return;
}
SetLabelText(l10n_util::GetStringUTF16(IsCannotSnapState(indicator_state)
? IDS_ASH_SPLIT_VIEW_CANNOT_SNAP
: IDS_ASH_SPLIT_VIEW_GUIDANCE));
SplitviewAnimationType animation_type;
if (Shell::Get()->split_view_controller()->state() ==
SplitViewController::NO_SNAP) {
animation_type = IsPreviewAreaState(previous_indicator_state)
? SPLITVIEW_ANIMATION_TEXT_FADE_IN_WITH_HIGHLIGHT
: SPLITVIEW_ANIMATION_TEXT_FADE_IN;
} else {
animation_type = SPLITVIEW_ANIMATION_TEXT_FADE_OUT_WITH_HIGHLIGHT;
}
DoSplitviewOpacityAnimation(layer(), animation_type);
}
protected:
gfx::Size CalculatePreferredSize() const override {
return label_parent_->GetPreferredSize();
}
private:
// True if the label view is the right/bottom side one, false if it is the
// left/top one.
const bool is_right_or_bottom_;
RoundedRectView* label_parent_ = nullptr;
views::Label* label_ = nullptr;
......@@ -201,8 +259,10 @@ class SplitViewDragIndicators::SplitViewDragIndicatorsView
AddChildView(left_highlight_view_);
AddChildView(right_highlight_view_);
left_rotated_view_ = new RotatedImageLabelView();
right_rotated_view_ = new RotatedImageLabelView();
left_rotated_view_ =
new RotatedImageLabelView(/*is_right_or_bottom=*/false);
right_rotated_view_ =
new RotatedImageLabelView(/*is_right_or_bottom=*/true);
AddChildView(left_rotated_view_);
AddChildView(right_rotated_view_);
......@@ -224,77 +284,15 @@ class SplitViewDragIndicators::SplitViewDragIndicatorsView
previous_indicator_state_ = indicator_state_;
indicator_state_ = indicator_state;
switch (indicator_state) {
case IndicatorState::kNone:
DoSplitviewOpacityAnimation(left_highlight_view_->layer(),
SPLITVIEW_ANIMATION_HIGHLIGHT_FADE_OUT);
DoSplitviewOpacityAnimation(right_highlight_view_->layer(),
SPLITVIEW_ANIMATION_HIGHLIGHT_FADE_OUT);
DoSplitviewOpacityAnimation(left_rotated_view_->layer(),
SPLITVIEW_ANIMATION_TEXT_FADE_OUT);
DoSplitviewOpacityAnimation(right_rotated_view_->layer(),
SPLITVIEW_ANIMATION_TEXT_FADE_OUT);
return;
case IndicatorState::kDragArea:
case IndicatorState::kCannotSnap: {
const bool show = Shell::Get()->split_view_controller()->state() ==
SplitViewController::NO_SNAP;
for (RotatedImageLabelView* view : GetTextViews()) {
view->SetLabelText(l10n_util::GetStringUTF16(
indicator_state == IndicatorState::kCannotSnap
? IDS_ASH_SPLIT_VIEW_CANNOT_SNAP
: IDS_ASH_SPLIT_VIEW_GUIDANCE));
SplitviewAnimationType animation_type;
if (!show) {
animation_type = SPLITVIEW_ANIMATION_TEXT_FADE_OUT_WITH_HIGHLIGHT;
} else {
animation_type =
IsPreviewAreaState(previous_indicator_state_)
? SPLITVIEW_ANIMATION_TEXT_FADE_IN_WITH_HIGHLIGHT
: SPLITVIEW_ANIMATION_TEXT_FADE_IN;
}
DoSplitviewOpacityAnimation(view->layer(), animation_type);
}
for (SplitViewHighlightView* view : GetHighlightViews()) {
view->SetColor(indicator_state == IndicatorState::kCannotSnap
? SK_ColorBLACK
: SK_ColorWHITE);
DoSplitviewOpacityAnimation(
view->layer(), show ? SPLITVIEW_ANIMATION_HIGHLIGHT_FADE_IN
: SPLITVIEW_ANIMATION_HIGHLIGHT_FADE_OUT);
}
Layout(previous_indicator_state_ != IndicatorState::kNone);
return;
}
case IndicatorState::kPreviewAreaLeft:
case IndicatorState::kPreviewAreaRight: {
for (RotatedImageLabelView* view : GetTextViews()) {
DoSplitviewOpacityAnimation(view->layer(),
SPLITVIEW_ANIMATION_TEXT_FADE_OUT);
}
if (IsPreviewAreaOnLeftTopOfScreen(indicator_state_)) {
DoSplitviewOpacityAnimation(left_highlight_view_->layer(),
SPLITVIEW_ANIMATION_PREVIEW_AREA_FADE_IN);
DoSplitviewOpacityAnimation(
right_highlight_view_->layer(),
SPLITVIEW_ANIMATION_OTHER_HIGHLIGHT_FADE_OUT);
} else {
DoSplitviewOpacityAnimation(
left_highlight_view_->layer(),
SPLITVIEW_ANIMATION_OTHER_HIGHLIGHT_FADE_OUT);
DoSplitviewOpacityAnimation(right_highlight_view_->layer(),
SPLITVIEW_ANIMATION_PREVIEW_AREA_FADE_IN);
}
Layout(/*animate=*/true);
return;
}
}
left_rotated_view_->OnIndicatorTypeChanged(indicator_state,
previous_indicator_state_);
right_rotated_view_->OnIndicatorTypeChanged(indicator_state,
previous_indicator_state_);
left_highlight_view_->OnIndicatorTypeChanged(indicator_state);
right_highlight_view_->OnIndicatorTypeChanged(indicator_state);
NOTREACHED();
if (indicator_state != IndicatorState::kNone)
Layout(previous_indicator_state_ != IndicatorState::kNone);
}
views::View* GetViewForIndicatorType(IndicatorType type) {
......@@ -325,31 +323,30 @@ class SplitViewDragIndicators::SplitViewDragIndicatorsView
->split_view_controller()
->IsCurrentScreenOrientationLandscape();
const int display_width = landscape ? width() : height();
const int display_height = landscape ? height() : width();
// Calculate the bounds of the two highlight regions.
const int highlight_width =
landscape ? width() * kHighlightScreenPrimaryAxisRatio
: width() - 2 * kHighlightScreenEdgePaddingDp;
display_width * kHighlightScreenPrimaryAxisRatio;
const int highlight_height =
landscape ? height() - 2 * kHighlightScreenEdgePaddingDp
: height() * kHighlightScreenPrimaryAxisRatio;
display_height - 2 * kHighlightScreenEdgePaddingDp;
gfx::Size highlight_size(highlight_width, highlight_height);
// The origin of the right highlight view in landscape, or the bottom
// highlight view in portrait.
const gfx::Point right_bottom_origin(
landscape ? width() - highlight_width - kHighlightScreenEdgePaddingDp
: kHighlightScreenEdgePaddingDp,
landscape
? kHighlightScreenEdgePaddingDp
: height() - highlight_height - kHighlightScreenEdgePaddingDp);
gfx::Rect left_highlight_bounds, right_highlight_bounds;
left_highlight_bounds =
gfx::Rect(kHighlightScreenEdgePaddingDp, kHighlightScreenEdgePaddingDp,
highlight_width, highlight_height);
right_highlight_bounds =
gfx::Rect(right_bottom_origin.x(), right_bottom_origin.y(),
highlight_width, highlight_height);
gfx::Point right_bottom_origin(
display_width - highlight_width - kHighlightScreenEdgePaddingDp,
kHighlightScreenEdgePaddingDp);
const gfx::Point hightlight_padding_point(kHighlightScreenEdgePaddingDp,
kHighlightScreenEdgePaddingDp);
gfx::Rect left_highlight_bounds(hightlight_padding_point, highlight_size);
gfx::Rect right_highlight_bounds(right_bottom_origin, highlight_size);
if (!landscape) {
TransposeRect(&left_highlight_bounds);
TransposeRect(&right_highlight_bounds);
}
const bool preview_left =
(indicator_state_ == IndicatorState::kPreviewAreaLeft);
if (IsPreviewAreaState(indicator_state_)) {
......@@ -365,29 +362,19 @@ class SplitViewDragIndicators::SplitViewDragIndicatorsView
// Calculate the bounds of the other highlight, which is the one that
// shrinks and fades away, while the other one, the preview area, expands
// and takes up half the screen.
gfx::Rect other_bounds;
if (landscape) {
other_bounds.set_size(
gfx::Size(kOtherHighlightLengthDp,
height() - 2 * kHighlightScreenEdgePaddingDp));
other_bounds.set_origin(gfx::Point(
width() - kOtherHighlightLengthDp - kHighlightScreenEdgePaddingDp,
kHighlightScreenEdgePaddingDp));
} else {
other_bounds.set_size(
gfx::Size(width() - 2 * kHighlightScreenEdgePaddingDp,
kOtherHighlightLengthDp));
other_bounds.set_origin(gfx::Point(kHighlightScreenEdgePaddingDp,
height() - kOtherHighlightLengthDp -
kHighlightScreenEdgePaddingDp));
}
gfx::Rect other_bounds(
display_width - kOtherHighlightLengthDp -
kHighlightScreenEdgePaddingDp,
kHighlightScreenEdgePaddingDp, kOtherHighlightLengthDp,
display_height - 2 * kHighlightScreenEdgePaddingDp);
if (!landscape)
TransposeRect(&other_bounds);
if (IsPreviewAreaOnLeftTopOfScreen(indicator_state_)) {
left_highlight_bounds = preview_area_bounds;
right_highlight_bounds = other_bounds;
} else {
other_bounds.set_origin(gfx::Point(kHighlightScreenEdgePaddingDp,
kHighlightScreenEdgePaddingDp));
other_bounds.set_origin(hightlight_padding_point);
left_highlight_bounds = other_bounds;
right_highlight_bounds = preview_area_bounds;
}
......@@ -400,14 +387,24 @@ class SplitViewDragIndicators::SplitViewDragIndicatorsView
// Calculate the bounds of the views which contain the guidance text and
// icon. Rotate the two views in landscape mode.
const gfx::Size size(left_rotated_view_->GetPreferredSize().width(),
kSplitviewLabelPreferredHeightDp);
gfx::Rect left_rotated_bounds(highlight_width / 2 - size.width() / 2,
highlight_height / 2 - size.height() / 2,
size.width(), size.height());
const int size_width =
indicator_state_ == IndicatorState::kDragAreaLeft
? left_rotated_view_->GetPreferredSize().width()
: right_rotated_view_->GetPreferredSize().width();
gfx::Size size(size_width, kSplitviewLabelPreferredHeightDp);
if (!landscape)
highlight_size.SetSize(highlight_size.height(), highlight_size.width());
gfx::Rect left_rotated_bounds(
highlight_size.width() / 2 - size.width() / 2,
highlight_size.height() / 2 - size.height() / 2, size.width(),
size.height());
gfx::Rect right_rotated_bounds = left_rotated_bounds;
left_rotated_bounds.Offset(kHighlightScreenEdgePaddingDp,
kHighlightScreenEdgePaddingDp);
left_rotated_bounds.Offset(hightlight_padding_point.x(),
hightlight_padding_point.y());
if (!landscape) {
right_bottom_origin.SetPoint(right_bottom_origin.y(),
right_bottom_origin.x());
}
right_rotated_bounds.Offset(right_bottom_origin.x(),
right_bottom_origin.y());
......@@ -430,12 +427,12 @@ class SplitViewDragIndicators::SplitViewDragIndicatorsView
SplitviewAnimationType animation = SPLITVIEW_ANIMATION_TEXT_SLIDE_IN;
if (IsPreviewAreaState(indicator_state_)) {
animation = SPLITVIEW_ANIMATION_TEXT_SLIDE_OUT;
main_rotated_transform = ComputeLabelTransform(
preview_left, left_rotated_bounds, highlight_width, highlight_height,
landscape, preview_left);
other_rotated_transform = ComputeLabelTransform(
!preview_left, left_rotated_bounds, highlight_width, highlight_height,
landscape, preview_left);
main_rotated_transform =
ComputeLabelTransform(preview_left, left_rotated_bounds,
highlight_width, landscape, preview_left);
other_rotated_transform =
ComputeLabelTransform(!preview_left, left_rotated_bounds,
highlight_width, landscape, preview_left);
}
DoSplitviewTransformAnimation(
......@@ -446,13 +443,6 @@ class SplitViewDragIndicators::SplitViewDragIndicatorsView
preview_left ? other_rotated_transform : main_rotated_transform);
}
std::vector<SplitViewHighlightView*> GetHighlightViews() {
return {left_highlight_view_, right_highlight_view_};
}
std::vector<RotatedImageLabelView*> GetTextViews() {
return {left_rotated_view_, right_rotated_view_};
}
SplitViewHighlightView* left_highlight_view_ = nullptr;
SplitViewHighlightView* right_highlight_view_ = nullptr;
RotatedImageLabelView* left_rotated_view_ = nullptr;
......
......@@ -22,9 +22,30 @@ namespace ash {
// Enum which contains the possible states SplitViewDragIndicators can be in.
enum class IndicatorState {
kNone,
// Showing both left/top and right/bottom drag guidances.
kDragArea,
// Showing only left/top drag guidance.
kDragAreaLeft,
// Showing only right/bottom drag guidance.
kDragAreaRight,
// Showing both left/top and right/bottom cannot drag indicators.
kCannotSnap,
// Showing only left/top cannot drag indicator.
kCannotSnapLeft,
// Showing only right/bottom cannot drag indicator.
kCannotSnapRight,
// Showing a left/top preview area with the same bounds as left/top snapped
// window.
kPreviewAreaLeft,
// Showing a right/bottom preview area with the same bounds as right/bottom
// snapped window.
kPreviewAreaRight
};
......@@ -43,6 +64,15 @@ enum class IndicatorType {
// window has entered a snap region.
class ASH_EXPORT SplitViewDragIndicators {
public:
static bool IsPreviewAreaState(IndicatorState indicator_state);
static bool IsLeftIndicatorState(IndicatorState indicator_state);
static bool IsRightIndicatorState(IndicatorState indicator_state);
static bool IsCannotSnapState(IndicatorState indicator_state);
// Calculates whether the preview area should physically be on the left or
// top of the screen.
static bool IsPreviewAreaOnLeftTopOfScreen(IndicatorState indicator_state);
SplitViewDragIndicators();
~SplitViewDragIndicators();
......
......@@ -4,7 +4,9 @@
#include "ash/wm/splitview/split_view_highlight_view.h"
#include "ash/shell.h"
#include "ash/wm/overview/rounded_rect_view.h"
#include "ash/wm/splitview/split_view_controller.h"
#include "ash/wm/splitview/split_view_utils.h"
#include "ui/gfx/canvas.h"
#include "ui/views/view.h"
......@@ -168,4 +170,43 @@ void SplitViewHighlightView::SetColor(SkColor color) {
middle_->layer()->SetColor(color);
}
void SplitViewHighlightView::OnIndicatorTypeChanged(
IndicatorState indicator_state) {
if (indicator_state == IndicatorState::kNone) {
DoSplitviewOpacityAnimation(layer(),
SPLITVIEW_ANIMATION_HIGHLIGHT_FADE_OUT);
return;
}
if (SplitViewDragIndicators::IsPreviewAreaState(indicator_state)) {
const bool is_preview_on_left_or_top =
SplitViewDragIndicators::IsPreviewAreaOnLeftTopOfScreen(
indicator_state);
const bool should_fade_in = is_right_or_bottom_ ? !is_preview_on_left_or_top
: is_preview_on_left_or_top;
DoSplitviewOpacityAnimation(
layer(), should_fade_in ? SPLITVIEW_ANIMATION_PREVIEW_AREA_FADE_IN
: SPLITVIEW_ANIMATION_OTHER_HIGHLIGHT_FADE_OUT);
return;
}
// No need to update left/top highlight view for right indicator state and
// also no need to update right/bottom highlight view for left indicator
// state.
if ((!is_right_or_bottom_ &&
SplitViewDragIndicators::IsRightIndicatorState(indicator_state)) ||
(is_right_or_bottom_ &&
SplitViewDragIndicators::IsLeftIndicatorState(indicator_state))) {
return;
}
SetColor(SplitViewDragIndicators::IsCannotSnapState(indicator_state)
? SK_ColorBLACK
: SK_ColorWHITE);
DoSplitviewOpacityAnimation(layer(),
Shell::Get()->split_view_controller()->state() ==
SplitViewController::NO_SNAP
? SPLITVIEW_ANIMATION_HIGHLIGHT_FADE_IN
: SPLITVIEW_ANIMATION_HIGHLIGHT_FADE_OUT);
}
} // namespace ash
......@@ -6,6 +6,7 @@
#define ASH_WM_SPLITVIEW_SPLIT_VIEW_HIGHLIGHT_VIEW_H_
#include "ash/ash_export.h"
#include "ash/wm/splitview/split_view_drag_indicators.h"
#include "ui/views/view.h"
namespace ash {
......@@ -30,6 +31,9 @@ class ASH_EXPORT SplitViewHighlightView : public views::View {
void SetColor(SkColor color);
// Called to update the opacity of the highlights view on |indicator_state|.
void OnIndicatorTypeChanged(IndicatorState indicator_state);
private:
friend class SplitViewHighlightViewTestApi;
......@@ -50,4 +54,4 @@ class ASH_EXPORT SplitViewHighlightView : public views::View {
} // namespace ash
#endif // ASH_WM_SPLITVIEW_SPLIT_VIEW_HIGHLIGHT_VIEW_H_
\ No newline at end of file
#endif // ASH_WM_SPLITVIEW_SPLIT_VIEW_HIGHLIGHT_VIEW_H_
......@@ -9,6 +9,7 @@
#include "ui/compositor/layer_animation_observer.h"
#include "ui/compositor/layer_animator.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/geometry/rect.h"
namespace ash {
......@@ -190,4 +191,8 @@ void DoSplitviewTransformAnimation(ui::Layer* layer,
layer->SetTransform(target_transform);
}
void TransposeRect(gfx::Rect* rect) {
rect->SetRect(rect->y(), rect->x(), rect->height(), rect->width());
}
} // namespace ash
......@@ -7,6 +7,10 @@
#include "ui/gfx/transform.h"
namespace gfx {
class Rect;
} // namespace gfx
namespace ui {
class Layer;
} // namespace ui
......@@ -66,6 +70,9 @@ void DoSplitviewTransformAnimation(ui::Layer* layer,
SplitviewAnimationType type,
const gfx::Transform& target_transform);
// Transposes the given |rect|.
void TransposeRect(gfx::Rect* rect);
} // namespace ash
#endif // ASH_WM_SPLITVIEW_SPLIT_VIEW_UTILS_H_
......@@ -320,7 +320,12 @@ IndicatorState TabletModeWindowDragDelegate::GetIndicatorState(
return IndicatorState::kNone;
}
return can_snap ? IndicatorState::kDragArea : IndicatorState::kCannotSnap;
// No top drag indicator if in portrait screen orientation.
if (split_view_controller_->IsCurrentScreenOrientationLandscape())
return can_snap ? IndicatorState::kDragArea : IndicatorState::kCannotSnap;
return can_snap ? IndicatorState::kDragAreaRight
: IndicatorState::kCannotSnapRight;
}
void TabletModeWindowDragDelegate::UpdateDraggedWindowTransform(
......
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