[PR #4912] [MERGED] til::rectangle #26033

Open
opened 2026-01-31 09:13:30 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/4912
Author: @miniksa
Created: 3/13/2020
Status: ✅ Merged
Merged: 3/14/2020
Merged by: @undefined

Base: master ← Head: dev/miniksa/til_rectangle


📝 Commits (6)

  • 56420f0 Pull out til::rectangle for separate submission.
  • 3861693 Add natvis.
  • 8b0d892 Code format, of course.
  • 21bde5a didn't need to define assignment, let it be default for rule of 5.
  • 1fba953 some typos
  • 2d0888e Use CheckSub to be clearer about the math and drop some parentheses per nit comment.

📊 Changes

10 files changed (+1517 additions, -4 deletions)

View changed files

📝 src/inc/til.h (+1 -0)
📝 src/inc/til/point.h (+2 -2)
➕ src/inc/til/rectangle.h (+484 -0)
📝 src/inc/til/size.h (+2 -2)
📝 src/inc/til/some.h (+58 -0)
➕ src/til/ut_til/RectangleTests.cpp (+932 -0)
📝 src/til/ut_til/SomeTests.cpp (+32 -0)
📝 src/til/ut_til/til.unit.tests.vcxproj (+1 -0)
📝 src/til/ut_til/til.unit.tests.vcxproj.filters (+1 -0)
📝 tools/ConsoleTypes.natvis (+4 -0)

📄 Description

Summary of the Pull Request

Introduces convenience type til::rectangle which automatically implements our best practices for rectangle-related types and provides automatic conversions in/out of the relevant types.

PR Checklist

  • In support of Differential Rendering #778
  • I work here.
  • Tests added/passed
  • I'm a core contributor.

Detailed Description of the Pull Request / Additional comments

  • Automatically converts in from anything with a Left/Top/Right/Bottom or left/top/right/bottom (Win32 RECT)
  • Automatically converts Console type SMALL_RECT and shifts it from inclusive to exclusive on instantiation
  • Automatically converts out to SMALL_RECT (converting back to inclusive), RECT, or D2D1_RECT_F.
  • Constructs from bare integers written into source file
  • Constructs from a single til::point as a 1x1 size rectangle with top-left corner (origin) at that point
  • Constructs from a single til::size as a WxH size rectangle with top-left corner (origin) at 0,0
  • Constructs from a til::point and a til::size representing the top-left corner and the width by height.
  • Constructs from a til::point and another til::point representing the top-left corner and the exclusive bottom-right corner.
  • Default constructs to empty
  • Uses Chromium numerics for all basic math operations (+, -, *, /)
  • Provides equality tests
  • Provides operator bool to know when it's valid (has an area > 0) and empty() to know the contrary
  • Accessors for left/top/right/bottom
  • Type converting accessors (that use safe conversions and throw) for left/top/right/bottom
  • Convenience methods for finding width/height (with Chromium numerics operations) and type-converting templates (with Chromium numerics conversions).
  • Accessors for origin (top-left point) and the size/dimensions (as a til::size).
  • Intersect operation on operator & to find where two til::rectangles overlap, returned as a til::rectangle.
  • Union operation on operator | to find the total area covered by two til::rectangles, returned as a til::rectangle.
  • Subtract operation on operator - to find the area remaining after one til::rectangle is removed from another, returned as a til::some<til::rectangle, 4>.
  • TAEF/WEX Output and Comparators so they will print very nicely with VERIFY and Log macros in our testing suite.
  • Additional comparators, TAEF/WEX output, and tests written on til::some to support the Subtract operation.
  • A natvis

Validation Steps Performed

  • See automated tests of functionality.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/4912 **Author:** [@miniksa](https://github.com/miniksa) **Created:** 3/13/2020 **Status:** ✅ Merged **Merged:** 3/14/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/miniksa/til_rectangle` --- ### 📝 Commits (6) - [`56420f0`](https://github.com/microsoft/terminal/commit/56420f064161a5ff596abf4b90c9c891d38064e3) Pull out til::rectangle for separate submission. - [`3861693`](https://github.com/microsoft/terminal/commit/386169316b6a5a9544cba435581a7d7670980212) Add natvis. - [`8b0d892`](https://github.com/microsoft/terminal/commit/8b0d892c8e7c126fbbecd886ea55fac5fefbbdc9) Code format, of course. - [`21bde5a`](https://github.com/microsoft/terminal/commit/21bde5a5339fba2ae7ccee7f43c753dd334e113f) didn't need to define assignment, let it be default for rule of 5. - [`1fba953`](https://github.com/microsoft/terminal/commit/1fba95398e4e7f38f7c97080e93260f8ff9f209e) some typos - [`2d0888e`](https://github.com/microsoft/terminal/commit/2d0888eea95dd0248ec96fc3aed50dab011e7fb4) Use CheckSub to be clearer about the math and drop some parentheses per nit comment. ### 📊 Changes **10 files changed** (+1517 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/inc/til.h` (+1 -0) 📝 `src/inc/til/point.h` (+2 -2) ➕ `src/inc/til/rectangle.h` (+484 -0) 📝 `src/inc/til/size.h` (+2 -2) 📝 `src/inc/til/some.h` (+58 -0) ➕ `src/til/ut_til/RectangleTests.cpp` (+932 -0) 📝 `src/til/ut_til/SomeTests.cpp` (+32 -0) 📝 `src/til/ut_til/til.unit.tests.vcxproj` (+1 -0) 📝 `src/til/ut_til/til.unit.tests.vcxproj.filters` (+1 -0) 📝 `tools/ConsoleTypes.natvis` (+4 -0) </details> ### 📄 Description ## Summary of the Pull Request Introduces convenience type `til::rectangle` which automatically implements our best practices for rectangle-related types and provides automatic conversions in/out of the relevant types. ## PR Checklist * [x] In support of Differential Rendering #778 * [X] I work here. * [x] Tests added/passed * [x] I'm a core contributor. ## Detailed Description of the Pull Request / Additional comments - Automatically converts in from anything with a Left/Top/Right/Bottom or left/top/right/bottom (Win32 `RECT`) - Automatically converts Console type `SMALL_RECT` and shifts it from **inclusive** to **exclusive** on instantiation - Automatically converts out to `SMALL_RECT` (converting back to **inclusive**), `RECT`, or `D2D1_RECT_F`. - Constructs from bare integers written into source file - Constructs from a single `til::point` as a 1x1 size rectangle with top-left corner (origin) at that point - Constructs from a single `til::size` as a WxH size rectangle with top-left corner (origin) at 0,0 - Constructs from a `til::point` and a `til::size` representing the top-left corner and the width by height. - Constructs from a `til::point` and another `til::point` representing the top-left corner and the **exclusive** bottom-right corner. - Default constructs to empty - Uses Chromium numerics for all basic math operations (+, -, *, /) - Provides equality tests - Provides `operator bool` to know when it's valid (has an area > 0) and `empty()` to know the contrary - Accessors for left/top/right/bottom - Type converting accessors (that use safe conversions and throw) for left/top/right/bottom - Convenience methods for finding width/height (with Chromium numerics operations) and type-converting templates (with Chromium numerics conversions). - Accessors for origin (top-left point) and the size/dimensions (as a `til::size`). - Intersect operation on `operator &` to find where two `til::rectangle`s overlap, returned as a `til::rectangle`. - Union operation on `operator |` to find the total area covered by two `til::rectangles`, returned as a `til::rectangle`. - Subtract operation on `operator -` to find the area remaining after one `til::rectangle` is removed from another, returned as a `til::some<til::rectangle, 4>`. - TAEF/WEX Output and Comparators so they will print very nicely with `VERIFY` and `Log` macros in our testing suite. - Additional comparators, TAEF/WEX output, and tests written on `til::some` to support the Subtract operation. - A natvis ## Validation Steps Performed - See automated tests of functionality. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:13:30 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#26033