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

[Dev→master] ToolTip #1936

Merged
merged 6 commits into from
Apr 18, 2018
Merged

[Dev→master] ToolTip #1936

merged 6 commits into from
Apr 18, 2018

Conversation

johnppella
Copy link
Contributor

@johnppella johnppella commented Apr 10, 2018

mrtk_tooltip

Overview

Tooltips were created to provide floating text panels that are connected to a point on a gameobject and give information about the object. they can be made to appear under different conditions. The Tooltip Examples project was originally created in MRDL and was ported to MRTK_Dev branch.

Target Branch

This PR is based on Patch4_Dev branch. Target branch is may18_dev for May release.

Changes

This PR implements changes involving changing MRTK namespace features to HoloToolkit namespace features.

…, colocated properties, public enums in separate files etc.
@cre8ivepark cre8ivepark changed the title ToolTips_dev-To-master [Dev→master] ToolTip Apr 10, 2018
@cre8ivepark cre8ivepark changed the base branch from master to may18_dev April 10, 2018 16:12
TopRightCorner = 6,
TopLeftCorner = 7,
// Automatic options
Center,
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed we only define some of these enums but not all. Really only the first one is required to be zero.

suggestion: Let's make ClosestCorner = 0, as the default.

Choose a reason for hiding this comment

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

If ClosestCorner becomes 0, it will be important to also update the dev branch. otherwise apps will get an unexpected setting change when migrating

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, ClosestCorner cannot be zero because the first eight enums are fixed as indices into an array.
ClosestCorner is one of a collection of runtime-computed enum options so it has to be defined after the initial values of 0-7

/// <summary>
/// No state to have from Manager
/// </summary>
None,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit None = 0,

InFront,
}


Copy link
Contributor

Choose a reason for hiding this comment

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

extra lines.

