diff --git a/bin/assets/ui/uitheme.eta b/bin/assets/ui/uitheme.eta index 61f5f35b7..fde209ad9 100644 Binary files a/bin/assets/ui/uitheme.eta and b/bin/assets/ui/uitheme.eta differ diff --git a/bin/assets/ui/uitheme/uitheme_icon_color-picker-white.png b/bin/assets/ui/uitheme/uitheme_icon_color-picker.png similarity index 100% rename from bin/assets/ui/uitheme/uitheme_icon_color-picker-white.png rename to bin/assets/ui/uitheme/uitheme_icon_color-picker.png diff --git a/bin/assets/ui/uitheme1.5x.eta b/bin/assets/ui/uitheme1.5x.eta index fe8b8cf1a..91b954f4e 100644 Binary files a/bin/assets/ui/uitheme1.5x.eta and b/bin/assets/ui/uitheme1.5x.eta differ diff --git a/bin/assets/ui/uitheme1.5x/uitheme1.5x_icon_color-picker-white.png b/bin/assets/ui/uitheme1.5x/uitheme1.5x_icon_color-picker.png similarity index 100% rename from bin/assets/ui/uitheme1.5x/uitheme1.5x_icon_color-picker-white.png rename to bin/assets/ui/uitheme1.5x/uitheme1.5x_icon_color-picker.png diff --git a/bin/assets/ui/uitheme2x.eta b/bin/assets/ui/uitheme2x.eta index f721df64a..30219ea8a 100644 Binary files a/bin/assets/ui/uitheme2x.eta and b/bin/assets/ui/uitheme2x.eta differ diff --git a/bin/assets/ui/uitheme2x/uitheme2x_icon_color-picker-white.png b/bin/assets/ui/uitheme2x/uitheme2x_icon_color-picker.png similarity index 100% rename from bin/assets/ui/uitheme2x/uitheme2x_icon_color-picker-white.png rename to bin/assets/ui/uitheme2x/uitheme2x_icon_color-picker.png diff --git a/include/eepp/ui/uimenuitem.hpp b/include/eepp/ui/uimenuitem.hpp index bc6ce82fe..b6bc86573 100644 --- a/include/eepp/ui/uimenuitem.hpp +++ b/include/eepp/ui/uimenuitem.hpp @@ -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; diff --git a/include/eepp/window/window.hpp b/include/eepp/window/window.hpp index b94aac71e..651016f3c 100644 --- a/include/eepp/window/window.hpp +++ b/include/eepp/window/window.hpp @@ -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 mCallbacks; WindowRequestCloseCallback mCloseRequestCallback; + Sizei mLastWindowedSize; class FrameData { public: diff --git a/src/eepp/ui/tools/uicolorpicker.cpp b/src/eepp/ui/tools/uicolorpicker.cpp index dc26e177e..08625b7c3 100644 --- a/src/eepp/ui/tools/uicolorpicker.cpp +++ b/src/eepp/ui/tools/uicolorpicker.cpp @@ -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 ); } diff --git a/src/eepp/ui/uicodeeditor.cpp b/src/eepp/ui/uicodeeditor.cpp index 6cefc7feb..894e74ac1 100644 --- a/src/eepp/ui/uicodeeditor.cpp +++ b/src/eepp/ui/uicodeeditor.cpp @@ -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 ) ); } diff --git a/src/eepp/ui/uimenuitem.cpp b/src/eepp/ui/uimenuitem.cpp index 0113b0a1e..75fffd49e 100644 --- a/src/eepp/ui/uimenuitem.cpp +++ b/src/eepp/ui/uimenuitem.cpp @@ -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 { diff --git a/src/eepp/window/backend/SDL2/windowsdl2.cpp b/src/eepp/window/backend/SDL2/windowsdl2.cpp index e4a29f32e..35d2834bd 100644 --- a/src/eepp/window/backend/SDL2/windowsdl2.cpp +++ b/src/eepp/window/backend/SDL2/windowsdl2.cpp @@ -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 ); diff --git a/src/eepp/window/backend/SDL2/windowsdl2.hpp b/src/eepp/window/backend/SDL2/windowsdl2.hpp index b5bad6d59..547b16fa5 100644 --- a/src/eepp/window/backend/SDL2/windowsdl2.hpp +++ b/src/eepp/window/backend/SDL2/windowsdl2.hpp @@ -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 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 diff --git a/src/eepp/window/window.cpp b/src/eepp/window/window.cpp index 827a2ab81..eb8795a74 100644 --- a/src/eepp/window/window.cpp +++ b/src/eepp/window/window.cpp @@ -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; diff --git a/src/tools/codeeditor/codeeditor.cpp b/src/tools/codeeditor/codeeditor.cpp index 372f53243..ad4dc12f4 100644 --- a/src/tools/codeeditor/codeeditor.cpp +++ b/src/tools/codeeditor/codeeditor.cpp @@ -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 run ) { run( tabWidget->getTab( i )->getOwnedWidget()->asType() ); } +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( "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() + ->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(); @@ -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()->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() ->setActive( true ); + + mDocMenu->find( "read_only" )->asType()->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(); diff --git a/src/tools/codeeditor/codeeditor.hpp b/src/tools/codeeditor/codeeditor.hpp index e7a7e3248..af4e2e087 100644 --- a/src/tools/codeeditor/codeeditor.hpp +++ b/src/tools/codeeditor/codeeditor.hpp @@ -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 mTabWidgets; std::map 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 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