Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

* Changes direct usages of GUI.enabled to instead use EditorGUI.Begin… #207

Merged
merged 8 commits into from
Aug 30, 2017
Merged

* Changes direct usages of GUI.enabled to instead use EditorGUI.Begin… #207

merged 8 commits into from
Aug 30, 2017

Conversation

MunchyYDL
Copy link
Contributor

…DisabledGroup() / EditorGUI.EndDisabledGroup()

Requirements

  • Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • All new code requires tests to ensure against regressions

Description of the Change

I have replaced all the possible direct usages of GUI.enabled with a corresponding set of calls to the EditorGUI.BeginDisabledGroup() and EditorGUI.EndDisabledGroup(). I have also used the code block style that I see you have used before, which places the code between the calls in a separate code block with { }, and indents the code making it easier to read.

I have also done two small other changes in this PR.

  1. Renamed the file PUblishView.cs to PublishView.cs
  2. Renamed the variable busy to isBusy in AuthenticationView.cs, to follow the naming in the other views.

Alternate Designs

Benefits

Possible Drawbacks

Applicable Issues

…DisabledGroup() / EditorGUI.EndDisabledGroup()
@StanleyGoldman
Copy link
Contributor

Hey @MunchyYDL thanks for the pull request!

@StanleyGoldman
Copy link
Contributor

StanleyGoldman commented Aug 21, 2017

Eek, some of your changes in PUblishView.cs 🤣 might conflict with some changes I have in #196.
But otherwise it's looking good initially.

@MunchyYDL
Copy link
Contributor Author

Haha ok, I actually did some changes just to make it harder for you. ;)

Copy link
Contributor

@StanleyGoldman StanleyGoldman left a comment

Choose a reason for hiding this comment

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

So what's really cool about BeginDisabledGroup/EndDisabledGroup is that you can use it to disable a whole lot of controls at the same time.

Check out what I did in this pending PR and see if you can copy what I did.

https://github.com/github-for-unity/Unity/blob/fixes/publish-view-disable-until-load/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PUblishView.cs#L138-L237

if (busy) GUI.enabled = false;
username = EditorGUILayout.TextField(usernameLabel ,username, Styles.TextFieldStyle);
GUI.enabled = true;
EditorGUI.BeginDisabledGroup(isBusy);
Copy link
Contributor

Choose a reason for hiding this comment

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

We can use a wider scope here.

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 will look at this as well, didn't want to change scope before, as I didn't know what you guys wanted.

if (busy) GUI.enabled = false;
two2fa = EditorGUILayout.TextField(twofaLabel, two2fa, Styles.TextFieldStyle);
GUI.enabled = true;
EditorGUI.BeginDisabledGroup(isBusy);
Copy link
Contributor

Choose a reason for hiding this comment

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

We can use a wider scope here.

GUI.enabled = !isBusy;
selectedOwner = EditorGUILayout.Popup(0, owners);
GUI.enabled = true;
EditorGUI.BeginDisabledGroup(isBusy);
Copy link
Contributor

Choose a reason for hiding this comment

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

We can use a wider scope here.

Copy link
Contributor

@StanleyGoldman StanleyGoldman left a comment

Choose a reason for hiding this comment

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

Sorry to be crazy about the formatting. It just makes it easier to validate the good work you did.

