From fbfea917cb5d30695c530c8f5dde68c282339720 Mon Sep 17 00:00:00 2001 From: gucio321 <73652197+gucio321@users.noreply.github.com> Date: Sat, 19 Dec 2020 21:28:07 +0100 Subject: [PATCH] added static checks to d2ui (#990) Co-authored-by: M. Sz --- d2core/d2ui/button.go | 3 ++- d2core/d2ui/checkbox.go | 4 ++-- d2core/d2ui/label.go | 3 +++ d2core/d2ui/scrollbar.go | 4 ++-- d2core/d2ui/sprite.go | 3 +++ d2core/d2ui/textbox.go | 4 ++-- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/d2core/d2ui/button.go b/d2core/d2ui/button.go index b558969a..91bd8437 100644 --- a/d2core/d2ui/button.go +++ b/d2core/d2ui/button.go @@ -768,7 +768,8 @@ func getButtonLayouts() map[ButtonType]ButtonLayout { } } -var _ Widget = &Button{} // static check to ensure button implements widget +// static check to ensure button implements clickable widget +var _ ClickableWidget = &Button{} // Button defines a standard wide UI button type Button struct { diff --git a/d2core/d2ui/checkbox.go b/d2core/d2ui/checkbox.go index c91bccbe..84984764 100644 --- a/d2core/d2ui/checkbox.go +++ b/d2core/d2ui/checkbox.go @@ -6,8 +6,8 @@ import ( "github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource" ) -// static check that Checkbox implements Widget -var _ Widget = &Checkbox{} +// static check that Checkbox implements ClickableWidget +var _ ClickableWidget = &Checkbox{} // Checkbox represents a checkbox UI element type Checkbox struct { diff --git a/d2core/d2ui/label.go b/d2core/d2ui/label.go index 9c5c53dd..3dda47fd 100644 --- a/d2core/d2ui/label.go +++ b/d2core/d2ui/label.go @@ -11,6 +11,9 @@ import ( "github.com/OpenDiablo2/OpenDiablo2/d2common/d2util" ) +// static check if Label implemented Widget +var _ Widget = &Label{} + // Label represents a user interface label type Label struct { *BaseWidget diff --git a/d2core/d2ui/scrollbar.go b/d2core/d2ui/scrollbar.go index db41da5d..ba832019 100644 --- a/d2core/d2ui/scrollbar.go +++ b/d2core/d2ui/scrollbar.go @@ -13,8 +13,8 @@ const ( scrollbarWidth = 10 ) -// static check that Scrollbar implements widget -var _ Widget = &Scrollbar{} +// static check that Scrollbar implements clickable widget +var _ ClickableWidget = &Scrollbar{} // Scrollbar is a vertical slider ui element type Scrollbar struct { diff --git a/d2core/d2ui/sprite.go b/d2core/d2ui/sprite.go index ba2a369d..ed382ec8 100644 --- a/d2core/d2ui/sprite.go +++ b/d2core/d2ui/sprite.go @@ -11,6 +11,9 @@ import ( "github.com/OpenDiablo2/OpenDiablo2/d2common/d2util" ) +// static check if Sprite implemented Widget +var _ Widget = &Sprite{} + // Sprite is a positioned visual object. type Sprite struct { *BaseWidget diff --git a/d2core/d2ui/textbox.go b/d2core/d2ui/textbox.go index 9a874024..20ab092b 100644 --- a/d2core/d2ui/textbox.go +++ b/d2core/d2ui/textbox.go @@ -11,8 +11,8 @@ import ( "github.com/OpenDiablo2/OpenDiablo2/d2common/d2util" ) -// static check that TextBox implements widget -var _ Widget = &TextBox{} +// static check that TextBox implements clickable widget +var _ ClickableWidget = &TextBox{} // TextBox represents a text input box type TextBox struct {