-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Adds tab and padding panel #21058
Adds tab and padding panel #21058
Conversation
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Thanks for tackling accessibility! It's an unsexy and often overlooked part of development. Considering how large of a range and how far-reaching a change you're looking to eventually cover with this PR, it would probably make things much easier on the review team if you broke this out in a couple different PRs – your outline makes planning that pretty easy. E.g. the first PR could implement the basic concept, and extend it to one instance. This will also ensure that each building block of your eventual, complete PR will be approved at a granular level, rather than submitting the whole thing and needing to potentially revise large blocks of code to fit the ensuing review process. I'd probably recommend working on a fork in your branch until that first, building block of a PR is approaching a point where it can be reviewed. Excited to see how this turns out! |
Will navigation keys be hardcoded or will it be possible to remap them? |
A few organizational notes: |
@ZhilkinSerg Hopefully remapable. @Leland @kevingranade Ok, I've updated the goals for this PR to be something simpler. @kevingranade I'd love to have Project Features, they would be nicer than a huge checklist. |
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Scince I haven't moved anything to my panels I have zero size! High quality work here! Signed-off-by: Hal Gentz <[email protected]>
src/UIHandler.cpp
Outdated
} | ||
|
||
void UIParentPanel::addChild(UIPanel *panel) | ||
{ if (m_childPanels.size() != 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you use empty()
instead of comparing the size?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not know of the empty function, thanks.
src/UIHandler.h
Outdated
#include "cursesdef.h" | ||
#include "output.h" | ||
|
||
struct IntPair |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have a class for this. It's called point
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks once again.
src/UIHandler.cpp
Outdated
|
||
IntPair UIParentPanel::RequestedSize(bool min) | ||
{ | ||
IntPair size; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be shorter: IntPair size = { 2, 2 };
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
src/UIHandler.cpp
Outdated
size.x = 2; | ||
size.y = 2; | ||
|
||
if (m_childPanels.size() == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again: you want empty()
here.
src/UIHandler.cpp
Outdated
|
||
auto paneSize = m_childPanels[0]->RequestedSize(min); | ||
size.x += paneSize.x; | ||
size.y += paneSize.y; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point
class allows to write this in one command: size += paneSize;
src/UIHandler.h
Outdated
virtual void addChild(UIPanel *panel) = 0; | ||
virtual void removeChild(size_t index) = 0; // Passes back removed child | ||
|
||
virtual IntPair RequestedSize(bool min) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get the meaning of the parameter. bool
parameters are always suspect. It's probably better to make this a private function and have two separate public function that call it:
IntPair RequestMinSize() const { return RequestSize(true); }
IntPair RequestMaxSize() const { return RequestSize(false); }
Even better would be an enum
, because nobody will remember whether the bool means min
or max
(whether RequestSize(true)
returns the minimal size or the maximal size). Or does it return the true and the untrue size, whatever that means?
enum Foo { // find better name
MININAL, MAXIMAL
};
void RequestSize(Foo f);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter is for getting either a the minimal size or the preferred size. It probably should be an enum.
src/UIHandler.h
Outdated
{ | ||
Centered, | ||
|
||
Undefined = 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it on purpose that Undefined
and Centered
have the same value? If so, you might want to make this explicit: Undefined = Centered,
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is.
src/UIHandler.h
Outdated
UIWindow(int minSizeX, int minSizeY, Location location); | ||
int UpdateWindow(); | ||
private: | ||
UIPanel* m_panel = new UIParentPanel(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memory leak. This is never freed. That's where smart pointers help a lot.
src/UIHandler.h
Outdated
class UIPanel | ||
{ | ||
public: | ||
virtual std::vector<UIPanel*> getChild() = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and maybe other functions should be const
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First time I hear about const. You'd be correct, they should be.
src/UIHandler.h
Outdated
{ | ||
public: | ||
virtual std::vector<UIPanel*> getChild() = 0; | ||
virtual void addChild(UIPanel *panel) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here for example it's not clear who owns the panel
pointer and who is responsible for deleting it.
You could write this as void addChild( std::unique_ptr<UIPanel> panel );
, which clearly states the function will take care of the pointer (either by storing it or by deleting it).
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
src/UIHandler.h
Outdated
@@ -22,6 +22,7 @@ namespace Utils | |||
/** | |||
* Draws a border. | |||
* | |||
* <pre> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you adding HTML elements to C++ code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, for doxygen.
Without <pre> it wraps my image into three weird lines. If you add <pre> (preformated) it doesn't wrap it.
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
I've completed reformatting the code to follow the style used almost everywhere and I think I've adressed all of the stated things. Can I get reviewed more or have this pushed? |
@zegentzy can you summarize in the PR description the appreciable differences that this implements? For a good example of a PR summary, see most any of @codemime's (e.g #20003). Reviewing the code is one thing; we also want to make sure that your intended changes are implemented accurately. So if there are visible differences, screenshots would be great, and if there are supposed to be no visible differences, definitely say so as well. |
So will this just rot here for the rest of eternity? Will someone tell me how to improve this? |
51 commits, homie. Have patience, project members are thin and this is a doozie of a PR, not to mention 0.D looming. Note the dates on some other big-ish PRs =) If it's good code today, it'll be good code tomorrow and months from now if need be. |
@zegentzy Are you still contributing? |
@BorkBorkGoesTheCode I'd be willing to continue working on this project if this actually got reviewed. |
@zegentzy you can resolve merge conflicts while waiting for the review. |
Marking as Stalled. Feel free to reopen it. |
Observable Changes
Implementation details
(note: I did not change the contents of the tabs to use the new system as that needs other panels)
(note: currently the tabs don't use the tab_pane)
Adds tab and padding panel.
Ready for review.