Skip to content

Commit

Permalink
Add get_hash_code method
Browse files Browse the repository at this point in the history
  • Loading branch information
gammasoft71 committed Feb 11, 2025
1 parent 393d5c8 commit 5efbff4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/xtd.forms/include/xtd/forms/flat_button_appearance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 9 additions & 1 deletion src/xtd.forms/src/xtd/forms/flat_button_appearance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<flat_button_appearance>(obj) && equals(static_cast<const flat_button_appearance&>(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));
}

0 comments on commit 5efbff4

Please sign in to comment.