@@ -207,7 +207,8 @@ private void RefreshLog()
{
if (Repository != null)
{
GitClient.Log().ThenInUI((success, log) => {
GitClient.Log().ThenInUI((success, log) =>
{
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you accidentally re-formatted this chunk of code here, could you restore it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, will fix that. I use tabs for spacing normally, so I had to reformat the code after I had done my changes, and thought that you guys just had missed this piece of formatting before. I will revert it. :)

@@ -569,7 +585,8 @@ private void RevertCommit()
{
Repository
.Revert(selection.CommitID)
.FinallyInUI((success, e) => {
.FinallyInUI((success, e) =>
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

@@ -699,7 +716,8 @@ private void Pull()
// (either git rebase --abort or git merge --abort)
}
}, true)
.FinallyInUI((success, e) => {
.FinallyInUI((success, e) =>
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

@@ -722,7 +740,8 @@ private void Push()
var remote = Repository.CurrentRemote.HasValue ? Repository.CurrentRemote.Value.Name : String.Empty;
Repository
.Push()
.FinallyInUI((success, e) => {
.FinallyInUI((success, e) =>
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

@@ -744,7 +763,8 @@ private void Fetch()
var remote = Repository.CurrentRemote.HasValue ? Repository.CurrentRemote.Value.Name : String.Empty;
Repository
.Fetch()
.FinallyInUI((success, e) => {
.FinallyInUI((success, e) =>
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here :trollface:

... Please don't hate me 🙈

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haha, no worries, I understand that you want this fixed.

@MunchyYDL
Copy link
Contributor Author

MunchyYDL commented Aug 23, 2017

@StanleyGoldman: I have made some changes, can you please have a look and see if this is more in line with what you wanted? :)

@StanleyGoldman
Copy link
Contributor

StanleyGoldman commented Aug 28, 2017

Hey @MunchyYDL sorry to leave you hanging. I will take a look at your stuff today.

@MunchyYDL
Copy link
Contributor Author

No worries @StanleyGoldman, I had some other things to work on as well. :)

Copy link
Contributor

@StanleyGoldman StanleyGoldman left a comment

Choose a reason for hiding this comment

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

Looking good, a few more nit picks as we are ready to go.

GUILayout.BeginHorizontal();
{
GUILayout.FlexibleSpace();
if (GUILayout.Button(loginButton) || (GUI.enabled && enterPressed))
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I think we have to do something about this GUI.enabled here.

Redraw();
}

if (GUILayout.Button(twofaButton) || (GUI.enabled && enterPressed))
Copy link
Contributor

Choose a reason for hiding this comment

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

Same scenario here.

}
EditorGUI.EndDisabledGroup();
GUI.enabled = enabled;
Copy link
Contributor

Choose a reason for hiding this comment

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

This should go away.

@@ -311,16 +311,19 @@ private void DoOfferToInitializeRepositoryGUI()
GUILayout.FlexibleSpace();

var enabled = GUI.enabled;
Copy link
Contributor

Choose a reason for hiding this comment

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

This variable should go away too,

@MunchyYDL
Copy link
Contributor Author

So, now I had some time to look at this again!

Wasn't aware of you pushing to my repo, I hope that doesn't mess up anything about the history in my branch, as I didn't notice it before I had done my last commit locally. :)

AuthenticationView.cs

Didn't think this through I guess, but now I have replaced GUI.enabled with a check for !isBusy, to prevent multiple invocations of the button handlers in both the "Normal" and "2FA" login code.

HistoryView.cs

What can I say? Well, it's gone now. :)

@MunchyYDL
Copy link
Contributor Author

Oh, and one more thing, what's the difference of the two appveyor checks?

As you can see, I'm a bit new to this whole PR thing, so I hope I'm not giving you too much trouble in "helping" you guys with this. :)

@shana
Copy link
Member

shana commented Aug 29, 2017

@MunchyYDL One of the builds is for your branch, and the other is for your branch merged with the target branch (master in this case). Since your branch is in a forked repo, AppVeyor isn't running a build for it, and it only does the combined branch+master build. I just can't convince the UI to ignore this check if the branch is on a fork so it makes for a bit of confusing status checks, but it isn't a problem.

@shana
Copy link
Member

shana commented Aug 29, 2017

Wasn't aware of you pushing to my repo, I hope that doesn't mess up anything about the history in my branch, as I didn't notice it before I had done my last commit locally. :)

Ah, yeah, sorry, that's just a thing we're used to doing, updating branches with the latest master so it's all up to date, it's kind of routine for all branches (they can't be merged if they're not up to date), but we shouldn't do it for branches we don't own without letting you know first (and preferably you do it, not us). I hope that didn't cause any issues on your end!

Copy link
Member

@shana shana left a comment

Choose a reason for hiding this comment

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

This looks great! 🎉

@StanleyGoldman
Copy link
Contributor

We are happy to help... but also, you started helping first! 🍻

There are a lot of reasons why.. Mostly, we can't fix everything.
And this time you are doing something simple, next time it will be a bit harder.

Hopefully soon you'll be taking whole features off our hands.. 😈

@StanleyGoldman
Copy link
Contributor

FYI, there is a checkbox when you were creating the pull request that allows us to push just to that branch in your fork.

https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/

@StanleyGoldman StanleyGoldman merged commit 784d624 into github-for-unity:master Aug 30, 2017
@MunchyYDL
Copy link
Contributor Author

Thanks for your help and nice comments!

I've been using both Git and Unity before, so I thought this project was a nice combination to help me further my understanding of both, and be able to submit my first PR to an open project.

@MunchyYDL MunchyYDL deleted the fixes/gui_enabled branch August 30, 2017 15:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants