KiCad PCB EDA Suite
Loading...
Searching...
No Matches
GIT_FILE_DIFF_AREA Class Reference

Shows what changed in one file: the old and new drawing side by side for a schematic or board, a line diff for a text file, or a note when there is nothing to compare. More...

#include <git_file_diff_area.h>

Inheritance diagram for GIT_FILE_DIFF_AREA:

Public Types

using MATERIALIZE = std::function<bool( KIGIT_COMMON&, GIT_DIFF_WORKSPACE&, GIT_FILE_SIDES& )>
 Writes the two sides on a worker with the session's action lock held.
 

Public Member Functions

 GIT_FILE_DIFF_AREA (wxWindow *aParent, EDA_BASE_FRAME *aFrame)
 
 ~GIT_FILE_DIFF_AREA () override
 
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.
 
void Clear ()
 Drop the documents and the drawing canvases.
 

Private Member Functions

void showNote (const wxString &aNote)
 
void showDiff (const GIT_FILE_SIDES &aSides, const std::vector< KIGIT::TEXT_DIFF_LINE > &aTextLines, const wxString &aBeforeLabel, const wxString &aAfterLabel)
 
void showTextDiff (const std::vector< KIGIT::TEXT_DIFF_LINE > &aLines)
 
bool showDrawingDiff (KICAD_DIFF::DOC_KIND aKind, const wxString &aBefore, const wxString &aAfter, const wxString &aBeforeLabel, const wxString &aAfterLabel)
 
void ensureCanvases ()
 The two drawing canvases exist only while a drawing is compared.
 
void destroyCanvases ()
 
void followCanvas (WIDGET_DIFF_CANVAS *aLead, WIDGET_DIFF_CANVAS *aFollower)
 Give aFollower the view of aLead, so panning or zooming one moves both.
 

Private Attributes

EDA_BASE_FRAME * m_frame
 
wxStaticText * m_note
 
wxSplitterWindow * m_canvasSplitter
 
wxStaticText * m_beforeLabel
 
wxStaticText * m_afterLabel
 
WIDGET_DIFF_CANVAS * m_beforeCanvas
 
WIDGET_DIFF_CANVAS * m_afterCanvas
 
wxStyledTextCtrl * m_textDiff
 
wxSizer * m_legend
 
KIGIT_QUERY m_query
 A newer file selection discards any materialization still running for the previous one.
 
std::unique_ptr< KICAD_DIFF::DIFF_CANVAS_CONTEXT > m_diffContext
 The documents the two canvases draw, held by the kiface that loaded them.
 

Detailed Description

Shows what changed in one file: the old and new drawing side by side for a schematic or board, a line diff for a text file, or a note when there is nothing to compare.

Definition at line 49 of file git_file_diff_area.h.

Member Typedef Documentation

◆ MATERIALIZE

Writes the two sides on a worker with the session's action lock held.

Captures must not refer to widgets, frames or the project, which belong to the UI thread.

Definition at line 57 of file git_file_diff_area.h.

Constructor & Destructor Documentation

◆ GIT_FILE_DIFF_AREA()

◆ ~GIT_FILE_DIFF_AREA()

GIT_FILE_DIFF_AREA::~GIT_FILE_DIFF_AREA ( )
override

Definition at line 144 of file git_file_diff_area.cpp.

References m_diffContext, and m_query.

Member Function Documentation

◆ Clear()

void GIT_FILE_DIFF_AREA::Clear ( )

Drop the documents and the drawing canvases.

Definition at line 153 of file git_file_diff_area.cpp.

References destroyCanvases(), and m_query.

◆ destroyCanvases()

void GIT_FILE_DIFF_AREA::destroyCanvases ( )
private

◆ ensureCanvases()

void GIT_FILE_DIFF_AREA::ensureCanvases ( )
private

The two drawing canvases exist only while a drawing is compared.

Each holds a GAL context, and a hidden one still paints over the text diff on macOS.

Definition at line 302 of file git_file_diff_area.cpp.

References followCanvas(), EDA_DRAW_PANEL_GAL::GAL_FALLBACK, m_afterCanvas, m_afterLabel, m_beforeCanvas, m_beforeLabel, m_canvasSplitter, and m_frame.

Referenced by showDrawingDiff().

◆ followCanvas()

void GIT_FILE_DIFF_AREA::followCanvas ( WIDGET_DIFF_CANVAS * aLead,
WIDGET_DIFF_CANVAS * aFollower )
private

Give aFollower the view of aLead, so panning or zooming one moves both.

