Skip to content

Feat/colorpicker#705

Open
Alex2772 wants to merge 5 commits intodevelopfrom
feat/colorpicker
Open

Feat/colorpicker#705
Alex2772 wants to merge 5 commits intodevelopfrom
feat/colorpicker

Conversation

@Alex2772
Copy link
Copy Markdown
Collaborator

No description provided.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the UI framework by introducing new declarative components for color selection and display, making it easier to integrate color manipulation into applications. It also includes a crucial fix for Windows clipboard operations to ensure correct text encoding and improves the In contract for more ergonomic access to reactive properties.

Highlights

  • Windows Clipboard Fix: Corrected the text length calculation and UTF-16 conversion for clipboard operations on Windows, ensuring proper handling of wide characters.
  • Declarative Contract Enhancements: Added value(), operator*(), and operator->() methods to the contract::In struct, providing more convenient access to the underlying reactive property values.
  • New Color Picker Components: Introduced ColorView for displaying colors and SlidersRGB for editing color channels (Red, Green, Blue) using declarative UI principles.
  • Color Picker Example Application: Added a new example (color_picker1) demonstrating the usage and integration of the new ColorView and SlidersRGB components within a declarative UI window.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • aui.views/src/AUI/Platform/win32/AClipboardImpl.cpp
    • Corrected text length calculation for UTF-16 clipboard data.
    • Ensured proper UTF-16 conversion before copying text to clipboard.
  • aui.views/src/AUI/Util/Declarative/Contracts.h
    • Added value() method to contract::In to retrieve the underlying value.
    • Implemented operator*() and operator->() for contract::In for pointer-like access.
  • aui.views/src/AUI/View/AColorPicker.h
    • Added ColorView struct for displaying a single color.
    • Added SlidersRGB struct for editing color channels via sliders.
    • Included helper functions for color channel adjustment and default slider creation.
  • examples/ui/color_picker1/CMakeLists.txt
    • Added CMake configuration for the new color picker example.
  • examples/ui/color_picker1/src/main.cpp
    • Created a new example application demonstrating ColorView and SlidersRGB usage.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new color picker feature with declarative UI components, along with a fix for Windows clipboard handling. The new components are well-designed and an example is provided. My feedback focuses on improving robustness in the clipboard implementation by adding necessary error checks, enhancing performance by avoiding unnecessary object copies in the new color picker code, and removing some dead code in the example.

Comment on lines +32 to +46
_<AView> operator()() {
auto color = this->color;
return Centered {
_new<AView>() AUI_LET {
AObject::connect(
AUI_REACT(ass::PropertyListRecursive {
BackgroundSolid {
color.value(),
},
Expanding {},
}),
AUI_SLOT(it)::setCustomStyle);
},
};
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The local variable color is an unnecessary copy of the member this->color. You can use this->color directly to avoid the copy.

    _<AView> operator()() {
        return Centered {
            _new<AView>() AUI_LET {
                    AObject::connect(
                        AUI_REACT(ass::PropertyListRecursive {
                          BackgroundSolid {
                            this->color.value(),
                          },
                          Expanding {},
                        }),
                        AUI_SLOT(it)::setCustomStyle);
                },
        };
    }

Comment on lines +125 to +127
sliderFactory(color, onColorChanged, &AColor::r),
sliderFactory(color, onColorChanged, &AColor::g),
sliderFactory(std::move(color), std::move(onColorChanged), &AColor::b),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The sliderFactory is called three times, causing two copies and one move of color and onColorChanged. This is inefficient, especially for std::function. A better approach would be to pass these by const reference to sliderFactory.

This would require changing sliderFactory's signature (line 78) to:

std::function<_<AView>(const contract::In<AColor>& color, const std::function<void(AColor)>& onColorChanged, Channel channel)>

And defaultSlider's signature (line 89) to:

static _<AView>
defaultSlider(const contract::In<AColor>& color, const std::function<void(AColor)>& onColorChanged, Channel channel)

Then you can call it without moves here, improving efficiency and consistency.

            sliderFactory(color, onColorChanged, &AColor::r),
            sliderFactory(color, onColorChanged, &AColor::g),
            sliderFactory(color, onColorChanged, &AColor::b),

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.

1 participant