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

DropdownInput preview support and ColorButton history improvements #1598

Merged
merged 17 commits into from
Apr 30, 2024

Conversation

zhiyuang
Copy link
Contributor

@zhiyuang zhiyuang commented Feb 8, 2024

As follow ups of #1584 (comment)

@zhiyuang
Copy link
Contributor Author

zhiyuang commented Feb 8, 2024

sry, it's still work in progress, not ready even for reviewing. I should open this as a draft pr...

@Keavon
Copy link
Member

Keavon commented Feb 8, 2024

Ah, yes, good to open PRs early but just please mark them as a draft. I usually don't poke around draft PRs. But just make sure to ping me once you're ready for review, and switch it to non-draft. Thanks :)

@zhiyuang zhiyuang marked this pull request as draft February 8, 2024 07:12
@zhiyuang
Copy link
Contributor Author

zhiyuang commented Feb 8, 2024

@Keavon Actually, I opened this pr actually would like to confirm two user experience behaviors first.

Also, same for TextInput and TextAreaInput that should send updates as the user types but only commits when that currently happens.

Does it mean user type in TextInput in right panel, would like the text change according to in the canvas as user typing.(Right now it only changes when the TextInput is unfocus.)

So if you edit a color, once you release the mouse after dragging any of the sliders, it should send a commit at that time.

Does it means these sliders? (Right now these sliders do not save any history steps separately, only save a history step after close Color Panel)
image

@Keavon
Copy link
Member

Keavon commented Feb 8, 2024

Does it mean user type in TextInput in right panel, would like the text change according to in the canvas as user typing.(Right now it only changes when the TextInput is unfocus.)

If I'm interpreting your question correctly, I think you're asking if text created with the Text tool should be re-rendered as the user types in the Properties panel? My answer to that is: maybe, but only if the performance isn't too bad. There is also #1589 currently open so let's avoid implementing that right now in case it causes conflicts. I'm mostly just interested in having the text widget send its real-time text but letting the user of the text, like the Properties panel for the Text node, decide if it wants to use the real time version or the committed version (which is what is used right now).

Does it means these sliders? (Right now these sliders do not save any history steps separately, only save a history step after close Color Panel)

image

  • A, B, C: Should update when the user is finished dragging
  • D: Should update when the user commits a new typed value by hitting Enter, clicking out of the box, or closing the entire color picker popover by moving the mouse far away from it
  • E: Since this can be dragged or typed in, the previous two bullet points apply to this
  • F: Should update immediately upon being clicked or picking a color with the eyedropper

All of the above should send the history update as described, but duplicates should be avoided if the user committed a change that resulted in a value that's the same as when they started to edit that value.

@zhiyuang zhiyuang changed the title WIP: DropdownInput support preview DropdownInput support preview and Color Button history improments. Feb 9, 2024
@zhiyuang
Copy link
Contributor Author

zhiyuang commented Feb 9, 2024

@Keavon could have a code review when you have time.

This PR is mainly about Dropdown preview ability and Color Button related history actions (All actions in below image).
image

For TextInput widget, I haven't handled in this PR. I found unless we really need send updates on every typing by the users, current text widget has satisfied enough right now. Maybe we could return to this if we meet some concrete issues in future 🤔

@zhiyuang zhiyuang marked this pull request as ready for review February 9, 2024 02:15
@Keavon Keavon changed the title DropdownInput support preview and Color Button history improments. DropdownInput preview support and ColorButton history improvements Feb 18, 2024
@@ -67,6 +67,10 @@ pub struct DropdownInput {

pub tooltip: String,

#[derivative(Default(value = "false"))]
#[serde(rename = "previewOnHover")]
pub preview_on_hover: bool,
Copy link
Member

Choose a reason for hiding this comment

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

I'm pretty sure this shouldn't be necessary. It can work just like your previous PR where NumberInput was set to send both a preview value and a committed value. Then the backend code which wants this widget to send preview values would just handle those temporary values directly from the backend, whereas those which only care about the final committed value do nothing with the preview values. The approach I'm suggesting here would allow this widget to have a more standardized API alongside NumberInput widgets and others, and would be generally cleaner.

/// Update the value of a given UI widget, and commit it to the history
#[wasm_bindgen(js_name = widgetValueRevert)]
pub fn widget_value_revert(&self) -> Result<(), JsValue> {
self.dispatch(DocumentMessage::Undo);
Copy link
Member

Choose a reason for hiding this comment

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

This makes me nervous. But it shouldn't be necessary anymore once you make the change I suggested above.

@Keavon Keavon marked this pull request as draft February 18, 2024 22:49
@Keavon
Copy link
Member

Keavon commented Feb 18, 2024

I'm marking this as a draft while awaiting the requested changes. Please un-mark as draft and also ping me when ready for a second review. Thanks!

@Keavon
Copy link
Member

Keavon commented Mar 9, 2024

Hi, I'm just checking up on how things are going with this feedback round. Thanks :)

@zhiyuang
Copy link
Contributor Author

sry for the late, a little busy these two weeks. I'll look forward to see if I could find some time next week.

@Keavon
Copy link
Member

Keavon commented Mar 10, 2024

Sure thing, thank you for the update.

@zhiyuang
Copy link
Contributor Author

!build

@zhiyuang zhiyuang marked this pull request as ready for review March 18, 2024 01:49
@Keavon
Copy link
Member

Keavon commented Mar 18, 2024

!build

Copy link

📦 Build Complete for 9dce4d5
https://ff05ca5f.graphite.pages.dev

@Keavon
Copy link
Member

Keavon commented Mar 18, 2024

!build

@Keavon
Copy link
Member

Keavon commented Mar 18, 2024

I rebased this for you, and now strangely I'm getting fatal console errors when I hover over the dropdown menu entries. Can you please help investigate? I committed some debug instrumentation which points out that it's getting a value of -1 where it should be able to fit as a u64, which is weird since it also gets sent from the JS code as a number that's 0 or greater. Maybe you can help figure out the issue? Thanks.

Copy link

📦 Build Complete for 0e8d5f2
https://59efb20a.graphite.pages.dev

@zhiyuang
Copy link
Contributor Author

it's related to these codes, if I comment these out, it could work. d6e357f

@zhiyuang
Copy link
Contributor Author

zhiyuang commented Mar 20, 2024

but I still don't know how fix this. I'm not familiar with MenuList yet. It should be related to this PR: #1499

@Keavon
Copy link
Member

Keavon commented Mar 20, 2024

Ah, that's a good hint, thank you for investigating and narrowing it down to that! If you'd like me to take it from here, I can do that in the next couple days. Or if you'd like to keep digging and find the solution, please feel free to do that as well.

}
// if (interactive && newHighlight?.value !== activeEntry?.value && newHighlight) {
// dispatch("activeEntry", newHighlight);
// }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

for the preview case for blend mode. The activeEntry actually is the one being hovered, not the one being highlighted. So in this case it could be different. Maybe @0HyperCube could help have a look here.

@zhiyuang
Copy link
Contributor Author

@Keavon updated, pls check

@Keavon Keavon merged commit e769f50 into GraphiteEditor:master Apr 30, 2024
2 checks passed
@Keavon
Copy link
Member

Keavon commented Apr 30, 2024

Pardon the very long delay, this required rebuilding some mental context and I was quite busy with things unrelated to this. Thank you for helping make this happen, and your patience in my finally returning to merge it.

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.

None yet

2 participants