Files
qelectrotech-source-mirror/sources/cellruler.h
T
ispyisail 1e74bcd9de Cell rulers: no ghost labels on Windows, hidden while the folio's own header shows
The Windows 11 style gives QPalette::Button a translucent colour
(#FFFFFFB3). The rulers filled their background with it, and since they
paint with WA_OpaquePaintEvent nothing clears them first: every zoom
step blended the new labels over the old ones, leaving a fading trail.
Fill with the button colour composed over the window colour instead,
which is always opaque.

Each ruler is now also hidden while the folio's own column (or row)
header is wholly in sight, so zoomed out only the folio's headers show,
not both. When a ruler comes or goes the drawing keeps its place on
screen: the ruler covers or uncovers the edge of the viewport.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 21:06:13 +12:00

57 lines
1.6 KiB
C++

/*
Copyright 2006-2026 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CELLRULER_H
#define CELLRULER_H
#include <QWidget>
class DiagramView;
/**
@brief The CellRuler class
A bar along the top or the left edge of a DiagramView that repeats the
column numbers or the row letters of the folio border, aligned with the
cells at any zoom, so they stay in sight however far the view is
scrolled. It sits in the view's margins, outside of the scene: printing
and exporting are unaffected.
*/
class CellRuler : public QWidget
{
Q_OBJECT
public:
CellRuler(Qt::Orientation orientation, DiagramView *view);
int thickness() const;
void setLeadingSpace(int space);
protected:
void paintEvent(QPaintEvent *event) override;
private:
QColor background() const;
Qt::Orientation m_orientation;
DiagramView *m_view;
/// Pixels before the viewport starts, left empty: the corner the
/// side ruler fills when both rulers are shown.
int m_leading_space = 0;
};
#endif // CELLRULER_H