heapcleaner

IntSpinBox

Apr 5th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.46 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include "SpinBox.h"
  4. #include "IntSpinBox.generated.h"
  5.  
  6. /**
  7.  * A numerical entry box that allows for direct entry of the number or allows the user to click and slide the number.
  8.  */
  9. UCLASS()
  10. class UIntSpinBox : public UWidget
  11. {
  12.     GENERATED_UCLASS_BODY()
  13.  
  14. public:
  15.     DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnSpinBoxValueChangedEvent, int32, InValue);
  16.     DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnSpinBoxValueCommittedEvent, int32, InValue, ETextCommit::Type, CommitMethod);
  17.     DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnSpinBoxBeginSliderMovement);
  18.  
  19. public:
  20.  
  21.     /** Value stored in this spin box */
  22.     UPROPERTY(EditAnywhere, Category=Content)
  23.     int32 Value;
  24.  
  25.     /** A bindable delegate to allow logic to drive the value of the widget */
  26.     UPROPERTY()
  27.     FGetInt32 ValueDelegate;
  28.  
  29. public:
  30.     /** The Style */
  31.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Style", meta=( DisplayName="Style" ))
  32.     FSpinBoxStyle WidgetStyle;
  33.  
  34.     UPROPERTY()
  35.     USlateWidgetStyleAsset* Style_DEPRECATED;
  36.  
  37.     /** The amount by which to change the spin box value as the slider moves. */
  38.     UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Slider")
  39.     int32 Delta;
  40.  
  41.     /** The exponent by which to increase the delta as the mouse moves. 1 is constant (never increases the delta). */
  42.     UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Slider")
  43.     int32 SliderExponent;
  44.    
  45.     /** Font color and opacity (overrides style) */
  46.     UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Display")
  47.     FSlateFontInfo Font;
  48.  
  49.     /** The minimum width of the spin box */
  50.     UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Display", AdvancedDisplay, DisplayName = "Minimum Desired Width")
  51.     int32 MinDesiredWidth;
  52.  
  53.     /** Whether to remove the keyboard focus from the spin box when the value is committed */
  54.     UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Input", AdvancedDisplay)
  55.     bool ClearKeyboardFocusOnCommit;
  56.  
  57.     /** Whether to select the text in the spin box when the value is committed */
  58.     UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Input", AdvancedDisplay)
  59.     bool SelectAllTextOnCommit;
  60.  
  61.     UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Style")
  62.     FSlateColor ForegroundColor;
  63.  
  64. public:
  65.     /** Called when the value is changed interactively by the user */
  66.     UPROPERTY(BlueprintAssignable, Category="SpinBox|Events")
  67.     FOnSpinBoxValueChangedEvent OnValueChanged;
  68.  
  69.     /** Called when the value is committed. Occurs when the user presses Enter or the text box loses focus. */
  70.     UPROPERTY(BlueprintAssignable, Category="SpinBox|Events")
  71.     FOnSpinBoxValueCommittedEvent OnValueCommitted;
  72.  
  73.     /** Called right before the slider begins to move */
  74.     UPROPERTY(BlueprintAssignable, Category="SpinBox|Events")
  75.     FOnSpinBoxBeginSliderMovement OnBeginSliderMovement;
  76.  
  77.     /** Called right after the slider handle is released by the user */
  78.     UPROPERTY(BlueprintAssignable, Category="SpinBox|Events")
  79.     FOnSpinBoxValueChangedEvent OnEndSliderMovement;
  80.  
  81. public:
  82.  
  83.     /** Get the current value of the spin box. */
  84.     UFUNCTION(BlueprintCallable, Category="Behavior")
  85.     int32 GetValue() const;
  86.  
  87.     /** Set the value of the spin box. */
  88.     UFUNCTION(BlueprintCallable, Category="Behavior")
  89.     void SetValue(int32 NewValue);
  90.  
  91. public:
  92.  
  93.     /** Get the current minimum value that can be manually set in the spin box. */
  94.     UFUNCTION(BlueprintCallable, Category="Behavior")
  95.     int32 GetMinValue() const;
  96.  
  97.     /** Set the minimum value that can be manually set in the spin box. */
  98.     UFUNCTION(BlueprintCallable, Category = "Behavior")
  99.     void SetMinValue(int32 NewValue);
  100.  
  101.     /** Clear the minimum value that can be manually set in the spin box. */
  102.     UFUNCTION(BlueprintCallable, Category = "Behavior")
  103.     void ClearMinValue();
  104.  
  105.     /** Get the current maximum value that can be manually set in the spin box. */
  106.     UFUNCTION(BlueprintCallable, Category = "Behavior")
  107.     int32 GetMaxValue() const;
  108.  
  109.     /** Set the maximum value that can be manually set in the spin box. */
  110.     UFUNCTION(BlueprintCallable, Category = "Behavior")
  111.     void SetMaxValue(int32 NewValue);
  112.  
  113.     /** Clear the maximum value that can be manually set in the spin box. */
  114.     UFUNCTION(BlueprintCallable, Category = "Behavior")
  115.     void ClearMaxValue();
  116.  
  117.     /** Get the current minimum value that can be specified using the slider. */
  118.     UFUNCTION(BlueprintCallable, Category = "Behavior")
  119.     int32 GetMinSliderValue() const;
  120.  
  121.     /** Set the minimum value that can be specified using the slider. */
  122.     UFUNCTION(BlueprintCallable, Category = "Behavior")
  123.     void SetMinSliderValue(int32 NewValue);
  124.  
  125.     /** Clear the minimum value that can be specified using the slider. */
  126.     UFUNCTION(BlueprintCallable, Category = "Behavior")
  127.     void ClearMinSliderValue();
  128.  
  129.     /** Get the current maximum value that can be specified using the slider. */
  130.     UFUNCTION(BlueprintCallable, Category = "Behavior")
  131.     int32 GetMaxSliderValue() const;
  132.  
  133.     /** Set the maximum value that can be specified using the slider. */
  134.     UFUNCTION(BlueprintCallable, Category = "Behavior")
  135.     void SetMaxSliderValue(int32 NewValue);
  136.  
  137.     /** Clear the maximum value that can be specified using the slider. */
  138.     UFUNCTION(BlueprintCallable, Category = "Behavior")
  139.     void ClearMaxSliderValue();
  140.  
  141.     /**  */
  142.     UFUNCTION(BlueprintCallable, Category = "Appearance")
  143.     void SetForegroundColor(FSlateColor InForegroundColor);
  144.  
  145. public:
  146.  
  147.     //~ Begin UWidget Interface
  148.     virtual void SynchronizeProperties() override;
  149.     //~ End UWidget Interface
  150.  
  151.     //~ Begin UVisual Interface
  152.     virtual void ReleaseSlateResources(bool bReleaseChildren) override;
  153.     //~ End UVisual Interface
  154.  
  155.     //~ Begin UObject Interface
  156.     virtual void PostLoad() override;
  157.     //~ End UObject Interface
  158.  
  159. #if WITH_EDITOR
  160.     virtual const FText GetPaletteCategory() override;
  161. #endif
  162.     //~ End UWidget Interface
  163.  
  164. protected:
  165.     //~ Begin UWidget Interface
  166.     virtual TSharedRef<SWidget> RebuildWidget() override;
  167.     // End of UWidget
  168.  
  169.     void HandleOnValueChanged(int32 InValue);
  170.     void HandleOnValueCommitted(int32 InValue, ETextCommit::Type CommitMethod);
  171.     void HandleOnBeginSliderMovement();
  172.     void HandleOnEndSliderMovement(int32 InValue);
  173.  
  174. protected:
  175.     /** Whether the optional MinValue attribute of the widget is set */
  176.     UPROPERTY()
  177.     uint32 bOverride_MinValue : 1;
  178.  
  179.     /** Whether the optional MaxValue attribute of the widget is set */
  180.     UPROPERTY()
  181.     uint32 bOverride_MaxValue : 1;
  182.  
  183.     /** Whether the optional MinSliderValue attribute of the widget is set */
  184.     UPROPERTY()
  185.     uint32 bOverride_MinSliderValue : 1;
  186.  
  187.     /** Whether the optional MaxSliderValue attribute of the widget is set */
  188.     UPROPERTY()
  189.     uint32 bOverride_MaxSliderValue : 1;
  190.  
  191.     /** The minimum allowable value that can be manually entered into the spin box */
  192.     UPROPERTY(EditAnywhere, Category = Content, DisplayName = "Minimum Value", meta = (editcondition = "bOverride_MinValue"))
  193.     int32 MinValue;
  194.  
  195.     /** The maximum allowable value that can be manually entered into the spin box */
  196.     UPROPERTY(EditAnywhere, Category = Content, DisplayName = "Maximum Value", meta = (editcondition = "bOverride_MaxValue"))
  197.     int32 MaxValue;
  198.  
  199.     /** The minimum allowable value that can be specified using the slider */
  200.     UPROPERTY(EditAnywhere, Category = Content, DisplayName = "Minimum Slider Value", meta = (editcondition = "bOverride_MinSliderValue"))
  201.     int32 MinSliderValue;
  202.  
  203.     /** The maximum allowable value that can be specified using the slider */
  204.     UPROPERTY(EditAnywhere, Category = Content, DisplayName = "Maximum Slider Value", meta = (editcondition = "bOverride_MaxSliderValue"))
  205.     int32 MaxSliderValue;
  206.  
  207. protected:
  208.     TSharedPtr<SSpinBox<int32>> MySpinBox;
  209. };
Advertisement
Add Comment
Please, Sign In to add comment