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
Fixes #1785. Adds Pos.Align
- Align sets of views horizontally or vertically
#3415
base: v2_develop
Are you sure you want to change the base?
Conversation
While this does not yet have sufficient unit tests, it is ready for review. I'm specifically looking for feedback on the API. The typical use-case where someone has a set of horizontal subviews they want justified (e.g. Button button1 = new () { Title = "Button 1", X = Pos.Justify(Justification.Center), Y = Pos.Bottom() };
Button button2 = new () { Title = "Button 2", X = Pos.Justify(Justification.Center), Y = Pos.Bottom() };
Button button3 = new () { Title = "Button 3", X = Pos.Justify(Justification.Center), Y = Pos.Bottom() };
Add (button1, button2, button3); If there are multiple groups: const int CHECKBOXGROUP = 1;
Checkbox cb1 = new () { Title = "Check 1", X = Pos.Justify(Justification.Justified, CHECKBOXGROUP), Y = 0};
Checkbox cb2 = new () { Title = "Check 2", X = Pos.Justify(Justification.Justified, CHECKBOXGROUP), Y = 0};
Checkbox cb3 = new () { Title = "Check 3", X = Pos.Justify(Justification.Justified, CHECKBOXGROUP), Y = 0};
Add (cb1, cb2, cb3);
const int BUTTONGROUP = 2;
Button button1 = new () { Title = "Button 1", X = Pos.Justify(Justification.Center, BUTTONGROUP), Y = Pos.Bottom() };
Button button2 = new () { Title = "Button 2", X = Pos.Justify(Justification.Center, BUTTONGROUP), Y = Pos.Bottom() };
Button button3 = new () { Title = "Button 3", X = Pos.Justify(Justification.Center, BUTTONGROUP), Y = Pos.Bottom() };
Add (button1, button2, button3); I'm open for suggestions for other ways to let devs have multiple sets of views that are independently justified other than the somewhat clunky "GroupID" concept. I've tried multiple things, including trying to make it automatic based on the opposite dimension, but what I have now seems to be the cleanest. |
Fixes
Pos.Align
to ease aligning subviews:Left
,Right
,Center
,Justify
#1785Proposed Changes/Todos
Pos.Justify
that automatically justifies views on the same X or Y axis with the same Justification settingGeneric
scenario.Justification
class to be an instance class that can hold all the settings, callingJustification.Justify(...)
static methodPosJustification
ScenarioJustifier
-> Add eventsPos.Justify
-> Cache locationDialog
(andMessageBox
)TextAlignment
and `VerticalTextAlignment``enums.Pull Request checklist:
CTRL-K-D
to automatically reformat your files before committing.dotnet test
before commit///
style comments)