Skip to content

Commit

Permalink
Merge pull request #1 from JanSeliv/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
JanSeliv authored Jun 4, 2023
2 parents 44b9734 + 591bb65 commit 4cfa8e4
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 34 deletions.
74 changes: 74 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Visual Studio 2015 user specific files
.vs/

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app
*.ipa

# These project files can be generated by the engine
*.xcodeproj
*.xcworkspace
*.sln
*.suo
*.opensdf
*.sdf
*.VC.db
*.VC.opendb

# Precompiled Assets
SourceArt/**/*.png
SourceArt/**/*.tga

# Binary Files
Binaries/*
Plugins/*/Binaries/*

# Builds
Build/*

# Whitelist PakBlacklist-<BuildConfiguration>.txt files
!Build/*/
Build/*/**
!Build/*/PakBlacklist*.txt

# Don't ignore icon files in Build
!Build/**/*.ico

# Built data for maps
*_BuiltData.uasset

# Configuration files generated by the Editor
Saved/*

# Compiled source files for the engine to use
Intermediate/*
Plugins/*/Intermediate/*

# Cache files for the editor to use
DerivedDataCache/*
Binary file modified Binaries/Win64/UnrealEditor-CustomShapeButton.dll
Binary file not shown.
Binary file modified Binaries/Win64/UnrealEditor-CustomShapeButton.pdb
Binary file not shown.
4 changes: 2 additions & 2 deletions CustomShapeButton.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"Description": "Plugin allows to have a widget button with any image you want with working hover and press behavior for its custom shapes.",
"Category": "UI",
"CreatedBy": "Yevhenii Selivanov",
"CreatedByURL": "https://github.com/JanSeliv/Bomber",
"CreatedByURL": "https://github.com/JanSeliv/CustomShapeButton",
"DocsURL": "",
"MarketplaceURL": "",
"SupportURL": "mailto:[email protected]",
"EngineVersion": "5.1.0",
"EngineVersion": "5.1",
"EnabledByDefault": true,
"CanContainContent": false,
"IsBetaVersion": false,
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Yevhenii Selivanov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Empty file added README.md
Empty file.
29 changes: 1 addition & 28 deletions Source/CustomShapeButton/Private/SCustomShapeButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ void SCustomShapeButton::SetCanHover(bool bAllow)
TryDetectOnHovered();
}

void SCustomShapeButton::Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime)
{
SButton::Tick(AllottedGeometry, InCurrentTime, InDeltaTime);

TickDetectMouseLeave(InDeltaTime);
}

FReply SCustomShapeButton::OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
UpdateMouseData(MyGeometry, MouseEvent);
Expand Down Expand Up @@ -103,10 +96,7 @@ void SCustomShapeButton::OnMouseLeave(const FPointerEvent& MouseEvent)
{
SButton::OnMouseLeave(MouseEvent);

if (!IsAlphaPixelHovered())
{
SetCanHover(false);
}
SetCanHover(false);
}

void SCustomShapeButton::OnMouseEnter(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
Expand Down Expand Up @@ -210,23 +200,6 @@ void SCustomShapeButton::TryUpdateRawColorsOnce()
});
}

// Try register leaving the button (e.g. another widget opens above)
void SCustomShapeButton::TickDetectMouseLeave(float DeltaTime)
{
if (bCanHover
&& CurrentGeometry.GetLocalSize().IsZero())
{
// Current data is zero, so widget is not hovered anymore
OnMouseLeave(CurrentMouseEvent);
}

// Reset data every tick, it will actualised during OnMouseMove
// so if data is empty, then Mouse Move did not happen
// and widget is not hovered anymore
static const FGeometry EmptyGeometry{};
CurrentGeometry = EmptyGeometry;
}

// Try register On Hovered and On Unhovered events
void SCustomShapeButton::TryDetectOnHovered()
{
Expand Down
4 changes: 0 additions & 4 deletions Source/CustomShapeButton/Public/SCustomShapeButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class CUSTOMSHAPEBUTTON_API SCustomShapeButton : public SButton
/** Contains cached information about the mouse event. */
FPointerEvent CurrentMouseEvent;

virtual void Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override;
virtual FReply OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
virtual FReply OnMouseButtonDoubleClick(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
virtual FReply OnMouseButtonUp(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
Expand All @@ -52,9 +51,6 @@ class CUSTOMSHAPEBUTTON_API SCustomShapeButton : public SButton
/** Set once on render thread the buffer data about all pixels of current texture if was not set before. */
virtual void TryUpdateRawColorsOnce();

/** Try register leaving the button (e.g. another widget opens above). */
virtual void TickDetectMouseLeave(float DeltaTime);

/** Try register On Hovered and On Unhovered events. */
virtual void TryDetectOnHovered();

Expand Down

0 comments on commit 4cfa8e4

Please sign in to comment.