Definition at line 364 of file git_file_diff_area.cpp.

References KIGFX::VIEW::GetCenter(), KIGFX::VIEW::GetScale(), EDA_DRAW_PANEL_GAL::GetView(), m_afterCanvas, m_beforeCanvas, EDA_DRAW_PANEL_GAL::Refresh(), KIGFX::VIEW::SetCenter(), and KIGFX::VIEW::SetScale().

Referenced by ensureCanvases().

◆ showDiff()

void GIT_FILE_DIFF_AREA::showDiff ( const GIT_FILE_SIDES & aSides,
const std::vector< KIGIT::TEXT_DIFF_LINE > & aTextLines,
const wxString & aBeforeLabel,
const wxString & aAfterLabel )
private

◆ showDrawingDiff()

bool GIT_FILE_DIFF_AREA::showDrawingDiff ( KICAD_DIFF::DOC_KIND aKind,
const wxString & aBefore,
const wxString & aAfter,
const wxString & aBeforeLabel,
const wxString & aAfterLabel )
private

◆ ShowFile()

void GIT_FILE_DIFF_AREA::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.

Definition at line 160 of file git_file_diff_area.cpp.

References _, KIGIT::BuildTextDiff(), m_frame, m_query, result, showDiff(), showNote(), KIGIT::SplitTextLines(), KIGIT::TextLooksBinary(), and KICAD_DIFF::UNKNOWN.

◆ showNote()

void GIT_FILE_DIFF_AREA::showNote ( const wxString & aNote)
private

Definition at line 217 of file git_file_diff_area.cpp.

References destroyCanvases(), m_canvasSplitter, m_legend, m_note, and m_textDiff.

Referenced by showDiff(), showDrawingDiff(), and ShowFile().

◆ showTextDiff()

void GIT_FILE_DIFF_AREA::showTextDiff ( const std::vector< KIGIT::TEXT_DIFF_LINE > & aLines)
private

Member Data Documentation

◆ m_afterCanvas

WIDGET_DIFF_CANVAS* GIT_FILE_DIFF_AREA::m_afterCanvas
private

◆ m_afterLabel

wxStaticText* GIT_FILE_DIFF_AREA::m_afterLabel
private

◆ m_beforeCanvas

WIDGET_DIFF_CANVAS* GIT_FILE_DIFF_AREA::m_beforeCanvas
private

◆ m_beforeLabel

wxStaticText* GIT_FILE_DIFF_AREA::m_beforeLabel
private

◆ m_canvasSplitter

wxSplitterWindow* GIT_FILE_DIFF_AREA::m_canvasSplitter
private

◆ m_diffContext

std::unique_ptr<KICAD_DIFF::DIFF_CANVAS_CONTEXT> GIT_FILE_DIFF_AREA::m_diffContext
private

The documents the two canvases draw, held by the kiface that loaded them.

Reset before the canvases go.

Definition at line 97 of file git_file_diff_area.h.

Referenced by destroyCanvases(), showDrawingDiff(), and ~GIT_FILE_DIFF_AREA().

◆ m_frame

EDA_BASE_FRAME* GIT_FILE_DIFF_AREA::m_frame
private

Definition at line 82 of file git_file_diff_area.h.

Referenced by ensureCanvases(), GIT_FILE_DIFF_AREA(), showDrawingDiff(), and ShowFile().

◆ m_legend

wxSizer* GIT_FILE_DIFF_AREA::m_legend
private

Definition at line 90 of file git_file_diff_area.h.

Referenced by GIT_FILE_DIFF_AREA(), showDrawingDiff(), showNote(), and showTextDiff().

◆ m_note

wxStaticText* GIT_FILE_DIFF_AREA::m_note
private

Definition at line 83 of file git_file_diff_area.h.

Referenced by GIT_FILE_DIFF_AREA(), showDrawingDiff(), showNote(), and showTextDiff().

◆ m_query

KIGIT_QUERY GIT_FILE_DIFF_AREA::m_query
private

A newer file selection discards any materialization still running for the previous one.

Definition at line 93 of file git_file_diff_area.h.

Referenced by Clear(), ShowFile(), and ~GIT_FILE_DIFF_AREA().

◆ m_textDiff

wxStyledTextCtrl* GIT_FILE_DIFF_AREA::m_textDiff
private

Definition at line 89 of file git_file_diff_area.h.

Referenced by GIT_FILE_DIFF_AREA(), showDrawingDiff(), showNote(), and showTextDiff().


The documentation for this class was generated from the following files: