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

Conversation

@StanleyGoldman
Copy link
Contributor

No description provided.

popupWindow.Initialize(EntryPoint.ApplicationManager);
}

[SerializeField] private PopupView activePopupView;
Copy link
Member

Choose a reason for hiding this comment

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

Fields go on top. See resharper layout file for ordering

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍


[NonSerialized] private Subview activeSubview;

public Subview ActiveSubview
Copy link
Member

Choose a reason for hiding this comment

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

A getter that sets values is confusing, and ActiveSubview/ActivePopupView isn't really clear about what is what. If we switch views by setting the enum value, then probably best to set the view there immediately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

using UnityEngine;

namespace GitHub.Unity
{
Copy link
Member

Choose a reason for hiding this comment

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

The casing of this file needs fixing, btw, probably a good time to do 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.

The private const fields?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

{
AuthenticationWindow.Open();
var popupWindow = (PopupWindow) PopupWindow.Open(PopupWindow.PopupView.AuthenticationView);
popupWindow.Initialize(EntryPoint.ApplicationManager);
Copy link
Member

Choose a reason for hiding this comment

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

You want to call InitializeWindow, not Initialize here. Check ApplicationManager.cs for how it does that for the other window. Also probably cast to BaseWindow here, or add a IWindow for it so we don't have to cast.

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 was looking at it a bit more, I was returning IView out of copy-pasting older code, since there is now only one type of popup being PopupWindow, I figured the easiest thing to do is return PopupWindow from the Open method.

@shana shana force-pushed the fixes/popup-window-refactor branch from 8e4a470 to 3bbb2e1 Compare August 18, 2017 17:40
{
var popupWindow = GetWindow<PopupWindow>(true);
if (onClose != null)
{
Copy link
Member

Choose a reason for hiding this comment

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

So the thing with the GetWindow method is that it'll return an existing window if there's one already. That means that we need to decide whether we need to reset the window and how. If there's another thing waiting for the close callback. we need to make sure it gets closure on it, probably by having the window shut itself down with onClose(false) and then resetting all the data and state.

This Open method should probably do all the work, including calling InitializeWindow (which is currently being called in Launch above. The PopupWindow class could probably use a Reset method to cancel any callbacks and clear all data before anything else, which it can probably do in it's InitializeWindow implementation.

InitializeWindow should probably also be called before calling show on the window, right now it's the other way around.

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 Open and InitializeWindow stuff was no problem...

I made RaiseOnClose virtual and calling a method to clear the OnClose handler In the PopupWindow override.

protected override void RaiseOnClose(bool result)
{
base.RaiseOnClose(result);
ClearOnClose();
}

}

protected void RaiseOnClose(bool result)
protected virtual void RaiseOnClose(bool result)
Copy link
Member

Choose a reason for hiding this comment

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

The override is just calling ClearOnClose to clear the callback, and that method is defined here and should always be called after OnClose is invoked, so shouldn't we just call it right here instead of making this a virtual and requiring all subclasses to remember to call a magic method?

Copy link
Member

Choose a reason for hiding this comment

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

TL;DR: ClearOnClose should be called directly from RaiseOnClose so that subclasses don't accidentally forget to do it. That means this method doesn't need to be virtual.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only a PopupWindow should need to ClearOnClose clearing the OnClose handler is generally new functionality that BaseWindow has never had/needed.

If i had a choice about the matter, I wouldn't have put ClearOnClose in BaseWindow. Even though the event is public you just can't set an event to null in a subclass so i was forced to define ClearOnClose there.

# Conflicts:
#	src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationView.cs
#	src/UnityExtension/Assets/Editor/GitHub.Unity/UI/HistoryView.cs
@StanleyGoldman StanleyGoldman merged commit 7294e09 into master Sep 6, 2017
@StanleyGoldman StanleyGoldman deleted the fixes/popup-window-refactor branch September 6, 2017 16:56
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