forked from qt-creator/qt-creator
Refactor HighlightScrollBar
Rename it into HighlightScrollBarController. Don't derive it anymore from QScrollBar. Make it based on QObject and decorate the existing instance of QAbstractScrollArea as needed. Fix the highlight of the shared scrollbar of the SideBySideDiffEditor. Both left and right diff editors have their own HighlightScrollBarController and their own separate overlays, but both overlays are created as children of the same right editor instance. Synchronize also the cursor between left and right editors. Make highlight current line working. Make the overlay transparent for mouse events - this fixes issues on macOS when scolling over invisible scrollbar. Change-Id: Iab05c360173e09d8748658c59785da86438a7189 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
94
src/plugins/coreplugin/find/highlightscrollbarcontroller.h
Normal file
94
src/plugins/coreplugin/find/highlightscrollbarcontroller.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QHash>
|
||||
#include <QPointer>
|
||||
#include <QVector>
|
||||
|
||||
#include <coreplugin/core_global.h>
|
||||
#include <coreplugin/id.h>
|
||||
#include <utils/theme/theme.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAbstractScrollArea;
|
||||
class QScrollBar;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
|
||||
struct CORE_EXPORT Highlight
|
||||
{
|
||||
enum Priority {
|
||||
Invalid = -1,
|
||||
LowPriority = 0,
|
||||
NormalPriority = 1,
|
||||
HighPriority = 2,
|
||||
HighestPriority = 3
|
||||
};
|
||||
|
||||
Highlight(Id category, int position, Utils::Theme::Color color, Priority priority);
|
||||
Highlight() = default;
|
||||
|
||||
Id category;
|
||||
int position = -1;
|
||||
Utils::Theme::Color color = Utils::Theme::TextColorNormal;
|
||||
Priority priority = Invalid;
|
||||
};
|
||||
|
||||
class HighlightScrollBarOverlay;
|
||||
|
||||
class CORE_EXPORT HighlightScrollBarController
|
||||
{
|
||||
public:
|
||||
HighlightScrollBarController() = default;
|
||||
~HighlightScrollBarController();
|
||||
|
||||
QScrollBar *scrollBar() const;
|
||||
QAbstractScrollArea *scrollArea() const;
|
||||
void setScrollArea(QAbstractScrollArea *scrollArea);
|
||||
|
||||
float visibleRange() const;
|
||||
void setVisibleRange(float visibleRange);
|
||||
|
||||
float rangeOffset() const;
|
||||
void setRangeOffset(float offset);
|
||||
|
||||
QHash<Id, QVector<Highlight>> highlights() const;
|
||||
void addHighlight(Highlight highlight);
|
||||
|
||||
void removeHighlights(Id id);
|
||||
void removeAllHighlights();
|
||||
|
||||
private:
|
||||
QHash<Id, QVector<Highlight> > m_highlights;
|
||||
float m_visibleRange = 0.0;
|
||||
float m_rangeOffset = 0.0;
|
||||
QAbstractScrollArea *m_scrollArea = nullptr;
|
||||
QPointer<HighlightScrollBarOverlay> m_overlay;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
Reference in New Issue
Block a user