This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Notify Win32FlutterWindow of cursor updates #23795
Merged
cbracken
merged 1 commit into
flutter:master
from
cbracken:windows-ime-cursor-rect-updates
Jan 23, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CPP_GEOMETRY_H_ | ||
| #define FLUTTER_SHELL_PLATFORM_COMMON_CPP_GEOMETRY_H_ | ||
|
|
||
| #include <cmath> | ||
|
|
||
| namespace flutter { | ||
|
|
||
| // A point in Cartesian space relative to a separately-maintained origin. | ||
| class Point { | ||
| public: | ||
| Point() = default; | ||
| Point(double x, double y) : x_(x), y_(y) {} | ||
| Point(const Point& point) = default; | ||
| Point& operator=(const Point& other) = default; | ||
|
|
||
| double x() const { return x_; } | ||
| double y() const { return y_; } | ||
|
|
||
| bool operator==(const Point& other) const { | ||
| return x_ == other.x_ && y_ == other.y_; | ||
| } | ||
|
|
||
| private: | ||
| double x_ = 0.0; | ||
| double y_ = 0.0; | ||
| }; | ||
|
|
||
| // A 2D floating-point size with non-negative dimensions. | ||
| class Size { | ||
| public: | ||
| Size() = default; | ||
| Size(double width, double height) | ||
| : width_(std::fmax(0.0, width)), height_(std::fmax(0.0, height)) {} | ||
|
|
||
| Size(const Size& size) = default; | ||
| Size& operator=(const Size& other) = default; | ||
|
|
||
| double width() const { return width_; } | ||
| double height() const { return height_; } | ||
|
|
||
| bool operator==(const Size& other) const { | ||
| return width_ == other.width_ && height_ == other.height_; | ||
| } | ||
|
|
||
| private: | ||
| double width_ = 0.0; | ||
| double height_ = 0.0; | ||
| }; | ||
|
|
||
| // A rectangle with position in Cartesian space specified relative to a | ||
| // separately-maintained origin. | ||
| class Rect { | ||
| public: | ||
| Rect() = default; | ||
| Rect(const Point& origin, const Size& size) : origin_(origin), size_(size) {} | ||
| Rect(const Rect& rect) = default; | ||
| Rect& operator=(const Rect& other) = default; | ||
|
|
||
| double left() const { return origin_.x(); } | ||
| double top() const { return origin_.y(); } | ||
| double right() const { return origin_.x() + size_.width(); } | ||
| double bottom() const { return origin_.y() + size_.height(); } | ||
| double width() const { return size_.width(); } | ||
| double height() const { return size_.height(); } | ||
| Point origin() const { return origin_; } | ||
| Size size() const { return size_; } | ||
|
|
||
| bool operator==(const Rect& other) const { | ||
| return origin_ == other.origin_ && size_ == other.size_; | ||
| } | ||
|
|
||
| private: | ||
| Point origin_; | ||
| Size size_; | ||
| }; | ||
cbracken marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| } // namespace flutter | ||
|
|
||
| #endif // FLUTTER_SHELL_PLATFORM_COMMON_CPP_GEOMETRY_H_ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #include "flutter/shell/platform/common/cpp/geometry.h" | ||
|
|
||
| #include "gtest/gtest.h" | ||
|
|
||
| namespace flutter { | ||
|
|
||
| TEST(Point, SetsCoordinates) { | ||
| Point point(-30.0, 42.0); | ||
| EXPECT_DOUBLE_EQ(-30.0, point.x()); | ||
| EXPECT_DOUBLE_EQ(42.0, point.y()); | ||
| } | ||
|
|
||
| TEST(Size, SetsDimensions) { | ||
| Size size(20.0, 42.0); | ||
| EXPECT_DOUBLE_EQ(20.0, size.width()); | ||
| EXPECT_DOUBLE_EQ(42.0, size.height()); | ||
| } | ||
|
|
||
| TEST(Size, ClampsDimensionsPositive) { | ||
| Size size(-20.0, -42.0); | ||
| EXPECT_DOUBLE_EQ(0.0, size.width()); | ||
| EXPECT_DOUBLE_EQ(0.0, size.height()); | ||
| } | ||
|
|
||
| TEST(Rect, SetsOriginAndSize) { | ||
| Point origin(-30.0, 42.0); | ||
| Size size(20.0, 22.0); | ||
| Rect rect(origin, size); | ||
| EXPECT_EQ(origin, rect.origin()); | ||
| EXPECT_EQ(size, rect.size()); | ||
| } | ||
|
|
||
| TEST(Rect, ReturnsLTRB) { | ||
| Point origin(-30.0, 42.0); | ||
| Size size(20.0, 22.0); | ||
| Rect rect(origin, size); | ||
| EXPECT_DOUBLE_EQ(-30.0, rect.left()); | ||
| EXPECT_DOUBLE_EQ(42.0, rect.top()); | ||
| EXPECT_DOUBLE_EQ(-10.0, rect.right()); | ||
| EXPECT_DOUBLE_EQ(64.0, rect.bottom()); | ||
| } | ||
|
|
||
| TEST(Rect, ReturnsWidthHeight) { | ||
| Point origin(-30.0, 42.0); | ||
| Size size(20.0, 22.0); | ||
| Rect rect(origin, size); | ||
| EXPECT_DOUBLE_EQ(20.0, rect.width()); | ||
| EXPECT_DOUBLE_EQ(22.0, rect.height()); | ||
| } | ||
|
|
||
| } // namespace flutter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.