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

修复inputbox_getline缩放错误Fix inputbox scaling issue #262

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

sadlavaarsc
Copy link

@sadlavaarsc sadlavaarsc commented Feb 28, 2025

如题,原本的inputbox由于锁死长宽高(默认设置为400*300)导致在窗口本身较小时会显示不完全,严重时甚至完全无法显示文本框,如下图所示:

3F9076E44ABCBAFA195B3DA0F8C7EDD9

或者:

69B22A2D8AA35F2DB82395D19174CBB2

对此,通过简单的修改补充了在窗口小于默认inputbox时进行简单的缩放,具体来说缩放逻辑是:

  1. 如果空间足够,就采用远古设置
  2. 如果空间不够,就等比例缩放一下
  3. 由于字体高度对观感影响比较大,这里字体高度绑定的是对话框的高度

最终效果如下:

300*200的窗口:

81756B6E2E470FACC09182DE23AB9E88

680*400的窗口:

DE405C32BC88E943044E7D9F86EF64C9

更多细节参见代码

Summary by CodeRabbit

  • New Features
    • The input box now automatically adjusts its size and position based on available screen space, offering a more responsive and adaptive user interface.
    • Enhanced scaling adapts the text size and layout, ensuring improved readability, visual consistency, and a smoother experience across various devices.

Copy link

coderabbitai bot commented Feb 28, 2025

Walkthrough

The pull request updates the inputbox_getline function in src/egegapi.cpp by replacing fixed dimensions with dynamic calculations. The width and height now adapt using the MIN function to ensure they do not exceed default values, and proportional adjustments have been applied for positioning, sizing of components, and font scaling. Chinese comments have been added to clarify the drawing logic, while no changes were made to the declared public interfaces.

Changes

File Change Summary
src/egegapi.cpp Updated inputbox_getline to compute dynamic dimensions and proportional positioning and scaling; added Chinese comments explaining the logic

Sequence Diagram(s)

sequenceDiagram
    participant UI as User Interface
    participant IB as inputbox_getline
    participant SC as Screen Dimensions

    UI->>IB: Request input box display
    IB->>SC: Retrieve available screen dimensions
    SC-->>IB: Provide dimensions
    IB->>IB: Compute width & height using MIN function
    IB->>IB: Adjust position, size, and font scaling based on dimensions
    IB->>UI: Render dynamically sized input box
Loading

Poem

In a burrow of code so neat,
I hop with joy at every beat,
Dynamic sizes now lead the way,
Scaling input boxes come to play,
My rabbit heart cheers the clever update!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a2d667b and 60691c6.

📒 Files selected for processing (1)
  • src/egegapi.cpp (3 hunks)
🔇 Additional comments (5)
src/egegapi.cpp (5)

2994-2996: Good addition of explanatory comments.

The comments effectively explain the scaling logic implemented in this fix: maintaining original settings when space is sufficient, proportionally scaling when space is limited, and binding font height to dialog box height for better appearance.


3000-3002: Good implementation of dynamic sizing.

The code properly defines default dimensions (400x300) and uses the MIN function to ensure dimensions don't exceed either the default values or available screen space. The centered positioning calculation is also correct.


3011-3012: Edit control positioning and sizing now scale properly.

The implementation correctly scales the edit control's position and size proportionally to the dialog dimensions, ensuring it remains usable at smaller window sizes.


3022-3029: UI elements now scale appropriately with window dimensions.

The line drawing, font size, and text positioning all scale proportionally with the dialog dimensions, ensuring consistent appearance at different window sizes.


3033-3033: Rectangle scaling is consistent with other UI elements.

The text display rectangle is properly scaled proportionally to maintain the layout at smaller window sizes.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@chirsz-ever
Copy link
Collaborator

最佳的方式也许是实际计算布局,把中间和左右的空白压缩下?

@sadlavaarsc
Copy link
Author

最佳的方式也许是实际计算布局,把中间和左右的空白压缩下?

我有想过改的多一点,但是估计工作量约等于重新做一个inputbox了,那我再看看要不要改改或者加个新接口重载什么的

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.

2 participants