-
Notifications
You must be signed in to change notification settings - Fork 445
* Changes direct usages of GUI.enabled to instead use EditorGUI.Begin… #207
* Changes direct usages of GUI.enabled to instead use EditorGUI.Begin… #207
Conversation
…DisabledGroup() / EditorGUI.EndDisabledGroup()
Hey @MunchyYDL thanks for the pull request! |
Eek, some of your changes in |
Haha ok, I actually did some changes just to make it harder for you. ;) |
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.
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.
if (busy) GUI.enabled = false; | ||
username = EditorGUILayout.TextField(usernameLabel ,username, Styles.TextFieldStyle); | ||
GUI.enabled = true; | ||
EditorGUI.BeginDisabledGroup(isBusy); |
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 can use a wider scope here.
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 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); |
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 can use a wider scope here.
GUI.enabled = !isBusy; | ||
selectedOwner = EditorGUILayout.Popup(0, owners); | ||
GUI.enabled = true; | ||
EditorGUI.BeginDisabledGroup(isBusy); |
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 can use a wider scope here.
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.
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) => | |||
{ |
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 think you accidentally re-formatted this chunk of code here, could you restore it?
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.
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) => | |||
{ |
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.
Same here.
@@ -699,7 +716,8 @@ private void Pull() | |||
// (either git rebase --abort or git merge --abort) | |||
} | |||
}, true) | |||
.FinallyInUI((success, e) => { | |||
.FinallyInUI((success, e) => | |||
{ |
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.
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) => | |||
{ |
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.
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) => | |||
{ |
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.
Same here
... Please don't hate me 🙈
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.
Haha, no worries, I understand that you want this fixed.
@StanleyGoldman: I have made some changes, can you please have a look and see if this is more in line with what you wanted? :) |
Hey @MunchyYDL sorry to leave you hanging. I will take a look at your stuff today. |
No worries @StanleyGoldman, I had some other things to work on as well. :) |
…ed-to-instead-use-editorgui-begin
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.
Looking good, a few more nit picks as we are ready to go.
GUILayout.BeginHorizontal(); | ||
{ | ||
GUILayout.FlexibleSpace(); | ||
if (GUILayout.Button(loginButton) || (GUI.enabled && enterPressed)) |
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.
Hmm, I think we have to do something about this GUI.enabled
here.
Redraw(); | ||
} | ||
|
||
if (GUILayout.Button(twofaButton) || (GUI.enabled && enterPressed)) |
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.
Same scenario here.
} | ||
EditorGUI.EndDisabledGroup(); | ||
GUI.enabled = enabled; |
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 should go away.
@@ -311,16 +311,19 @@ private void DoOfferToInitializeRepositoryGUI() | |||
GUILayout.FlexibleSpace(); | |||
|
|||
var enabled = GUI.enabled; |
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 variable should go away too,
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.csDidn'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.csWhat can I say? Well, it's gone now. :) |
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. :) |
@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. |
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! |
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 looks great! 🎉
We are happy to help... but also, you started helping first! 🍻 There are a lot of reasons why.. Mostly, we can't fix everything. Hopefully soon you'll be taking whole features off our hands.. 😈 |
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/ |
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. |
…DisabledGroup() / EditorGUI.EndDisabledGroup()
Requirements
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.
Alternate Designs
Benefits
Possible Drawbacks
Applicable Issues