Casting and documentation fixes (#608)

Add `-wDocumentation` option. Fix the documentation.
Fix c++20/c++17 confusion in tests.

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
Marc
2023-03-31 17:13:48 +02:00
committed by GitHub
parent eed7e2ea70
commit 896c0f2f6e
22 changed files with 96 additions and 82 deletions

View File

@@ -110,7 +110,7 @@ bool ComponentBase::OnEvent(Event event) { // NOLINT
}
/// @brief Called in response to an animation event.
/// @param animation_params the parameters of the animation
/// @param params the parameters of the animation
/// The default implementation dispatch the event to every child.
/// @ingroup component
void ComponentBase::OnAnimation(animation::Params& params) {
@@ -166,7 +166,7 @@ bool ComponentBase::Focused() const {
/// @brief Make the |child| to be the "active" one.
/// @param child the child to become active.
/// @ingroup component
void ComponentBase::SetActiveChild(ComponentBase* /*child*/) {}
void ComponentBase::SetActiveChild([[maybe_unused]] ComponentBase* child) {}
/// @brief Make the |child| to be the "active" one.
/// @param child the child to become active.
@@ -187,7 +187,7 @@ void ComponentBase::TakeFocus() {
/// @brief Take the CapturedMouse if available. There is only one component of
/// them. It represents a component taking priority over others.
/// @param event
/// @param event The event
/// @ingroup component
CapturedMouse ComponentBase::CaptureMouse(const Event& event) { // NOLINT
if (event.screen_) {

View File

@@ -96,8 +96,7 @@ MenuOption GeneratorMenuOption(const char* data, size_t size) {
MenuOption option;
option.underline = GeneratorUnderlineOption(data, size);
option.entries = GeneratorMenuEntryOption(data, size);
option.direction =
static_cast<MenuOption::Direction>(GeneratorInt(data, size) % 4);
option.direction = static_cast<Direction>(GeneratorInt(data, size) % 4);
return option;
}

View File

@@ -39,7 +39,7 @@ Component Dropdown(ConstStringListRef entries, int* selected) {
}
Element Render() override {
*selected_ = util::clamp(*selected_, 0, (int)entries_.size() - 1);
*selected_ = util::clamp(*selected_, 0, int(entries_.size()) - 1);
title_ = entries_[static_cast<size_t>(*selected_)];
if (show_) {
const int max_height = 12;

View File

@@ -26,8 +26,8 @@ void Post(std::function<void()> f) {
/// @brief Wrap a component. Gives the ability to know if it is hovered by the
/// mouse.
/// @param component: The wrapped component.
/// @param hover: The value to reflect whether the component is hovered or not.
/// @param component The wrapped component.
/// @param hover The value to reflect whether the component is hovered or not.
/// @ingroup component
///
/// ### Example
@@ -68,10 +68,10 @@ Component Hoverable(Component component, bool* hover) {
return Make<Impl>(component, hover);
}
/// @brief Wrap a component. Gives the ability to know if it is hovered by the
/// mouse.
/// @param component: The wrapped component.
/// @param hover: The value to reflect whether the component is hovered or not.
/// @brief Wrap a component. Uses callbacks.
/// @param component The wrapped component.
/// @param on_enter Callback OnEnter
/// @param on_leave Callback OnLeave
/// @ingroup component
///
/// ### Example
@@ -126,7 +126,7 @@ Component Hoverable(Component component,
/// @brief Wrap a component. Gives the ability to know if it is hovered by the
/// mouse.
/// @param hover: The value to reflect whether the component is hovered or not.
/// @param hover The value to reflect whether the component is hovered or not.
/// @ingroup component
///
/// ### Example

View File

@@ -187,7 +187,7 @@ class InputBase : public ComponentBase {
}
if (event == Event::ArrowRight &&
cursor_position() < (int)content_->size()) {
cursor_position() < static_cast<int>(content_->size())) {
cursor_position()++;
return true;
}
@@ -242,7 +242,7 @@ class InputBase : public ComponentBase {
void HandleRightCtrl() {
auto properties = Utf8ToWordBreakProperty(*content_);
const int max = (int)properties.size();
const int max = properties.size();
// Move right, as long as right is not a word character.
while (cursor_position() < max &&
@@ -280,7 +280,7 @@ class InputBase : public ComponentBase {
size_t original_cell = 0;
for (size_t i = 0; i < mapping.size(); i++) {
if (mapping[i] == original_glyph) {
original_cell = (int)i;
original_cell = i;
break;
}
}
@@ -289,8 +289,8 @@ class InputBase : public ComponentBase {
}
const int target_cell =
int(original_cell) + event.mouse().x - cursor_box_.x_min;
int target_glyph = target_cell < (int)mapping.size() ? mapping[target_cell]
: (int)mapping.size();
int target_glyph = target_cell < int(mapping.size()) ? mapping[target_cell]
: int(mapping.size());
target_glyph = util::clamp(target_glyph, 0, GlyphCount(*content_));
if (cursor_position() != target_glyph) {
cursor_position() = target_glyph;

View File

@@ -356,7 +356,7 @@ class MenuBase : public ComponentBase {
}
void UpdateColorTarget() {
if (size() != (int)animation_background_.size()) {
if (size() != int(animation_background_.size())) {
animation_background_.resize(size());
animation_foreground_.resize(size());
animator_background_.clear();
@@ -518,7 +518,7 @@ Component Menu(ConstStringListRef entries,
/// @brief An horizontal list of elements. The user can navigate through them.
/// @param entries The list of selectable entries to display.
/// @param selected Reference the selected entry.
/// @param See also |Menu|.
/// See also |Menu|.
/// @ingroup component
Component Toggle(ConstStringListRef entries, int* selected) {
return Menu(entries, selected, MenuOption::Toggle());

View File

@@ -135,7 +135,7 @@ class ResizableSplitBase : public ComponentBase {
} // namespace
/// @brief A split in between two components.
/// @param options: all the parameters.
/// @param options all the parameters.
///
/// ### Example
///

View File

@@ -309,7 +309,7 @@ Component Slider(ConstStringRef label,
}
/// @brief A slider in any direction.
/// @param option The options
/// @param options The options
/// ### Example
///
/// ```cpp

View File

@@ -51,7 +51,7 @@ unsigned char TerminalInputParser::Current() {
bool TerminalInputParser::Eat() {
position_++;
return position_ < (int)pending_.size();
return position_ < static_cast<int>(pending_.size());
}
void TerminalInputParser::Send(TerminalInputParser::Output output) {