// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #pragma once #include #include #include #include "../widgets/SliderPlusBox.h" #include #include #include #include "../../reader/JFJochReaderImage.h" // Display toolbar: how the image is rendered — foreground (white-point) and background // (black-point) sliders, auto-contrast, HDR (full dynamic range), and the colour map; at its right // end the font size and the light/dark switch, which are also in the View menu but easy to miss there. class JFJochViewerToolbarDisplay : public QToolBar { Q_OBJECT bool auto_foreground = false; SliderPlusBox *foreground_slider; SliderPlusBox *background_slider; // The background slider is rarely needed, so it is hidden unless this toggle (View menu) is on. // A non-zero black point switches it on, so an active background is never invisible. QAction *background_label_action; QAction *background_slider_action; QAction *show_background_action; QToolButton *auto_foreground_button; QToolButton *hdr_mode_button; QComboBox *color_map_select; QButtonGroup *font_zoom_group; // three "A" buttons; the id is the zoom in per cent QToolButton *theme_button; // light/dark switch; its tooltip names the theme it switches to void UpdateThemeButton(); // A ctrl-wheel or auto-foreground burst reports a new foreground per event, and on a remote // display each slider update is a repaint of its own. Hold the readback to the remote // cadence; the tail run shows the final value. The background readback (held B + wheel) // gets the same treatment. void ApplyPendingForeground(); float pending_foreground_ = 0.0f; QElapsedTimer foreground_rate_; QTimer *foreground_tail_timer_ = nullptr; void ApplyPendingBackground(); float pending_background_ = 0.0f; QElapsedTimer background_rate_; QTimer *background_tail_timer_ = nullptr; public: JFJochViewerToolbarDisplay(QWidget *parent = nullptr); // Current display settings, for persisting them across sessions (see JFJochViewerWindow). [[nodiscard]] int colorMap() const { return color_map_select->currentIndex(); } [[nodiscard]] bool autoForeground() const { return auto_foreground_button->isChecked(); } [[nodiscard]] bool hdrMode() const { return hdr_mode_button->isChecked(); } [[nodiscard]] bool backgroundSliderShown() const { return show_background_action->isChecked(); } [[nodiscard]] QAction *backgroundSliderAction() const { return show_background_action; } signals: void setForeground(float val); void setBackground(float val); void colorMapChanged(int val); void setAutoForeground(bool val); void setHDRMode(bool val); void fontZoomSelected(int percent); public slots: void updateForeground(float val); void updateBackground(float val); void updateAutoForeground(bool val); void updateColorMap(int val); void updateHDRMode(bool val); void showBackgroundSlider(bool val); void updateFontZoom(int percent); void imageLoaded(std::shared_ptr image); private slots: void foregroundSet(double val); void backgroundSet(double val); void colorComboBoxSet(int val); void autoForegroundButtonPressed(); void HDRModeButtonPressed(); };