KiCad PCB EDA Suite
Loading...
Searching...
No Matches
git_file_diff_area.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef GIT_FILE_DIFF_AREA_H
21#define GIT_FILE_DIFF_AREA_H
22
23#include <functional>
24#include <memory>
25
26#include <wx/panel.h>
27
31#include <git/text_diff.h>
32
33class EDA_BASE_FRAME;
35class wxSplitterWindow;
36class wxStaticText;
37class wxStyledTextCtrl;
38
39namespace KICAD_DIFF
40{
42}
43
44
49class GIT_FILE_DIFF_AREA : public wxPanel
50{
51public:
52 GIT_FILE_DIFF_AREA( wxWindow* aParent, EDA_BASE_FRAME* aFrame );
53 ~GIT_FILE_DIFF_AREA() override;
54
57 using MATERIALIZE = std::function<bool( KIGIT_COMMON&, GIT_DIFF_WORKSPACE&, GIT_FILE_SIDES& )>;
58
60 void ShowFile( const std::shared_ptr<KIGIT_COMMON>& aSession, const MATERIALIZE& aMaterialize,
61 const wxString& aBeforeLabel, const wxString& aAfterLabel );
62
64 void Clear();
65
66private:
67 void showNote( const wxString& aNote );
68 void showDiff( const GIT_FILE_SIDES& aSides, const std::vector<KIGIT::TEXT_DIFF_LINE>& aTextLines,
69 const wxString& aBeforeLabel, const wxString& aAfterLabel );
70 void showTextDiff( const std::vector<KIGIT::TEXT_DIFF_LINE>& aLines );
71 bool showDrawingDiff( KICAD_DIFF::DOC_KIND aKind, const wxString& aBefore, const wxString& aAfter,
72 const wxString& aBeforeLabel, const wxString& aAfterLabel );
73
76 void ensureCanvases();
77 void destroyCanvases();
78
80 void followCanvas( WIDGET_DIFF_CANVAS* aLead, WIDGET_DIFF_CANVAS* aFollower );
81
83 wxStaticText* m_note;
84 wxSplitterWindow* m_canvasSplitter;
85 wxStaticText* m_beforeLabel;
86 wxStaticText* m_afterLabel;
89 wxStyledTextCtrl* m_textDiff;
90 wxSizer* m_legend;
91
94
97 std::unique_ptr<KICAD_DIFF::DIFF_CANVAS_CONTEXT> m_diffContext;
98};
99
100#endif // GIT_FILE_DIFF_AREA_H
The base frame for deriving all KiCad main window classes.
A private scratch directory for extracting committed file versions to diff, removed when this object ...
std::function< bool(KIGIT_COMMON &, GIT_DIFF_WORKSPACE &, GIT_FILE_SIDES &)> MATERIALIZE
Writes the two sides on a worker with the session's action lock held.
wxStyledTextCtrl * m_textDiff
KIGIT_QUERY m_query
A newer file selection discards any materialization still running for the previous one.
void showDiff(const GIT_FILE_SIDES &aSides, const std::vector< KIGIT::TEXT_DIFF_LINE > &aTextLines, const wxString &aBeforeLabel, const wxString &aAfterLabel)
GIT_FILE_DIFF_AREA(wxWindow *aParent, EDA_BASE_FRAME *aFrame)
void followCanvas(WIDGET_DIFF_CANVAS *aLead, WIDGET_DIFF_CANVAS *aFollower)
Give aFollower the view of aLead, so panning or zooming one moves both.
bool showDrawingDiff(KICAD_DIFF::DOC_KIND aKind, const wxString &aBefore, const wxString &aAfter, const wxString &aBeforeLabel, const wxString &aAfterLabel)
void showTextDiff(const std::vector< KIGIT::TEXT_DIFF_LINE > &aLines)
std::unique_ptr< KICAD_DIFF::DIFF_CANVAS_CONTEXT > m_diffContext
The documents the two canvases draw, held by the kiface that loaded them.
WIDGET_DIFF_CANVAS * m_afterCanvas
wxStaticText * m_beforeLabel
wxSplitterWindow * m_canvasSplitter
void ShowFile(const std::shared_ptr< KIGIT_COMMON > &aSession, const MATERIALIZE &aMaterialize, const wxString &aBeforeLabel, const wxString &aAfterLabel)
Compare the two sides aMaterialize writes out, or show its reason instead.
EDA_BASE_FRAME * m_frame
void showNote(const wxString &aNote)
void ensureCanvases()
The two drawing canvases exist only while a drawing is compared.
WIDGET_DIFF_CANVAS * m_beforeCanvas
wxStaticText * m_afterLabel
void Clear()
Drop the documents and the drawing canvases.
Keeps the documents drawn on a pair of diff canvases alive.
The project's git session.
Read repository state without blocking the UI.
GAL-backed canvas for visualizing a KICAD_DIFF::DIFF_SCENE.
DOC_KIND
Document type a diff/merge entry point should route to, derived from a file path's extension.
The two sides of one file, written out for a comparison.