/// </summary>
public enum ConnectorPivotDirection
{
Manual, // Direction will be specified manually
Copy link
Contributor

Choose a reason for hiding this comment

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

nit Manual = 0,

/// <summary>
/// How does the Tooltip track with its parent object
/// </summary>
public enum ConnectorFollowType
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs [Flags] attribute

/// </summary>
public enum ConnectorFollowType
{
AnchorOnly, // The anchor will follow the target - pivot remains unaffected
Copy link
Contributor

@StephenHodgson StephenHodgson Apr 10, 2018

Choose a reason for hiding this comment

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

Use bit assignments to do bitwise operations on the enum value.

Copy link
Contributor

Choose a reason for hiding this comment

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

AnchorOnly = 1<<0

public enum ConnectorFollowType
{
AnchorOnly, // The anchor will follow the target - pivot remains unaffected
PositionOnly, // Anchor and pivot will follow target position, but not rotation
Copy link
Contributor

Choose a reason for hiding this comment

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

PositionOnly = 1<<1

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's rename this to Position

{
AnchorOnly, // The anchor will follow the target - pivot remains unaffected
PositionOnly, // Anchor and pivot will follow target position, but not rotation
PositionAndYRotation, // Anchor and pivot will follow target like it's parented, but only on Y axis
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's rename this to YRotation = 1<<2

AnchorOnly, // The anchor will follow the target - pivot remains unaffected
PositionOnly, // Anchor and pivot will follow target position, but not rotation
PositionAndYRotation, // Anchor and pivot will follow target like it's parented, but only on Y axis
PositionAndRotation, // Anchor and pivot will follow target like it's parented
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's rename this to XRotation = 1<<3

Copy link
Contributor

@StephenHodgson StephenHodgson left a comment

Choose a reason for hiding this comment

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

See comments

enum names, bit shifting, remove empty lines
@@ -56,6 +56,11 @@ public ButtonStates()
public bool RaiseEventsBasedOnVisibility;
public InteractionSourceInfo SourceKind;

//Navigation Gesture Emulation vars
Vector3 NavigatorValues = Vector3.zero; //holds the navigation gesture values [-1,1]

Choose a reason for hiding this comment

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

please explicitly state visibility for class variables

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changes to this file are from previous commit(s) by other developers.
Its not part of the Tooltip commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ill make the change anyway because its clear what the effect would be.

Choose a reason for hiding this comment

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

You may wish to rebase against the may18_dev branch to eliminate files that you are not modifying. the branch was updated to "final" 2017.2.1.4 changes yesterday.

Thanks for being willing to change this, though after the rebase you may not need to :)

@@ -456,6 +480,11 @@ private void SendControllerStateEvents(float time)
else
{
InputManager.Instance.RaiseManipulationUpdated(this, controllerId, currentButtonStates.CumulativeDelta);

//Navigation Gesture Emulation
NavigatorValues.x = Mathf.Clamp(currentButtonStates.CumulativeDelta.x*5, -1.0f, 1.0f) * railUsedCurrently.x;

Choose a reason for hiding this comment

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

what is the multiply by 5 accomplishing? is this something that should be configurable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changes to this file are from previous commit(s) by other developers.
Its not part of the Tooltip commit.

Choose a reason for hiding this comment

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

You may wish to rebase against the may18_dev branch to eliminate files that you are not modifying. the branch was updated to "final" 2017.2.1.4 changes yesterday.

[Tooltip("Current State of the Button")]
public ButtonStateEnum ButtonState = ButtonStateEnum.Observation;
private ButtonStateEnum buttonState = ButtonStateEnum.Observation;

Choose a reason for hiding this comment

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

Is this the same ButtonStateEnum used by the AppBar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changes to this file are from previous commit(s) by other developers.
Its not part of the Tooltip commit.

Choose a reason for hiding this comment

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

You may wish to rebase against the may18_dev branch to eliminate files that you are not modifying. the branch was updated to "final" 2017.2.1.4 changes yesterday.

ScaleToFitContent();
}

protected abstract void ScaleToFitContent();

Choose a reason for hiding this comment

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

should a default implementation be provided?

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 overrides (tooltipBackgroundMesh, tooltipBackgroundBlob, and tooltipBackgroundCorners have such different overrides for this abstract function that it really isn't possible to make a useful virtual function with default implementation. I could change the abstract prototype to a virtual function and have it be empty but that seems like it violates the thinking behind the original design.

{
/// <summary>
/// Renders meshes at the corners of a tool tip
/// TODO implement color changes

Choose a reason for hiding this comment

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

remove this TODO in favor of a workitem issue?


[SerializeField]
private Transform Anchor;

Choose a reason for hiding this comment

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

nit: extra blank line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can you verify that you still see this extra line?


public void OnInputUp(InputEventData eventData)
{
}

Choose a reason for hiding this comment

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

recommend adding a comment to the effect of "this method intentionally left blank"


namespace HoloToolkit.UX.ToolTips
{
public static class ToolTipUtility

Choose a reason for hiding this comment

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

Please add summary block


default:
// For all other types, just use the array position
// TODO error checking for array size (?)

Choose a reason for hiding this comment

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

this TODO sounds like a good idea :)

TopRightCorner = 6,
TopLeftCorner = 7,
// Automatic options
Center,

Choose a reason for hiding this comment

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

If ClosestCorner becomes 0, it will be important to also update the dev branch. otherwise apps will get an unexpected setting change when migrating

cre8ivepark and others added 4 commits April 11, 2018 14:21
rolled back initial pushed change concerning ClosestCorner = 0 rearrangement of enum values
because first 8 enum vals are used as array indices and cannot be rearranged.
[RequireComponent(typeof(ToolTipConnector))]

/// <summary>
/// Class for Tooltip object

Choose a reason for hiding this comment

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

nit: not really needed. the following line describes the class

set
{
showBackground = value;
GetComponent<ToolTipBackgroundMesh>().IsVisible = value;

Choose a reason for hiding this comment

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

what should happen if GetComponent fails? is there a cleaner solution than a nullref exception?

set
{
showOutline = value;
GameObject TipBackground = contentParent.transform.GetChild(1).gameObject;

Choose a reason for hiding this comment

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

can the child be at an index other than 1?

{
showOutline = value;
GameObject TipBackground = contentParent.transform.GetChild(1).gameObject;
Rectangle rectangle = TipBackground.GetComponent<Rectangle>();

Choose a reason for hiding this comment

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

what should happen if GetComponent fails?

{
showConnector = value;
//todo fix this
Line lineScript = GetComponent<Line>();

Choose a reason for hiding this comment

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

what if GetComponent returns null?

toolTipText = value;
RefreshLocalContent();
if (ContentChange != null)
ContentChange.Invoke();

Choose a reason for hiding this comment

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

please wrap with { }


Transform pivotTransform = transform.Find("Pivot");
Transform anchorTransform = transform.Find("Anchor");
if (pivotTransform == null || anchorTransform == null) {

Choose a reason for hiding this comment

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

please align the {'s in these ifs

return false;
}
Transform contentParentTransform = pivotTransform.Find("ContentParent");
if (contentParentTransform == null) {

Choose a reason for hiding this comment

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

please align the {'s in these ifs

return false;
}
Transform labelTransform = contentParentTransform.Find("Label");
if (labelTransform == null) {

Choose a reason for hiding this comment

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

please align the {'s in these ifs

}

#if UNITY_EDITOR
private void OnDrawGizmos() {

Choose a reason for hiding this comment

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

please align the {'s here

break;

default:
throw new System.ArgumentOutOfRangeException("ScaleMode not set to valid enum value.");

Choose a reason for hiding this comment

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

should this ever happen?

Choose a reason for hiding this comment

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

is there a way to ensure it cannot?

@david-c-kline david-c-kline dismissed their stale review April 18, 2018 22:33

my feedback is all nit-picks....

@david-c-kline david-c-kline merged commit cb1298a into microsoft:may18_dev Apr 18, 2018
@keveleigh
Copy link
Contributor

image

I see some missing prefabs and a lot of newly generated meta files when I open this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants