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

Adds tab and padding panel #21058

Closed
wants to merge 51 commits into from
Closed

Adds tab and padding panel #21058

wants to merge 51 commits into from

Conversation

goddessfreya
Copy link
Contributor

@goddessfreya goddessfreya commented May 19, 2017

Observable Changes

  • Tab's have become slightly more compact

Implementation details

  • Moved code for handling window size and windows to ui::window
    (note: I did not change the contents of the tabs to use the new system as that needs other panels)
  • Moved code for creating tabs and choosing what goes in them to ui::tab_panel
    (note: currently the tabs don't use the tab_pane)

Adds tab and padding panel.

Ready for review.

zegentzy added 3 commits May 19, 2017 17:25
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
@Leland
Copy link
Contributor

Leland commented May 20, 2017

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!

@ZhilkinSerg
Copy link
Contributor

Will navigation keys be hardcoded or will it be possible to remap them?

@kevingranade
Copy link
Member

A few organizational notes:
Please proceed in a depth-first fashion here, i.e. implement a widget and add it to the game as a standalone pr, then create the next widget and integrate it, etc. If this ended up as one giant PR, it would be at a very high risk of never being merged.
Take a look at the projects feature, if you're interested in using it i think it would be a great fit for this project. (I'll need to grant you some permissions to do it, just let me know if you're interested)

@goddessfreya
Copy link
Contributor Author

@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.

zegentzy added 8 commits May 20, 2017 01:41
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]>
}

void UIParentPanel::addChild(UIPanel *panel)
{ if (m_childPanels.size() != 0)
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks once again.


IntPair UIParentPanel::RequestedSize(bool min)
{
IntPair size;
Copy link
Contributor

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 };

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks.

size.x = 2;
size.y = 2;

if (m_childPanels.size() == 0)
Copy link
Contributor

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.


auto paneSize = m_childPanels[0]->RequestedSize(min);
size.x += paneSize.x;
size.y += paneSize.y;
Copy link
Contributor

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;
Copy link
Contributor

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);

Copy link
Contributor Author

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,
Copy link
Contributor

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,.

Copy link
Contributor Author

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();
Copy link
Contributor

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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;
Copy link
Contributor

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).

zegentzy added 3 commits May 20, 2017 10:49
Signed-off-by: Hal Gentz <[email protected]>
Signed-off-by: Hal Gentz <[email protected]>
@Night-Pryanik Night-Pryanik changed the title [WIP] Overhualling CDDA's UI [WIP] Overhaulling CDDA's UI May 20, 2017
@goddessfreya goddessfreya changed the title [WIP] Overhaulling CDDA's UI [WIP] Adds tab and padding panel. May 21, 2017
zegentzy added 5 commits May 21, 2017 19:46
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>
Copy link
Contributor

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?

Copy link
Contributor Author

@goddessfreya goddessfreya May 22, 2017

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.

zegentzy added 8 commits May 21, 2017 20:01
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]>
@goddessfreya
Copy link
Contributor Author

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?

@Leland
Copy link
Contributor

Leland commented May 23, 2017

@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.

@goddessfreya
Copy link
Contributor Author

So will this just rot here for the rest of eternity? Will someone tell me how to improve this?

@Toothspit
Copy link
Contributor

Toothspit commented May 31, 2017

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.

@BorkBorkGoesTheCode
Copy link
Contributor

@zegentzy Are you still contributing?

@goddessfreya
Copy link
Contributor Author

@BorkBorkGoesTheCode I'd be willing to continue working on this project if this actually got reviewed.

@Night-Pryanik
Copy link
Contributor

@zegentzy you can resolve merge conflicts while waiting for the review.

@illi-kun illi-kun changed the title [RDY] Adds tab and padding panel. Adds tab and padding panel Mar 17, 2018
@ZhilkinSerg ZhilkinSerg added Info / User Interface Game - player communication, menus, etc. [C++] Changes (can be) made in C++. Previously named `Code` (P2 - High) High priority (for ex. important bugfixes) (S5 - Stalled) labels Apr 2, 2018
@ZhilkinSerg
Copy link
Contributor

Marking as Stalled. Feel free to reopen it.

@ZhilkinSerg ZhilkinSerg closed this Apr 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc. (P2 - High) High priority (for ex. important bugfixes)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants