Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nadro/adhoc/center rectangle #4480

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Nadro/adhoc/center rectangle #4480

wants to merge 12 commits into from

Conversation

nadr0
Copy link
Collaborator

@nadr0 nadr0 commented Nov 13, 2024

closes #4402

Implements

  • Used the placeholder we have for Center Rectangle in the toolbar and updated it with the new state
  • Implemented a workflow similar to Rectangle but for Center Rectangle
  • Center Rectangle is enabled in the rectangle dropdown menu
  • Several type narrowing functions for different expressions
  • Fixed createLiteral definition since it didn't actually use the type LiteralValue

Gotchas

  • Toolbar UX issue are apparent in this ticket but the work will be done in Improve toolbar UX #4469
  • We are using the same modtifyAST for rectangle for center rectangle
  • Once the center rectangle is created, it edits as if it is a rectangle not a center rectangle due to the handler
  • The initial point the user clicks is "wrong" in the KCL code within the startProfileAt but once they click into the second state for dragging the width and height it will be corrected since there is dimension to the box. It effectively says the startProfile at is the center with width/height of 0.

Future improvements

  • Do we need a kcl standard library call for center rectangle?
  • Do we need a new handler for center rectangle so it only allows center point moving and matched dimensions dragging for height and width?

Copy link

vercel bot commented Nov 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
modeling-app ✅ Ready (Inspect) Visit Preview Nov 13, 2024 5:20pm

Copy link

qa-wolf bot commented Nov 13, 2024

QA Wolf here! As you write new code it's important that your test coverage is keeping up.
Click here to request test coverage for this PR!

Copy link
Collaborator

@franknoirot franknoirot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This works well for me while testing locally. I only had nits

@franknoirot
Copy link
Collaborator

Oh wtf my VS Code extension didn't save the comments, so annoying

Copy link
Collaborator

@franknoirot franknoirot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One addition I'd call out is that if you want this to appear in the command bar as a part of this PR, you should add the center rectangle tool to the modelingCommandConfig.ts, but that's not critical just another way to equip the tool. Great job!

: 'none',
},
}),
icon: 'arc',
Copy link
Collaborator

@franknoirot franknoirot Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(comment): This looks like you might have been testing out if it had any effect, which it doesn't. So maybe we need a TODO to make the dropdown items support icons; I can make a Center Rectangle icon coming up soon.

Comment on lines +123 to +124
;((pipeExpression.body[1] as CallExpression)
.arguments[0] as ArrayExpression) = createArrayExpression([
Copy link
Collaborator

@franknoirot franknoirot Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit): Should this make use of your new cool type narrowing functions as well?

Copy link
Collaborator

@franknoirot franknoirot Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(comment): I didn't know about this syntax, super cool

Copy link
Collaborator

@franknoirot franknoirot Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(comment): Kurt's done some cool work to make this stuff less boilerplate-filled, and I'd love your ideas as you touch code like this on how to take it further, because it still feels repetitive and "getting your hands dirty", na mean?

@@ -215,6 +217,7 @@ export function Toolbar({
}
const itemConfig = maybeIconConfig

// A single button
Copy link
Collaborator

@franknoirot franknoirot Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(comment):

// A single button

...followed by like 40 lines of JSX lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Rectangle from center tool
2 participants