forked from bartvdbraak/blender
Cleanup: GHOST_ISystem::toggleConsole API
GHOST_ISystem::toggleConsole had a somewhat misleading name it could be fed 4 different values, so it was not as much a toggle as a set console window state. This change renames `toggleConsole` to a more appropriately named `setConsoleWindowState` and replaces the integer it had to an enum so it's easy to tell what is being asked of it at the call site. Reviewed By: LazyDodo Differential Revision: https://developer.blender.org/D14020
This commit is contained in:
parent
452a7f6731
commit
f021d46752
@ -889,16 +889,11 @@ extern char *GHOST_getClipboard(bool selection);
|
||||
extern void GHOST_putClipboard(const char *buffer, bool selection);
|
||||
|
||||
/**
|
||||
* Toggles console
|
||||
* \param action:
|
||||
* - 0: Hides
|
||||
* - 1: Shows
|
||||
* - 2: Toggles
|
||||
* - 3: Hides if it runs not from command line
|
||||
* - *: Does nothing
|
||||
* Set the Console State
|
||||
* \param action: console state
|
||||
* \return current status (1 -visible, 0 - hidden)
|
||||
*/
|
||||
extern int GHOST_toggleConsole(int action);
|
||||
extern int setConsoleWindowState(GHOST_TConsoleWindowState action);
|
||||
|
||||
/**
|
||||
* Use native pixel size (MacBook pro 'retina'), if supported.
|
||||
|
@ -411,16 +411,11 @@ class GHOST_ISystem {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Toggles console
|
||||
* \param action:
|
||||
* - 0: Hides.
|
||||
* - 1: Shows
|
||||
* - 2: Toggles
|
||||
* - 3: Hides if it runs not from command line
|
||||
* - *: Does nothing
|
||||
* Set the Console State
|
||||
* \param action: console state
|
||||
* \return current status (1 -visible, 0 - hidden)
|
||||
*/
|
||||
virtual int toggleConsole(int action) = 0;
|
||||
virtual int setConsoleWindowState(GHOST_TConsoleWindowState action) = 0;
|
||||
|
||||
/***************************************************************************************
|
||||
* Access to clipboard.
|
||||
|
@ -140,6 +140,13 @@ typedef enum {
|
||||
// GHOST_kWindowStateUnModified,
|
||||
} GHOST_TWindowState;
|
||||
|
||||
typedef enum {
|
||||
GHOST_kConsoleWindowStateHide = 0,
|
||||
GHOST_kConsoleWindowStateShow,
|
||||
GHOST_kConsoleWindowStateToggle,
|
||||
GHOST_kConsoleWindowStateHideForNonConsoleLaunch
|
||||
} GHOST_TConsoleWindowState;
|
||||
|
||||
typedef enum { GHOST_kWindowOrderTop = 0, GHOST_kWindowOrderBottom } GHOST_TWindowOrder;
|
||||
|
||||
typedef enum {
|
||||
|
@ -809,10 +809,10 @@ void GHOST_putClipboard(const char *buffer, bool selection)
|
||||
system->putClipboard(buffer, selection);
|
||||
}
|
||||
|
||||
int GHOST_toggleConsole(int action)
|
||||
int setConsoleWindowState(GHOST_TConsoleWindowState action)
|
||||
{
|
||||
GHOST_ISystem *system = GHOST_ISystem::getSystem();
|
||||
return system->toggleConsole(action);
|
||||
return system->setConsoleWindowState(action);
|
||||
}
|
||||
|
||||
int GHOST_UseNativePixels(void)
|
||||
|
@ -244,7 +244,7 @@ class GHOST_SystemCocoa : public GHOST_System {
|
||||
/**
|
||||
* \see GHOST_ISystem
|
||||
*/
|
||||
int toggleConsole(int action)
|
||||
int setConsoleWindowState(GHOST_TConsoleWindowState action)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class GHOST_SystemNULL : public GHOST_System {
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int toggleConsole(int action)
|
||||
int setConsoleWindowState(GHOST_TConsoleWindowState action)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class GHOST_SystemSDL : public GHOST_System {
|
||||
|
||||
bool processEvents(bool waitForEvent);
|
||||
|
||||
int toggleConsole(int action)
|
||||
int setConsoleWindowState(GHOST_TConsoleWindowState action)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -1473,7 +1473,7 @@ bool GHOST_SystemWayland::processEvents(bool waitForEvent)
|
||||
return fired || (getEventManager()->getNumEvents() > 0);
|
||||
}
|
||||
|
||||
int GHOST_SystemWayland::toggleConsole(int /*action*/)
|
||||
int GHOST_SystemWayland::setConsoleWindowState(GHOST_TConsoleWindowState /*action*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class GHOST_SystemWayland : public GHOST_System {
|
||||
|
||||
bool processEvents(bool waitForEvent) override;
|
||||
|
||||
int toggleConsole(int action) override;
|
||||
int setConsoleWindowState(GHOST_TConsoleWindowState action) override;
|
||||
|
||||
GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys &keys) const override;
|
||||
|
||||
|
@ -170,7 +170,7 @@ GHOST_SystemWin32::~GHOST_SystemWin32()
|
||||
OleUninitialize();
|
||||
|
||||
if (isStartedFromCommandPrompt()) {
|
||||
toggleConsole(1);
|
||||
setConsoleWindowState(GHOST_kConsoleWindowStateShow);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2221,31 +2221,30 @@ static bool isStartedFromCommandPrompt()
|
||||
return false;
|
||||
}
|
||||
|
||||
int GHOST_SystemWin32::toggleConsole(int action)
|
||||
int GHOST_SystemWin32::setConsoleWindowState(GHOST_TConsoleWindowState action)
|
||||
{
|
||||
HWND wnd = GetConsoleWindow();
|
||||
|
||||
switch (action) {
|
||||
case 3: // startup: hide if not started from command prompt
|
||||
{
|
||||
case GHOST_kConsoleWindowStateHideForNonConsoleLaunch: {
|
||||
if (!isStartedFromCommandPrompt()) {
|
||||
ShowWindow(wnd, SW_HIDE);
|
||||
m_consoleStatus = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0: // hide
|
||||
case GHOST_kConsoleWindowStateHide:
|
||||
ShowWindow(wnd, SW_HIDE);
|
||||
m_consoleStatus = 0;
|
||||
break;
|
||||
case 1: // show
|
||||
case GHOST_kConsoleWindowStateShow:
|
||||
ShowWindow(wnd, SW_SHOW);
|
||||
if (!isStartedFromCommandPrompt()) {
|
||||
DeleteMenu(GetSystemMenu(wnd, FALSE), SC_CLOSE, MF_BYCOMMAND);
|
||||
}
|
||||
m_consoleStatus = 1;
|
||||
break;
|
||||
case 2: // toggle
|
||||
case GHOST_kConsoleWindowStateToggle:
|
||||
ShowWindow(wnd, m_consoleStatus ? SW_HIDE : SW_SHOW);
|
||||
m_consoleStatus = !m_consoleStatus;
|
||||
if (m_consoleStatus && !isStartedFromCommandPrompt()) {
|
||||
|
@ -436,16 +436,11 @@ class GHOST_SystemWin32 : public GHOST_System {
|
||||
static LRESULT WINAPI s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
/**
|
||||
* Toggles console
|
||||
* \param action:
|
||||
* - 0 - Hides
|
||||
* - 1 - Shows
|
||||
* - 2 - Toggles
|
||||
* - 3 - Hides if it runs not from command line
|
||||
* - * - Does nothing
|
||||
* Set the Console State
|
||||
* \param action: console state
|
||||
* \return current status (1 -visible, 0 - hidden)
|
||||
*/
|
||||
int toggleConsole(int action);
|
||||
int setConsoleWindowState(GHOST_TConsoleWindowState action);
|
||||
|
||||
/** The current state of the modifier keys. */
|
||||
GHOST_ModifierKeys m_modifierKeys;
|
||||
|
@ -269,7 +269,7 @@ class GHOST_SystemX11 : public GHOST_System {
|
||||
/**
|
||||
* \see GHOST_ISystem
|
||||
*/
|
||||
int toggleConsole(int /*action*/)
|
||||
int setConsoleWindowState(GHOST_TConsoleWindowState /*action*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -356,10 +356,10 @@ void WM_init(bContext *C, int argc, const char **argv)
|
||||
|
||||
if (!G.background) {
|
||||
if (wm_start_with_console) {
|
||||
GHOST_toggleConsole(1);
|
||||
setConsoleWindowState(GHOST_kConsoleWindowStateShow);
|
||||
}
|
||||
else {
|
||||
GHOST_toggleConsole(3);
|
||||
setConsoleWindowState(GHOST_kConsoleWindowStateHideForNonConsoleLaunch);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2046,7 +2046,7 @@ static void WM_OT_quit_blender(wmOperatorType *ot)
|
||||
|
||||
static int wm_console_toggle_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
|
||||
{
|
||||
GHOST_toggleConsole(2);
|
||||
setConsoleWindowState(GHOST_kConsoleWindowStateToggle);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user