Skip to content

Commit

Permalink
Fix an issue with the canvas editor when the canvas is embedded (root…
Browse files Browse the repository at this point in the history
…-project#12477)

* Fix an issue with the canvas editor when the canvas is embedded

Fix a problem with the editor not appearing when the TCanvas is embedded, [as reported on the Forum](https://root-forum.cern.ch/t/editor-not-appearing-in-gui-canvas/53968)

Co-authored-by: Axel Naumann <Axel.Naumann@cern.ch>

* Cosmetics (thanks Axel!)

---------

Co-authored-by: Axel Naumann <Axel.Naumann@cern.ch>
(cherry picked from commit 77d0a99)
  • Loading branch information
bellenot authored and Axel-Naumann committed Mar 17, 2023
1 parent 42d8d28 commit 0f91d65
Showing 1 changed file with 33 additions and 25 deletions.
58 changes: 33 additions & 25 deletions gui/gui/src/TRootCanvas.cxx
Expand Up @@ -1473,6 +1473,35 @@ void TRootCanvas::ShowEditor(Bool_t show)
UInt_t h = GetHeight();
UInt_t s = fHorizontal1->GetHeight();

auto lambda_show = [&, this]() {
if (show) {
if (!fEditor)
CreateEditor();
TVirtualPadEditor *gged = TVirtualPadEditor::GetPadEditor(kFALSE);
if (gged && gged->GetCanvas() == fCanvas) {
gged->Hide();
}
if (!fViewMenu->IsEntryChecked(kViewToolbar) || fToolDock->IsUndocked()) {
ShowFrame(fHorizontal1);
h += s;
}
fMainFrame->ShowFrame(fEditorFrame);
fEditor->Show();
fViewMenu->CheckEntry(kViewEditor);
w += e;
} else {
if (!fViewMenu->IsEntryChecked(kViewToolbar) || fToolDock->IsUndocked()) {
HideFrame(fHorizontal1);
h -= s;
}
if (fEditor)
fEditor->Hide();
fMainFrame->HideFrame(fEditorFrame);
fViewMenu->UnCheckEntry(kViewEditor);
w -= e;
}
};

if (fParent && fParent != fClient->GetDefaultRoot()) {
TGMainFrame *main = (TGMainFrame *)fParent->GetMainFrame();
fMainFrame->HideFrame(fEditorFrame);
Expand Down Expand Up @@ -1507,34 +1536,13 @@ void TRootCanvas::ShowEditor(Bool_t show)
fEditor = TVirtualPadEditor::GetPadEditor(kFALSE);
}
if (show) browser->GetTabLeft()->SetTab("Pad Editor");
} else {
lambda_show();
main->Layout();
}
}
else {
if (show) {
if (!fEditor) CreateEditor();
TVirtualPadEditor* gged = TVirtualPadEditor::GetPadEditor(kFALSE);
if(gged && gged->GetCanvas() == fCanvas){
gged->Hide();
}
if (!fViewMenu->IsEntryChecked(kViewToolbar) || fToolDock->IsUndocked()) {
ShowFrame(fHorizontal1);
h = h + s;
}
fMainFrame->ShowFrame(fEditorFrame);
fEditor->Show();
fViewMenu->CheckEntry(kViewEditor);
w = w + e;
} else {
if (!fViewMenu->IsEntryChecked(kViewToolbar) || fToolDock->IsUndocked()) {
HideFrame(fHorizontal1);
h = h - s;
}
if (fEditor) fEditor->Hide();
fMainFrame->HideFrame(fEditorFrame);
fViewMenu->UnCheckEntry(kViewEditor);
w = w - e;
}
Resize(w, h);
lambda_show();
}
}

Expand Down

0 comments on commit 0f91d65

Please sign in to comment.