Skip to content

Commit

Permalink
fixed subclassing api
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto De Ioris committed Mar 5, 2018
1 parent a639bd4 commit 6dcbffe
Show file tree
Hide file tree
Showing 4 changed files with 490 additions and 561 deletions.
67 changes: 0 additions & 67 deletions Source/PythonConsole/Private/PythonConsoleModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,71 +93,4 @@ TSharedRef< SWidget > FPythonConsoleModule::MakeConsoleInputBox( TSharedPtr< SEd
TSharedRef< SPythonConsoleInputBox > NewConsoleInputBox = SNew( SPythonConsoleInputBox );
OutExposedEditableTextBox = NewConsoleInputBox->GetEditableTextBox();
return NewConsoleInputBox;
}


void FPythonConsoleModule::TogglePythonConsoleForWindow( const TSharedRef< SWindow >& Window, const EPythonConsoleStyle::Type InStyle, const FPythonConsoleDelegates& PythonConsoleDelegates )
{
bool bShouldOpen = true;
// Close an existing console box, if there is one
TSharedPtr< SWidget > PinnedPythonConsole( PythonConsole.Pin() );
if( PinnedPythonConsole.IsValid() )
{
// If the console is already open close it unless it is in a different window. In that case reopen it on that window
bShouldOpen = false;
TSharedPtr< SWindow > WindowForExistingConsole = FSlateApplication::Get().FindWidgetWindow(PinnedPythonConsole.ToSharedRef());
if (WindowForExistingConsole.IsValid())
{
WindowForExistingConsole->RemoveOverlaySlot(PinnedPythonConsole.ToSharedRef());
PythonConsole.Reset();
}

if( WindowForExistingConsole != Window )
{
// Console is being opened on another window
bShouldOpen = true;
}
}

TSharedPtr<SDockTab> ActiveTab = FGlobalTabmanager::Get()->GetActiveTab();
if (ActiveTab.IsValid() && ActiveTab->GetLayoutIdentifier() == FTabId(PythonConsoleModule::PythonLogTabName))
{
FGlobalTabmanager::Get()->DrawAttention(ActiveTab.ToSharedRef());
bShouldOpen = false;
}

if( bShouldOpen )
{
const EPythonConsoleStyle::Type PythonConsoleStyle = InStyle;
TSharedRef< SPythonConsole > PythonConsoleRef = SNew( SPythonConsole, PythonConsoleStyle, this, &PythonConsoleDelegates );
PythonConsole = PythonConsoleRef;

const int32 MaximumZOrder = MAX_int32;
Window->AddOverlaySlot( MaximumZOrder )
.VAlign(VAlign_Bottom)
.HAlign(HAlign_Center)
.Padding( 10.0f )
[
PythonConsoleRef
];

// Force keyboard focus
PythonConsoleRef->SetFocusToEditableText();
}
}


void FPythonConsoleModule::ClosePythonConsole()
{
TSharedPtr< SWidget > PinnedPythonConsole( PythonConsole.Pin() );

if( PinnedPythonConsole.IsValid() )
{
TSharedPtr< SWindow > WindowForExistingConsole = FSlateApplication::Get().FindWidgetWindow(PinnedPythonConsole.ToSharedRef());
if (WindowForExistingConsole.IsValid())
{
WindowForExistingConsole->RemoveOverlaySlot( PinnedPythonConsole.ToSharedRef() );
PythonConsole.Reset();
}
}
}
8 changes: 1 addition & 7 deletions Source/PythonConsole/Public/PythonConsoleModule.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
// Copyright 1998-2018 20Tab S.r.l. All Rights Reserved.

#pragma once

Expand Down Expand Up @@ -33,12 +33,6 @@ class FPythonConsoleModule : public IModuleInterface
output log DLL is unloaded on the fly. */
virtual TSharedRef< SWidget > MakeConsoleInputBox( TSharedPtr< SEditableTextBox >& OutExposedEditableTextBox ) const;

/** Opens a debug console in the specified window, if not already open */
virtual void TogglePythonConsoleForWindow( const TSharedRef< SWindow >& Window, const EPythonConsoleStyle::Type InStyle, const FPythonConsoleDelegates& PythonConsoleDelegates );

/** Closes the debug console for the specified window */
virtual void ClosePythonConsole();


private:

Expand Down
Loading

0 comments on commit 6dcbffe

Please sign in to comment.