From 5efbff404365e71a191b4264db71543bc2131901 Mon Sep 17 00:00:00 2001 From: Gammasoft Date: Tue, 11 Feb 2025 13:52:09 +0100 Subject: [PATCH] Add get_hash_code method --- .../include/xtd/forms/flat_button_appearance.hpp | 12 +++++++++++- .../src/xtd/forms/flat_button_appearance.cpp | 10 +++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/xtd.forms/include/xtd/forms/flat_button_appearance.hpp b/src/xtd.forms/include/xtd/forms/flat_button_appearance.hpp index 2661c4146b10..9708287bd1eb 100644 --- a/src/xtd.forms/include/xtd/forms/flat_button_appearance.hpp +++ b/src/xtd.forms/include/xtd/forms/flat_button_appearance.hpp @@ -117,8 +117,18 @@ namespace xtd { /// @name Public Methods /// @{ - using object::equals; + /// @brief Determines whether the specified object is equal to the current object. + /// @param obj The object to compare with the current object. + /// @return `true` if the specified object is equal to the current object. otherwise, `false`. + bool equals(const xtd::object& obj) const noexcept override; + /// @brief Determines whether the specified object is equal to the current object. + /// @param other The object to compare with the current object. + /// @return `true` if the specified object is equal to the current object. otherwise, `false`. bool equals(const flat_button_appearance& other) const noexcept override; + + /// @brief Serves as a hash function for a particular type. + /// @return A hash code for the current object. + xtd::size get_hash_code() const noexcept override; /// @} private: diff --git a/src/xtd.forms/src/xtd/forms/flat_button_appearance.cpp b/src/xtd.forms/src/xtd/forms/flat_button_appearance.cpp index 508f2c15a626..d06611b9cc4c 100644 --- a/src/xtd.forms/src/xtd/forms/flat_button_appearance.cpp +++ b/src/xtd.forms/src/xtd/forms/flat_button_appearance.cpp @@ -108,6 +108,14 @@ flat_button_appearance& flat_button_appearance::mouse_over_back_color(std::nullp return *this; } +bool flat_button_appearance::equals(const object& obj) const noexcept { + return is(obj) && equals(static_cast(obj)); +} + bool flat_button_appearance::equals(const flat_button_appearance& other) const noexcept { - return data_->border_color == other.data_->border_color && data_->border_size == other.data_->border_size && data_->checked_back_color == other.data_->checked_back_color && data_->mouse_down_back_color == other.data_->mouse_down_back_color && data_->mouse_over_back_color == other.data_->mouse_over_back_color; + return data_->border_color == other.data_->border_color && data_->border_radius == other.data_->border_radius && data_->border_size == other.data_->border_size && data_->checked_back_color == other.data_->checked_back_color && data_->mouse_down_back_color == other.data_->mouse_down_back_color && data_->mouse_over_back_color == other.data_->mouse_over_back_color; +} + +xtd::size flat_button_appearance::get_hash_code() const noexcept { + return hash_code::combine(data_->border_color.value_or(drawing::color::empty), data_->border_radius.value_or(0), data_->border_size.value_or(0), data_->checked_back_color.value_or(drawing::color::empty), data_->mouse_down_back_color.value_or(drawing::color::empty), data_->mouse_over_back_color.value_or(drawing::color::empty)); }