Skip to content

Refactor: Replace horizontal/vertical AddLine() calls to AddLineH(),AddLineV() - #711

Merged
brenocq merged 1 commit into
epezent:masterfrom
ocornut:v193_addline
Aug 6, 2026
Merged

Refactor: Replace horizontal/vertical AddLine() calls to AddLineH(),AddLineV()#711
brenocq merged 1 commit into
epezent:masterfrom
ocornut:v193_addline

Conversation

@ocornut

@ocornut ocornut commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Note: I do not suggest merging as-is. Read on.

1.92.8 introduced helper AddLineV(), AddLineH() functions.
There have a nicer API but in current version is essentially identical.

An upcoming rework of ImDrawList will slightly change AddLine() (with a legacy path available) and basically using AddLineV()/AddLineH() will be both faster and a "simpler" path to backward compatibility.

This PR changes all horizontal/vertical AddLine() calls to AddLineV/AddLineH.
There are only 3 remaining AddLine() which may need revaluation when the 1.93.0 is ready (either add +0.5 to provide pixel center, either pass ImDrawFlags_StrokeLegacy. Will provide details later as this is not out yet).

In theory you could merge this today and it makes ImPlot code a little bit simpler and shorter.
BUT, this requires 1.92.8, and unfortunately as ImDrawList functions are methods we can't easily add them locally.

I see 3 options:

  • A. Merge as is and decide to break support for <1.92.8, which can be an occasion to cleanup some old support. This is sort of the lazy option.
  • B. Make those helpers floating functions, e.g. ImPlot_AddLineH(drawlist, ... which makes it easy to support <1.92.8. I can change the PR to do that. It only creates a syntax asymmetry calling those functions.
  • C. Use hacky/messy derived type ImDrawListForImPlot to add a method.

I would suggest (B) so it feels silly that the current PR is for (A) but I'll let you confirm what you think is the right approach.

@brenocq
brenocq self-requested a review August 6, 2026 07:23
@brenocq brenocq changed the title Replace horizontal/vertical AddLine() calls to AddLineH(),AddLineV() Refactor: Replace horizontal/vertical AddLine() calls to AddLineH(),AddLineV() Aug 6, 2026
@brenocq brenocq added prio:high High priority status:review The task is under review type:refactor Code refactoring without changing functionality labels Aug 6, 2026
@brenocq

brenocq commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Thanks for making the changes! The new ImDrawList results look great, also, nice work on the Wiki! I agree (B) sounds like the best. I noticed the "Allow edits from maintainers" is turned off, so feel free to implement the new methods or allow me to edit the branch, then I can make the changes myself. I think it's always nice to keep support for old ImGui versions, when the code gets too messy then we can decide to drop support for ImGui < X.YYY.Z.

To offload some work from you, I could also start porting your ImPlot changes to ImPlot3D and add you as reviewer there, let me know if you prefer implementing the changes in both ImPlot and ImPlot3D yourself.

Thanks for the great work!

@ocornut

ocornut commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks I’ll makes the change soon. Feel free to work on equivalent ImPlot3d change.

…AddLineV() wrappers. (epezent#711)

3 remaining AddLine() calls to check evaluate for 1.93.0 change.
@ocornut

ocornut commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

Reworked as 0182a86.
The signature and location of the helper functions made to match existing e.g.AddTextVertical().

@brenocq brenocq left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Awesome! I've tested it with v1.92.4 and features/drawlist_193, both worked without problems.

@brenocq
brenocq merged commit 47c994a into epezent:master Aug 6, 2026
18 checks passed
@brenocq brenocq added status:done Task completed successfully and removed status:review The task is under review labels Aug 6, 2026
@brenocq

brenocq commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

@ocornut I've created the PR in ImPlot3D brenocq/implot3d#195, feel free to take a look at it when you have some time (I'm not very familiar with AA lines).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

prio:high High priority status:done Task completed successfully type:refactor Code refactoring without changing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants