Qt-parity icon button: fixed 26px square by default (the legacy Qt frontend's QToolButtons were fixed width 26; see tag legacy-qt), fontello glyph as label. `checked` (when non-null) renders the button in the active color, mirroring a checked QToolButton. `size` lets in-row callers match a neighboring widget's height (e.g. the AC editor's reset buttons beside its input fields).
| 37 | // QToolButton. `size` lets in-row callers match a neighboring widget's |
| 38 | // height (e.g. the AC editor's reset buttons beside its input fields). |
| 39 | inline bool icon_button(const char* glyph, |
| 40 | const char* tooltip, |
| 41 | const bool* checked = nullptr, |
| 42 | const ImVec2& size = ImVec2(26.0f, 26.0f)) { |
| 43 | const bool on = checked != nullptr && *checked; |
| 44 | if (on) { |
| 45 | ImGui::PushStyleColor(ImGuiCol_Button, |
| 46 | ImGui::GetStyleColorVec4(ImGuiCol_ButtonActive)); |
| 47 | } |
| 48 | const bool clicked = ImGui::Button(glyph, size); |
| 49 | if (on) { |
| 50 | ImGui::PopStyleColor(); |
| 51 | } |
| 52 | ImGui::SetItemTooltip("%s", tooltip); |
| 53 | return clicked; |
| 54 | } |
| 55 | |
| 56 | } // namespace oid::host |
| 57 |
no outgoing calls
no test coverage detected