mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-06-04 20:46:29 +03:00
More improvements to the Code Editor.
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 834 B After Width: | Height: | Size: 834 B |
Binary file not shown.
|
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 8.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
@@ -19,7 +19,7 @@ class EE_API UIMenuItem : public UIPushButton {
|
||||
|
||||
virtual void setTheme( UITheme* Theme );
|
||||
|
||||
virtual void setShortcutText( const String& text );
|
||||
virtual UIMenuItem* setShortcutText( const String& text );
|
||||
|
||||
UITextView* getShortcutView() const;
|
||||
|
||||
|
||||
@@ -124,6 +124,8 @@ class WindowInfo {
|
||||
Maximized( false ),
|
||||
Context( 0 ) {}
|
||||
|
||||
Sizei getWindowSize() const { return Sizei( WindowConfig.Width, WindowConfig.Height ); }
|
||||
|
||||
WindowSettings WindowConfig;
|
||||
ContextSettings ContextConfig;
|
||||
WindowBackend Backend;
|
||||
@@ -456,7 +458,9 @@ class EE_API Window {
|
||||
* per second. */
|
||||
const System::Time& getRenderTimePerSecond() const;
|
||||
|
||||
protected:
|
||||
const Sizei& getLastWindowedSize() const;
|
||||
|
||||
protected:
|
||||
friend class Engine;
|
||||
friend class Input;
|
||||
|
||||
@@ -469,6 +473,7 @@ class EE_API Window {
|
||||
Uint32 mNumCallBacks;
|
||||
std::map<Uint32, WindowResizeCallback> mCallbacks;
|
||||
WindowRequestCloseCallback mCloseRequestCallback;
|
||||
Sizei mLastWindowedSize;
|
||||
|
||||
class FrameData {
|
||||
public:
|
||||
|
||||
@@ -28,7 +28,7 @@ const char* COLOR_PICKER_STYLE = R"xml(
|
||||
#color_picker > .header > .current_color {
|
||||
}
|
||||
#color_picker > .header > .picker_icon {
|
||||
icon: color-picker-white;
|
||||
icon: color-picker;
|
||||
gravity: center;
|
||||
}
|
||||
#color_picker > .pickers > .color_picker_container > .color_picker {
|
||||
@@ -371,7 +371,7 @@ Texture* UIColorPicker::createHueTexture( const Sizef& size ) {
|
||||
TextureFactory* TF = TextureFactory::instance();
|
||||
Uint32 texId =
|
||||
TF->loadFromPixels( image.getPixelsPtr(), image.getWidth(), image.getHeight(),
|
||||
image.getChannels(), false, Texture::ClampMode::ClampRepeat );
|
||||
image.getChannels() );
|
||||
|
||||
return TF->getTexture( texId );
|
||||
}
|
||||
|
||||
@@ -625,14 +625,14 @@ Uint32 UICodeEditor::onMouseUp( const Vector2i& position, const Uint32& flags )
|
||||
}
|
||||
} else if ( flags & EE_BUTTON_WDMASK ) {
|
||||
if ( getUISceneNode()->getWindow()->getInput()->isControlPressed() ) {
|
||||
fontSizeShrink();
|
||||
mDoc->execute( "font-size-shrink" );
|
||||
} else {
|
||||
setScrollY( mScroll.y + PixelDensity::dpToPx( mMouseWheelScroll ) );
|
||||
}
|
||||
invalidateDraw();
|
||||
} else if ( flags & EE_BUTTON_WUMASK ) {
|
||||
if ( getUISceneNode()->getWindow()->getInput()->isControlPressed() ) {
|
||||
fontSizeGrow();
|
||||
mDoc->execute( "font-size-grow" );
|
||||
} else {
|
||||
setScrollY( mScroll.y - PixelDensity::dpToPx( mMouseWheelScroll ) );
|
||||
}
|
||||
|
||||
@@ -31,11 +31,12 @@ void UIMenuItem::setTheme( UITheme* Theme ) {
|
||||
onThemeLoaded();
|
||||
}
|
||||
|
||||
void UIMenuItem::setShortcutText( const String& text ) {
|
||||
UIMenuItem* UIMenuItem::setShortcutText( const String& text ) {
|
||||
if ( !text.empty() )
|
||||
createShortcutView();
|
||||
if ( mShortcutView )
|
||||
mShortcutView->setText( text );
|
||||
return this;
|
||||
}
|
||||
|
||||
UITextView* UIMenuItem::getShortcutView() const {
|
||||
|
||||
@@ -362,6 +362,7 @@ bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) {
|
||||
mWindow.WindowConfig.Width = w;
|
||||
mWindow.WindowConfig.Height = h;
|
||||
mWindow.WindowSize = Sizei( mWindow.WindowConfig.Width, mWindow.WindowConfig.Height );
|
||||
mLastWindowedSize = mWindow.WindowSize;
|
||||
} else {
|
||||
eePRINTL( "Window failed to create!" );
|
||||
|
||||
@@ -528,15 +529,18 @@ bool WindowSDL::hasMouseFocus() {
|
||||
return 0 != ( SDL_GetWindowFlags( mSDLWindow ) & ( SDL_WINDOW_MOUSE_FOCUS ) );
|
||||
}
|
||||
|
||||
void WindowSDL::onWindowResize( Uint32 Width, Uint32 Height ) {
|
||||
if ( Width == mWindow.WindowConfig.Width && Height == mWindow.WindowConfig.Height )
|
||||
void WindowSDL::onWindowResize( Uint32 width, Uint32 height ) {
|
||||
if ( width == mWindow.WindowConfig.Width && height == mWindow.WindowConfig.Height )
|
||||
return;
|
||||
|
||||
eePRINTL( "onWindowResize: %d Height %d.", Width, Height );
|
||||
eePRINTL( "onWindowResize: Width %d Height %d.", width, height );
|
||||
|
||||
mWindow.WindowConfig.Width = Width;
|
||||
mWindow.WindowConfig.Height = Height;
|
||||
mWindow.WindowSize = Sizei( Width, Height );
|
||||
mWindow.WindowConfig.Width = width;
|
||||
mWindow.WindowConfig.Height = height;
|
||||
mWindow.WindowSize = Sizei( width, height );
|
||||
|
||||
if ( isWindowed() )
|
||||
mLastWindowedSize = Sizei( width, height );
|
||||
|
||||
mDefaultView.reset( Rectf( 0, 0, mWindow.WindowConfig.Width, mWindow.WindowConfig.Height ) );
|
||||
|
||||
@@ -551,55 +555,58 @@ void WindowSDL::onWindowResize( Uint32 Width, Uint32 Height ) {
|
||||
sendVideoResizeCb();
|
||||
}
|
||||
|
||||
void WindowSDL::setSize( Uint32 Width, Uint32 Height, bool Windowed ) {
|
||||
if ( ( !Width || !Height ) ) {
|
||||
Width = mWindow.DesktopResolution.getWidth();
|
||||
Height = mWindow.DesktopResolution.getHeight();
|
||||
void WindowSDL::setSize( Uint32 width, Uint32 height, bool windowed ) {
|
||||
if ( ( !width || !height ) ) {
|
||||
width = mWindow.DesktopResolution.getWidth();
|
||||
height = mWindow.DesktopResolution.getHeight();
|
||||
}
|
||||
|
||||
if ( this->isWindowed() == Windowed && Width == mWindow.WindowConfig.Width &&
|
||||
Height == mWindow.WindowConfig.Height )
|
||||
if ( this->isWindowed() == windowed && width == mWindow.WindowConfig.Width &&
|
||||
height == mWindow.WindowConfig.Height )
|
||||
return;
|
||||
|
||||
eePRINTL( "Switching from %s to %s. Width: %d Height %d.",
|
||||
this->isWindowed() ? "windowed" : "fullscreen", Windowed ? "windowed" : "fullscreen",
|
||||
Width, Height );
|
||||
this->isWindowed() ? "windowed" : "fullscreen", windowed ? "windowed" : "fullscreen",
|
||||
width, height );
|
||||
|
||||
Uint32 oldWidth = mWindow.WindowConfig.Width;
|
||||
Uint32 oldHeight = mWindow.WindowConfig.Height;
|
||||
|
||||
mWindow.WindowConfig.Width = Width;
|
||||
mWindow.WindowConfig.Height = Height;
|
||||
mWindow.WindowConfig.Width = width;
|
||||
mWindow.WindowConfig.Height = height;
|
||||
|
||||
if ( Windowed ) {
|
||||
mWindow.WindowSize = Sizei( Width, Height );
|
||||
if ( windowed ) {
|
||||
mWindow.WindowSize = Sizei( width, height );
|
||||
} else {
|
||||
mWindow.WindowSize = Sizei( oldWidth, oldHeight );
|
||||
}
|
||||
|
||||
if ( isWindowed() && !Windowed ) {
|
||||
if ( isWindowed() && !windowed ) {
|
||||
mWinPos = getPosition();
|
||||
} else {
|
||||
SDL_SetWindowFullscreen( mSDLWindow, Windowed ? 0 : SDL_WINDOW_FULLSCREEN );
|
||||
SDL_SetWindowFullscreen( mSDLWindow, windowed ? 0 : SDL_WINDOW_FULLSCREEN );
|
||||
}
|
||||
|
||||
SDL_SetWindowSize( mSDLWindow, Width, Height );
|
||||
if ( windowed )
|
||||
mLastWindowedSize = Sizei( width, height );
|
||||
|
||||
if ( isWindowed() && !Windowed ) {
|
||||
SDL_SetWindowSize( mSDLWindow, width, height );
|
||||
|
||||
if ( isWindowed() && !windowed ) {
|
||||
mWinPos = getPosition();
|
||||
|
||||
setGLConfig();
|
||||
|
||||
SDL_SetWindowFullscreen( mSDLWindow, Windowed ? 0 : SDL_WINDOW_FULLSCREEN );
|
||||
SDL_SetWindowFullscreen( mSDLWindow, windowed ? 0 : SDL_WINDOW_FULLSCREEN );
|
||||
}
|
||||
|
||||
if ( isWindowed() && Windowed ) {
|
||||
if ( isWindowed() && windowed ) {
|
||||
setPosition( mWinPos.x, mWinPos.y );
|
||||
}
|
||||
|
||||
BitOp::setBitFlagValue( &mWindow.WindowConfig.Style, WindowStyle::Fullscreen, !Windowed );
|
||||
BitOp::setBitFlagValue( &mWindow.WindowConfig.Style, WindowStyle::Fullscreen, !windowed );
|
||||
|
||||
mDefaultView.reset( Rectf( 0, 0, Width, Height ) );
|
||||
mDefaultView.reset( Rectf( 0, 0, width, height ) );
|
||||
|
||||
setup2D( false );
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ class EE_API WindowSDL : public Window {
|
||||
|
||||
bool hasMouseFocus();
|
||||
|
||||
void setSize( Uint32 Width, Uint32 Height, bool isWindowed );
|
||||
void setSize( Uint32 width, Uint32 height, bool windowed );
|
||||
|
||||
std::vector<DisplayMode> getDisplayModes() const;
|
||||
|
||||
@@ -115,7 +115,7 @@ class EE_API WindowSDL : public Window {
|
||||
|
||||
void updateDesktopResolution();
|
||||
|
||||
void onWindowResize( Uint32 Width, Uint32 Height );
|
||||
void onWindowResize( Uint32 width, Uint32 height );
|
||||
};
|
||||
|
||||
}}}} // namespace EE::Window::Backend::SDL2
|
||||
|
||||
@@ -330,6 +330,10 @@ const Time& Window::getRenderTimePerSecond() const {
|
||||
return mFrameData.FPS.CurRenderTime;
|
||||
}
|
||||
|
||||
const Sizei& Window::getLastWindowedSize() const {
|
||||
return mLastWindowedSize;
|
||||
}
|
||||
|
||||
void Window::calculateFps() {
|
||||
if ( mFrameData.FPS.LastCheck.getElapsedTime().asSeconds() >= 1.f ) {
|
||||
mFrameData.FPS.Current = mFrameData.FPS.Count;
|
||||
|
||||
@@ -9,15 +9,15 @@ void appLoop() {
|
||||
|
||||
bool App::onCloseRequestCallback( EE::Window::Window* ) {
|
||||
if ( nullptr != mCurEditor && mCurEditor->isDirty() ) {
|
||||
mMsgBox = UIMessageBox::New(
|
||||
UIMessageBox* msgBox = UIMessageBox::New(
|
||||
UIMessageBox::OK_CANCEL,
|
||||
"Do you really want to close the code editor?\nAll changes will be lost." );
|
||||
mMsgBox->addEventListener( Event::MsgBoxConfirmClick,
|
||||
[&]( const Event* ) { mWindow->close(); } );
|
||||
mMsgBox->addEventListener( Event::OnClose, [&]( const Event* ) { mMsgBox = nullptr; } );
|
||||
mMsgBox->setTitle( "Close Code Editor?" );
|
||||
mMsgBox->center();
|
||||
mMsgBox->show();
|
||||
msgBox->addEventListener( Event::MsgBoxConfirmClick,
|
||||
[&]( const Event* ) { mWindow->close(); } );
|
||||
msgBox->addEventListener( Event::OnClose, [&]( const Event* ) { msgBox = nullptr; } );
|
||||
msgBox->setTitle( "Close " + mWindowTitle + "?" );
|
||||
msgBox->center();
|
||||
msgBox->show();
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@@ -26,19 +26,19 @@ bool App::onCloseRequestCallback( EE::Window::Window* ) {
|
||||
|
||||
bool App::tryTabClose( UICodeEditor* editor ) {
|
||||
if ( nullptr != editor && editor->isDirty() ) {
|
||||
mMsgBox =
|
||||
UIMessageBox* msgBox =
|
||||
UIMessageBox::New( UIMessageBox::OK_CANCEL,
|
||||
"Do you really want to close this tab?\nAll changes will be lost." );
|
||||
mMsgBox->addEventListener( Event::MsgBoxConfirmClick,
|
||||
[&, editor]( const Event* ) { closeEditorTab( editor ); } );
|
||||
mMsgBox->addEventListener( Event::OnClose, [&]( const Event* ) {
|
||||
mMsgBox = nullptr;
|
||||
msgBox->addEventListener( Event::MsgBoxConfirmClick,
|
||||
[&, editor]( const Event* ) { closeEditorTab( editor ); } );
|
||||
msgBox->addEventListener( Event::OnClose, [&]( const Event* ) {
|
||||
msgBox = nullptr;
|
||||
if ( mCurEditor )
|
||||
mCurEditor->setFocus();
|
||||
} );
|
||||
mMsgBox->setTitle( "Close Tab?" );
|
||||
mMsgBox->center();
|
||||
mMsgBox->show();
|
||||
msgBox->setTitle( "Close Tab?" );
|
||||
msgBox->center();
|
||||
msgBox->show();
|
||||
return false;
|
||||
} else {
|
||||
closeEditorTab( editor );
|
||||
@@ -196,6 +196,18 @@ void App::forEachEditor( std::function<void( UICodeEditor* )> run ) {
|
||||
run( tabWidget->getTab( i )->getOwnedWidget()->asType<UICodeEditor>() );
|
||||
}
|
||||
|
||||
void App::zoomIn() {
|
||||
forEachEditor( []( UICodeEditor* editor ) { editor->fontSizeGrow(); } );
|
||||
}
|
||||
|
||||
void App::zoomOut() {
|
||||
forEachEditor( []( UICodeEditor* editor ) { editor->fontSizeShrink(); } );
|
||||
}
|
||||
|
||||
void App::zoomReset() {
|
||||
forEachEditor( []( UICodeEditor* editor ) { editor->fontSizeReset(); } );
|
||||
}
|
||||
|
||||
UICodeEditor* App::createCodeEditor() {
|
||||
UICodeEditor* codeEditor = UICodeEditor::NewOpt( false, true );
|
||||
TextDocument& doc = codeEditor->getDocument();
|
||||
@@ -264,29 +276,26 @@ UICodeEditor* App::createCodeEditor() {
|
||||
if ( mCurEditor )
|
||||
mCurEditor->paste();
|
||||
} );
|
||||
doc.setCommand( "font-size-grow", [&] {
|
||||
if ( mCurEditor )
|
||||
mCurEditor->fontSizeGrow();
|
||||
} );
|
||||
doc.setCommand( "font-size-shrink", [&] {
|
||||
if ( mCurEditor )
|
||||
mCurEditor->fontSizeShrink();
|
||||
} );
|
||||
doc.setCommand( "font-size-reset", [&] {
|
||||
if ( mCurEditor )
|
||||
mCurEditor->fontSizeReset();
|
||||
} );
|
||||
doc.setCommand( "font-size-grow", [&] { zoomIn(); } );
|
||||
doc.setCommand( "font-size-shrink", [&] { zoomOut(); } );
|
||||
doc.setCommand( "font-size-reset", [&] { zoomReset(); } );
|
||||
doc.setCommand( "lock", [&] {
|
||||
if ( mCurEditor )
|
||||
if ( mCurEditor ) {
|
||||
mCurEditor->setLocked( true );
|
||||
updateDocumentMenu();
|
||||
}
|
||||
} );
|
||||
doc.setCommand( "unlock", [&] {
|
||||
if ( mCurEditor )
|
||||
if ( mCurEditor ) {
|
||||
mCurEditor->setLocked( false );
|
||||
updateDocumentMenu();
|
||||
}
|
||||
} );
|
||||
doc.setCommand( "lock-toggle", [&] {
|
||||
if ( mCurEditor )
|
||||
if ( mCurEditor ) {
|
||||
mCurEditor->setLocked( !mCurEditor->isLocked() );
|
||||
updateDocumentMenu();
|
||||
}
|
||||
} );
|
||||
codeEditor->addUnlockedCommand( "copy" );
|
||||
codeEditor->addUnlockedCommand( "select-all" );
|
||||
@@ -318,7 +327,12 @@ UICodeEditor* App::createCodeEditor() {
|
||||
findNextText( "", mSearchBarLayout->find<UICheckBox>( "case_sensitive" )->isChecked() );
|
||||
} );
|
||||
doc.setCommand( "close-app", [&] { closeApp(); } );
|
||||
doc.setCommand( "fullscreen-toggle", [&]() { mWindow->toggleFullscreen(); } );
|
||||
doc.setCommand( "fullscreen-toggle", [&]() {
|
||||
mWindow->toggleFullscreen();
|
||||
mViewMenu->find( "fullscreen-mode" )
|
||||
->asType<UIMenuCheckBox>()
|
||||
->setActive( !mWindow->isWindowed() );
|
||||
} );
|
||||
doc.setCommand( "open-file", [&] { openFileDialog(); } );
|
||||
doc.setCommand( "console-toggle", [&] {
|
||||
mConsole->toggle();
|
||||
@@ -764,9 +778,8 @@ void App::findAndReplace( String find, String replace, const bool& caseSensitive
|
||||
}
|
||||
|
||||
void App::runCommand( const std::string& command ) {
|
||||
if ( mCurEditor ) {
|
||||
if ( mCurEditor )
|
||||
mCurEditor->getDocument().execute( command );
|
||||
}
|
||||
}
|
||||
|
||||
void App::loadConfig() {
|
||||
@@ -812,7 +825,7 @@ void App::loadConfig() {
|
||||
|
||||
void App::saveConfig() {
|
||||
mConfig.editor.colorScheme = mCurrentColorScheme;
|
||||
mConfig.window.size = mWindow->getSize();
|
||||
mConfig.window.size = mWindow->getLastWindowedSize();
|
||||
mConfig.window.maximized = mWindow->isMaximized();
|
||||
mIni.setValue( "editor", "colorscheme", mConfig.editor.colorScheme );
|
||||
mIniState.setValueI( "window", "width", mConfig.window.size.getWidth() );
|
||||
@@ -930,9 +943,8 @@ void App::showFindView() {
|
||||
}
|
||||
|
||||
void App::closeApp() {
|
||||
if ( nullptr == mMsgBox && onCloseRequestCallback( mWindow ) ) {
|
||||
if ( onCloseRequestCallback( mWindow ) )
|
||||
mWindow->close();
|
||||
}
|
||||
}
|
||||
|
||||
void App::mainLoop() {
|
||||
@@ -1034,24 +1046,33 @@ void App::updateRecentFiles() {
|
||||
}
|
||||
|
||||
UIMenu* App::createViewMenu() {
|
||||
UIPopUpMenu* menu = UIPopUpMenu::New();
|
||||
menu->addCheckBox( "Show Line Numbers" )->setActive( mConfig.editor.showLineNumbers );
|
||||
menu->addCheckBox( "Show White Space" )->setActive( mConfig.editor.showWhiteSpaces );
|
||||
menu->addCheckBox( "Highlight Matching Bracket" )
|
||||
mViewMenu = UIPopUpMenu::New();
|
||||
mViewMenu->addCheckBox( "Show Line Numbers" )->setActive( mConfig.editor.showLineNumbers );
|
||||
mViewMenu->addCheckBox( "Show White Space" )->setActive( mConfig.editor.showWhiteSpaces );
|
||||
mViewMenu->addCheckBox( "Highlight Matching Bracket" )
|
||||
->setActive( mConfig.editor.highlightMatchingBracket );
|
||||
menu->addCheckBox( "Highlight Current Line" )->setActive( mConfig.editor.highlightCurrentLine );
|
||||
menu->addCheckBox( "Enable Horizontal ScrollBar" )
|
||||
mViewMenu->addCheckBox( "Highlight Current Line" )
|
||||
->setActive( mConfig.editor.highlightCurrentLine );
|
||||
mViewMenu->addCheckBox( "Enable Horizontal ScrollBar" )
|
||||
->setActive( mConfig.editor.horizontalScrollbar );
|
||||
menu->addSeparator();
|
||||
menu->add( "Editor Font Size", findIcon( "font-size" ) );
|
||||
menu->add( "UI Font Size", findIcon( "font-size" ) );
|
||||
menu->add( "Line Breaking Column" );
|
||||
menu->addSeparator();
|
||||
menu->add( "Split Left", findIcon( "split-horizontal" ), "Ctrl+Shift+J" );
|
||||
menu->add( "Split Right", findIcon( "split-horizontal" ), "Ctrl+Shift+L" );
|
||||
menu->add( "Split Top", findIcon( "split-vertical" ), "Ctrl+Shift+I" );
|
||||
menu->add( "Split Bottom", findIcon( "split-vertical" ), "Ctrl+Shift+K" );
|
||||
menu->addEventListener( Event::OnItemClicked, [&]( const Event* event ) {
|
||||
mViewMenu->addSeparator();
|
||||
mViewMenu->add( "Editor Font Size", findIcon( "font-size" ) );
|
||||
mViewMenu->add( "UI Font Size", findIcon( "font-size" ) );
|
||||
mViewMenu->add( "Line Breaking Column" );
|
||||
mViewMenu->addSeparator();
|
||||
mViewMenu->addCheckBox( "Full Screen Mode" )
|
||||
->setShortcutText( "Alt+Return" )
|
||||
->setId( "fullscreen-mode" );
|
||||
mViewMenu->addSeparator();
|
||||
mViewMenu->add( "Split Left", findIcon( "split-horizontal" ), "Ctrl+Shift+J" );
|
||||
mViewMenu->add( "Split Right", findIcon( "split-horizontal" ), "Ctrl+Shift+L" );
|
||||
mViewMenu->add( "Split Top", findIcon( "split-vertical" ), "Ctrl+Shift+I" );
|
||||
mViewMenu->add( "Split Bottom", findIcon( "split-vertical" ), "Ctrl+Shift+K" );
|
||||
mViewMenu->addSeparator();
|
||||
mViewMenu->add( "Zoom In", findIcon( "zoom-in" ), "Ctrl++" );
|
||||
mViewMenu->add( "Zoom Out", findIcon( "zoom-out" ), "Ctrl+-" );
|
||||
mViewMenu->add( "Zoom Reset", findIcon( "zoom-reset" ), "Ctrl+0" );
|
||||
mViewMenu->addEventListener( Event::OnItemClicked, [&]( const Event* event ) {
|
||||
if ( !event->getNode()->isType( UI_TYPE_MENUITEM ) )
|
||||
return;
|
||||
UIMenuItem* item = event->getNode()->asType<UIMenuItem>();
|
||||
@@ -1083,7 +1104,7 @@ UIMenu* App::createViewMenu() {
|
||||
} else if ( item->getText() == "Editor Font Size" ) {
|
||||
UIMessageBox* msgBox =
|
||||
UIMessageBox::New( UIMessageBox::INPUT, "Set the editor font size:" );
|
||||
msgBox->setTitle( "ecode" );
|
||||
msgBox->setTitle( mWindowTitle );
|
||||
msgBox->getTextInput()->setAllowOnlyNumbers( true, true );
|
||||
msgBox->getTextInput()->setText( String::format(
|
||||
mConfig.editor.fontSize == (int)mConfig.editor.fontSize ? "%2.f" : "%2.1f",
|
||||
@@ -1103,7 +1124,7 @@ UIMenu* App::createViewMenu() {
|
||||
} else if ( item->getText() == "UI Font Size" ) {
|
||||
UIMessageBox* msgBox = UIMessageBox::New( UIMessageBox::INPUT,
|
||||
"Set the UI font size (requires restart):" );
|
||||
msgBox->setTitle( "ecode" );
|
||||
msgBox->setTitle( mWindowTitle );
|
||||
msgBox->getTextInput()->setAllowOnlyNumbers( true, true );
|
||||
msgBox->getTextInput()->setText(
|
||||
String::format( mConfig.ui.fontSize == (int)mConfig.ui.fontSize ? "%2.f" : "%2.1f",
|
||||
@@ -1124,7 +1145,7 @@ UIMenu* App::createViewMenu() {
|
||||
UIMessageBox* msgBox =
|
||||
UIMessageBox::New( UIMessageBox::INPUT, "Set Line Breaking Column:\n"
|
||||
"Set 0 to disable it.\n" );
|
||||
msgBox->setTitle( "ecode" );
|
||||
msgBox->setTitle( mWindowTitle );
|
||||
msgBox->getTextInput()->setAllowOnlyNumbers( true, false );
|
||||
msgBox->getTextInput()->setText(
|
||||
String::toString( mConfig.editor.lineBreakingColumn ) );
|
||||
@@ -1142,6 +1163,14 @@ UIMenu* App::createViewMenu() {
|
||||
if ( mCurEditor )
|
||||
mCurEditor->setFocus();
|
||||
} );
|
||||
} else if ( "Zoom In" == item->getText() ) {
|
||||
zoomIn();
|
||||
} else if ( "Zoom Out" == item->getText() ) {
|
||||
zoomOut();
|
||||
} else if ( "Zoom Reset" == item->getText() ) {
|
||||
zoomReset();
|
||||
} else if ( "Full Screen Mode" == item->getText() ) {
|
||||
runCommand( "fullscreen-toggle" );
|
||||
} else {
|
||||
String text = String( event->getNode()->asType<UIMenuItem>()->getText() ).toLower();
|
||||
String::replaceAll( text, " ", "-" );
|
||||
@@ -1149,7 +1178,7 @@ UIMenu* App::createViewMenu() {
|
||||
runCommand( text );
|
||||
}
|
||||
} );
|
||||
return menu;
|
||||
return mViewMenu;
|
||||
}
|
||||
|
||||
Drawable* App::findIcon( const std::string& name ) {
|
||||
@@ -1248,6 +1277,8 @@ UIMenu* App::createDocumentMenu() {
|
||||
|
||||
mDocMenu->addSeparator();
|
||||
|
||||
mDocMenu->addCheckBox( "Read Only" )->setId( "read_only" );
|
||||
|
||||
mDocMenu->addCheckBox( "Trim Trailing Whitespaces", mConfig.editor.trimTrailingWhitespaces )
|
||||
->setId( "trim_whitespaces" );
|
||||
|
||||
@@ -1278,6 +1309,8 @@ UIMenu* App::createDocumentMenu() {
|
||||
} else if ( "write_bom" == id ) {
|
||||
doc.setBOM( item->isActive() );
|
||||
mConfig.editor.writeUnicodeBOM = item->isActive();
|
||||
} else if ( "read_only" == id ) {
|
||||
mCurEditor->setLocked( item->isActive() );
|
||||
}
|
||||
}
|
||||
} );
|
||||
@@ -1331,6 +1364,8 @@ void App::updateDocumentMenu() {
|
||||
->find( mConfig.editor.windowsLineEndings ? "windows" : "unix" )
|
||||
->asType<UIMenuRadioButton>()
|
||||
->setActive( true );
|
||||
|
||||
mDocMenu->find( "read_only" )->asType<UIMenuCheckBox>()->setActive( mCurEditor->isLocked() );
|
||||
}
|
||||
|
||||
void App::createSettingsMenu() {
|
||||
@@ -1501,16 +1536,17 @@ void App::init( const std::string& file, const Float& pidelDensity ) {
|
||||
|
||||
SceneManager::instance()->add( mUISceneNode );
|
||||
|
||||
mTheme = UITheme::load( "uitheme", "uitheme", "", font, resPath + "assets/ui/breeze.css" );
|
||||
mTheme->setDefaultFontSize( mConfig.ui.fontSize );
|
||||
mUISceneNode->setStyleSheet( mTheme->getStyleSheet() );
|
||||
UITheme* theme =
|
||||
UITheme::load( "uitheme", "uitheme", "", font, resPath + "assets/ui/breeze.css" );
|
||||
theme->setDefaultFontSize( mConfig.ui.fontSize );
|
||||
mUISceneNode->setStyleSheet( theme->getStyleSheet() );
|
||||
mUISceneNode
|
||||
->getUIThemeManager()
|
||||
//->setDefaultEffectsEnabled( true )
|
||||
->setDefaultTheme( mTheme )
|
||||
->setDefaultTheme( theme )
|
||||
->setDefaultFont( font )
|
||||
->setDefaultFontSize( mConfig.ui.fontSize )
|
||||
->add( mTheme );
|
||||
->add( theme );
|
||||
|
||||
auto colorSchemes =
|
||||
SyntaxColorScheme::loadFromFile( resPath + "assets/colorschemes/colorschemes.conf" );
|
||||
@@ -1633,6 +1669,11 @@ void App::init( const std::string& file, const Float& pidelDensity ) {
|
||||
addIcon( "file-code", 0xecd1, 12 );
|
||||
addIcon( "file-edit", 0xecdb, 12 );
|
||||
addIcon( "font-size", 0xed8d, 12 );
|
||||
addIcon( "color-picker", 0xf13d, 16 );
|
||||
addIcon( "zoom-in", 0xf2db, 12 );
|
||||
addIcon( "zoom-out", 0xf2dd, 12 );
|
||||
addIcon( "zoom-reset", 0xeb47, 12 );
|
||||
addIcon( "fullscreen", 0xed9c, 12 );
|
||||
|
||||
mUISceneNode->getUIIconThemeManager()->setCurrentTheme( iconTheme );
|
||||
initSearchBar();
|
||||
|
||||
@@ -138,23 +138,22 @@ class App {
|
||||
UICodeEditor* mCurEditor{nullptr};
|
||||
Console* mConsole{nullptr};
|
||||
std::string mWindowTitle{"ecode"};
|
||||
UIMessageBox* mMsgBox{nullptr};
|
||||
String mLastSearch;
|
||||
UILayout* mBaseLayout{nullptr};
|
||||
UISearchBar* mSearchBarLayout{nullptr};
|
||||
std::vector<UITabWidget*> mTabWidgets;
|
||||
std::map<std::string, SyntaxColorScheme> mColorSchemes;
|
||||
std::string mCurrentColorScheme;
|
||||
UIPopUpMenu* mSettingsMenu;
|
||||
UITextView* mSettingsButton;
|
||||
UIPopUpMenu* mColorSchemeMenu;
|
||||
UIPopUpMenu* mFiletypeMenu;
|
||||
UITheme* mTheme;
|
||||
UIPopUpMenu* mSettingsMenu{nullptr};
|
||||
UITextView* mSettingsButton{nullptr};
|
||||
UIPopUpMenu* mColorSchemeMenu{nullptr};
|
||||
UIPopUpMenu* mFiletypeMenu{nullptr};
|
||||
IniFile mIni;
|
||||
IniFile mIniState;
|
||||
std::vector<std::string> mRecentFiles;
|
||||
Config mConfig;
|
||||
UIPopUpMenu* mDocMenu;
|
||||
UIPopUpMenu* mDocMenu{nullptr};
|
||||
UIPopUpMenu* mViewMenu{nullptr};
|
||||
|
||||
void onFileDropped( String file );
|
||||
|
||||
@@ -211,6 +210,12 @@ class App {
|
||||
UIMenu* createDocumentMenu();
|
||||
|
||||
void updateDocumentMenu();
|
||||
|
||||
void zoomIn();
|
||||
|
||||
void zoomOut();
|
||||
|
||||
void zoomReset();
|
||||
};
|
||||
|
||||
#endif // EE_TOOLS_CODEEDITOR_HPP
|
||||
|
||||
Reference in New Issue
Block a user