/* * Copyright (c) 2018-2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include REGISTER_WIDGET(GUI, SpinBox) namespace GUI { SpinBox::SpinBox() { set_min_width(32); set_fixed_height(22); m_editor = add(); m_editor->set_text("0"); m_editor->on_change = [this] { auto value = m_editor->text().to_uint(); if (value.has_value()) set_value(value.value()); else m_editor->set_text(String::number(m_value)); }; m_editor->on_up_pressed = [this] { set_value(m_value + 1); }; m_editor->on_down_pressed = [this] { set_value(m_value - 1); }; m_increment_button = add