diff --git a/bin/assets/ui/breeze.css b/bin/assets/ui/breeze.css index dead31f5a..f94ebed13 100644 --- a/bin/assets/ui/breeze.css +++ b/bin/assets/ui/breeze.css @@ -200,7 +200,8 @@ MarkdownView code { font-family: monospace; background-color: var(--button-back); font-size: 11dp; - padding: 4dp; + padding-left: 2dp; + padding-right: 2dp; } pushbutton, diff --git a/include/eepp/scene/event.hpp b/include/eepp/scene/event.hpp index cc0bf7caf..245a1603a 100644 --- a/include/eepp/scene/event.hpp +++ b/include/eepp/scene/event.hpp @@ -128,6 +128,8 @@ class EE_API Event { OnNavigationError, OnTitleChanged, OnToggle, + OnFocusWithin, + OnFocusWithinLoss, NoEvent = eeINDEX_NOT_FOUND }; diff --git a/src/eepp/ui/tools/uicodeeditorsplitter.cpp b/src/eepp/ui/tools/uicodeeditorsplitter.cpp index 1cbc8d33f..f53a0b450 100644 --- a/src/eepp/ui/tools/uicodeeditorsplitter.cpp +++ b/src/eepp/ui/tools/uicodeeditorsplitter.cpp @@ -600,7 +600,7 @@ UICodeEditorSplitter::createWidgetInTabWidget( UITabWidget* tabWidget, UIWidget* return std::make_pair( (UITab*)nullptr, (UIWidget*)nullptr ); UITab* tab = tabWidget->add( tabName, widget ); widget->setData( (UintPtr)tab ); - widget->on( Event::OnFocus, [this]( const Event* event ) { + widget->on( Event::OnFocusWithin, [this]( const Event* event ) { setCurrentWidget( event->getNode()->asType() ); } ); widget->on( Event::OnTitleChange, [this]( const Event* event ) { diff --git a/src/eepp/ui/uinode.cpp b/src/eepp/ui/uinode.cpp index 19961b1de..37a65871a 100644 --- a/src/eepp/ui/uinode.cpp +++ b/src/eepp/ui/uinode.cpp @@ -1341,6 +1341,9 @@ void UINode::pushState( const Uint32& State, bool emitEvent ) { if ( emitEvent ) { onStateChange(); + + if ( State & UIState::StateFocusWithin ) + sendCommonEvent( Event::OnFocusWithin ); } else { invalidateDraw(); } @@ -1356,6 +1359,9 @@ void UINode::popState( const Uint32& State, bool emitEvent ) { if ( emitEvent ) { onStateChange(); + + if ( State & UIState::StateFocusWithin ) + sendCommonEvent( Event::OnFocusWithinLoss ); } else { invalidateDraw(); } diff --git a/src/eepp/ui/uiscenenode.cpp b/src/eepp/ui/uiscenenode.cpp index 604199e8f..0cac9a60b 100644 --- a/src/eepp/ui/uiscenenode.cpp +++ b/src/eepp/ui/uiscenenode.cpp @@ -1515,6 +1515,7 @@ void UISceneNode::navigate( const NavigationRequest& request ) { } Font* UISceneNode::getFontFromNamesList( std::string_view names, Uint32 fontStyle ) const { + FontManager* fm = FontManager::instance(); Font* font = nullptr; String::readBySeparatorStoppable( names, @@ -1528,7 +1529,7 @@ Font* UISceneNode::getFontFromNamesList( std::string_view names, Uint32 fontStyl if ( fontStyle ) fontFamily += "#" + Text::styleFlagToString( fontStyle ); - font = FontManager::instance()->getByName( fontFamily ); + font = fm->getByName( fontFamily ); if ( fontStyle ) fontFamily.resize( size ); @@ -1544,7 +1545,7 @@ Font* UISceneNode::getFontFromNamesList( std::string_view names, Uint32 fontStyl if ( fontStyle ) fontFamily += "#" + Text::styleFlagToString( fontStyle ); - font = FontManager::instance()->getByName( fontFamily ); + font = fm->getByName( fontFamily ); } return font != nullptr; @@ -1559,13 +1560,16 @@ Font* UISceneNode::getFontFromNamesList( std::string_view names, Uint32 fontStyl std::string family = desc.family; if ( fontStyle ) family += "#" + Text::styleFlagToString( fontStyle ); + + if ( ( font = fm->getByName( family ) ) ) + return font; + FontTrueType* ttf = FontTrueType::New( family, desc.path, desc.faceIndex ); if ( ttf && ttf->loaded() ) { font = ttf; - Uint32 weightStyle = fontStyle & ( Text::Bold | Text::Italic ); if ( weightStyle ) { - Font* regular = FontManager::instance()->getByName( desc.family ); + Font* regular = fm->getByName( desc.family ); if ( regular && regular != font && regular->getType() == FontType::TTF ) { auto* regularFT = static_cast( regular ); if ( weightStyle == Text::Bold ) diff --git a/src/eepp/ui/uiwidget.cpp b/src/eepp/ui/uiwidget.cpp index c9fedbc3d..961865a73 100644 --- a/src/eepp/ui/uiwidget.cpp +++ b/src/eepp/ui/uiwidget.cpp @@ -1302,6 +1302,9 @@ void UIWidget::pushState( const Uint32& State, bool emitEvent ) { if ( emitEvent ) { onStateChange(); + + if ( State & UIState::StateFocusWithin ) + sendCommonEvent( Event::OnFocusWithin ); } else { invalidateDraw(); } @@ -1324,6 +1327,9 @@ void UIWidget::popState( const Uint32& State, bool emitEvent ) { if ( emitEvent ) { onStateChange(); + + if ( State & UIState::StateFocusWithin ) + sendCommonEvent( Event::OnFocusWithinLoss ); } else { invalidateDraw(); } diff --git a/src/examples/ui_markdownview/ui_markdownview.cpp b/src/examples/ui_markdownview/ui_markdownview.cpp index bdb6893c7..c1ee6d024 100644 --- a/src/examples/ui_markdownview/ui_markdownview.cpp +++ b/src/examples/ui_markdownview/ui_markdownview.cpp @@ -2,7 +2,9 @@ #include EE_MAIN_FUNC int main( int, char** ) { - UIApplication app( { 1280, 720, "eepp - UIMarkdownView Example" } ); + UIApplication app( + { 1280, 720, "eepp - UIMarkdownView Example" }, {}, + ContextSettings( false, ContextSettings::FrameRateLimitScreenRefreshRate, 4 ) ); app.getUI()->loadLayoutFromString( R"xml( diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index 323f14cb6..add723a08 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -186,10 +186,10 @@ void App::saveAllProcess() { } ); } -void App::saveAll() { +void App::saveAll( bool includeBuffers ) { mTmpDocs.clear(); - mSplitter->forEachEditor( [this]( UICodeEditor* editor ) { - if ( editor->isDirty() ) + mSplitter->forEachEditor( [&]( UICodeEditor* editor ) { + if ( editor->isDirty() && ( includeBuffers || editor->getDocument().hasFilepath() ) ) mTmpDocs.insert( &editor->getDocument() ); } ); saveAllProcess(); @@ -1739,8 +1739,8 @@ void App::onTabCreated( UITab* tab, UIWidget* ) { menuAdd( "open_containing_folder_in_fm", "Open Containing Folder in File Manager", "folder-open", "open-containing-folder" ); - menuAdd( "copy_containing_folder_path", "Copy Containing Folder Path", - "copy", "copy-containing-folder-path" ); + menuAdd( "copy_containing_folder_path", "Copy Containing Folder Path", "copy", + "copy-containing-folder-path" ); menuAdd( "copy_file_path", "Copy File Path", "copy", "copy-file-path" ); @@ -3273,9 +3273,8 @@ void App::onCodeEditorCreated( UICodeEditor* editor, TextDocument& doc ) { } ); mdView->loadFromString( doc->toUtf8String() ); - auto title = - i18n( "markdown_live_preview_colon", "Markdown Live Preview:" ) + " " + - doc->getFilename(); + auto title = i18n( "markdown_live_preview_colon", "Markdown Live Preview:" ) + + " " + doc->getFilename(); auto [tab, _] = getSplitter()->createWidgetInTabWidget( tabWidget, scrollView, title ); tab->setIcon( findIcon( "filetype-md" ) ); diff --git a/src/tools/ecode/ecode.hpp b/src/tools/ecode/ecode.hpp index 399bd39ff..0a615bc38 100644 --- a/src/tools/ecode/ecode.hpp +++ b/src/tools/ecode/ecode.hpp @@ -103,7 +103,7 @@ class App : public UICodeEditorSplitter::Client, public PluginContextProvider { std::vector getUnlockedCommands(); - void saveAll(); + void saveAll( bool includeBuffers = true); ProjectDirectoryTree* getDirTree() const; diff --git a/src/tools/ecode/projectbuild.cpp b/src/tools/ecode/projectbuild.cpp index e8c252016..f24e63700 100644 --- a/src/tools/ecode/projectbuild.cpp +++ b/src/tools/ecode/projectbuild.cpp @@ -765,7 +765,7 @@ void ProjectBuildManager::buildCurrentConfig( StatusBuildOutputController* sboc, if ( sboc && !isBuilding() && !getBuilds().empty() ) { const ProjectBuild* build = getCurrentBuild(); if ( build ) { - mApp->saveAll(); + mApp->saveAll( false ); sboc->runBuild( build->getName(), mConfig.buildType, getOutputParser( build->getName() ), false, doneFn ); } diff --git a/src/tools/ecode/uibuildsettings.hpp b/src/tools/ecode/uibuildsettings.hpp index 122da1972..4181cc684 100644 --- a/src/tools/ecode/uibuildsettings.hpp +++ b/src/tools/ecode/uibuildsettings.hpp @@ -15,9 +15,9 @@ namespace ecode { class UIBuildSettings : public UIRelativeLayout { public: static UIBuildSettings* - New( ProjectBuild& build, ProjectBuildConfiguration& config, bool isNew, - const std::function onBuildNameChange ); + const std::function + onBuildNameChange ); virtual ~UIBuildSettings(); @@ -39,8 +39,10 @@ class UIBuildSettings : public UIRelativeLayout { bool mCanceled{ false }; std::function mNewNameFn; - explicit UIBuildSettings( ProjectBuild& build, ProjectBuildConfiguration& config, bool isNew, - const std::function onBuildNameChange ); + explicit UIBuildSettings( + ProjectBuild& build, ProjectBuildConfiguration& config, bool isNew, + const std::function + onBuildNameChange ); void moveStepUp( size_t stepNum, bool isClean );