SExtDocumentationToolTip.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. // Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
  2. #pragma once
  3. #include "CoreMinimal.h"
  4. #include "Misc/Attribute.h"
  5. #include "Styling/SlateColor.h"
  6. #include "Input/Reply.h"
  7. #include "Layout/Margin.h"
  8. #include "Widgets/DeclarativeSyntaxSupport.h"
  9. #include "Widgets/SCompoundWidget.h"
  10. #include "Styling/SlateTypes.h"
  11. class IDocumentationPage;
  12. class SBox;
  13. class SVerticalBox;
  14. #include "DocumentationDefines.h"
  15. namespace EXT_DOC_NAMESPACE
  16. {
  17. class SExtDocumentationToolTip : public SCompoundWidget
  18. {
  19. public:
  20. SLATE_BEGIN_ARGS(SExtDocumentationToolTip)
  21. : _Text()
  22. , _Style(TEXT("Documentation.SDocumentationToolTip"))
  23. , _SubduedStyle(TEXT("Documentation.SDocumentationToolTipSubdued"))
  24. , _HyperlinkTextStyle(TEXT("Documentation.SDocumentationToolTipHyperlinkText"))
  25. , _HyperlinkButtonStyle(TEXT("Documentation.SDocumentationToolTipHyperlinkButton"))
  26. , _ColorAndOpacity(FLinearColor::Black)
  27. , _AddDocumentation(true)
  28. , _DocumentationMargin(0)
  29. , _AlwaysShowFullToolTip(false)
  30. , _Content()
  31. {}
  32. /** The text displayed in this tool tip */
  33. SLATE_ATTRIBUTE(FText, Text)
  34. /** The text style to use for this tool tip */
  35. SLATE_ARGUMENT(FName, Style)
  36. /** The text style to use for subdued footer text in this tool tip */
  37. SLATE_ARGUMENT(FName, SubduedStyle)
  38. /** The text style to use for hyperlinks in this tool tip */
  39. SLATE_ARGUMENT(FName, HyperlinkTextStyle)
  40. /** Hyperlink button style */
  41. SLATE_ARGUMENT(FName, HyperlinkButtonStyle)
  42. /** Font color and opacity */
  43. SLATE_ATTRIBUTE(FSlateColor, ColorAndOpacity)
  44. /** */
  45. SLATE_ARGUMENT(bool, AddDocumentation)
  46. SLATE_ARGUMENT(FMargin, DocumentationMargin)
  47. /** */
  48. SLATE_ARGUMENT(FString, DocumentationLink)
  49. /** */
  50. SLATE_ARGUMENT(FString, ExcerptName)
  51. /** */
  52. SLATE_ARGUMENT(bool, AlwaysShowFullToolTip)
  53. /** Arbitrary content to be displayed in the tool tip; overrides any text that may be set. */
  54. SLATE_DEFAULT_SLOT(FArguments, Content)
  55. SLATE_END_ARGS()
  56. /**
  57. * Construct this widget
  58. *
  59. * @param InArgs The declaration data for this widget
  60. */
  61. void Construct(const FArguments& InArgs);
  62. void Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime);
  63. bool IsInteractive() const;
  64. virtual const FText& GetTextTooltip() const
  65. {
  66. return TextContent.Get();
  67. }
  68. /**
  69. * Adds slots to the provided Vertical Box containing the documentation information.
  70. * If you specify not to add it (AddDocumentation = false) you may call this externally to do custom tooltip layout
  71. *
  72. * @param VerticalBox The vertical box to add it to
  73. */
  74. void AddDocumentation(TSharedPtr< SVerticalBox > VerticalBox);
  75. TSharedPtr< IDocumentationPage > GetDocumentationPage() { ReloadDocumentation(); return DocumentationPage; }
  76. TSharedPtr< SWidget > GetFullTipContent() { ReloadDocumentation(); return FullTipContent; }
  77. private:
  78. void ConstructSimpleTipContent();
  79. void ConstructFullTipContent();
  80. FReply ReloadDocumentation();
  81. void CreateExcerpt(FString FileSource, FString ExcerptName);
  82. private:
  83. /** Text block widget */
  84. TAttribute< FText > TextContent;
  85. TSharedPtr< SWidget > OverrideContent;
  86. FTextBlockStyle StyleInfo;
  87. FTextBlockStyle SubduedStyleInfo;
  88. FTextBlockStyle HyperlinkTextStyleInfo;
  89. FButtonStyle HyperlinkButtonStyleInfo;
  90. TAttribute< FSlateColor > ColorAndOpacity;
  91. /** The link to the documentation */
  92. FString DocumentationLink;
  93. FString ExcerptName;
  94. bool AlwaysShowFullToolTip;
  95. /** Content widget */
  96. TSharedPtr< SBox > WidgetContent;
  97. TSharedPtr< SWidget > SimpleTipContent;
  98. bool IsDisplayingDocumentationLink;
  99. TSharedPtr< SWidget > FullTipContent;
  100. TSharedPtr< IDocumentationPage > DocumentationPage;
  101. bool IsShowingFullTip;
  102. bool bAddDocumentation;
  103. FMargin DocumentationMargin;
  104. };
  105. }