diff --git a/include/eepp/ui/uicodeeditor.hpp b/include/eepp/ui/uicodeeditor.hpp index 69ac4c068..f14f51663 100644 --- a/include/eepp/ui/uicodeeditor.hpp +++ b/include/eepp/ui/uicodeeditor.hpp @@ -783,6 +783,15 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client { bool isEnabledFlashCursor() { return mEnableFlashCursor; } + void setCursorVisible( bool visible ); + + bool isCursorVisible() const; + + void setDisableCursorBlinkingAfterAMinuteOfInactivity( + bool diableCursorBlinkingAfterAMinuteOfInactivity ); + + bool isCursorBlinkingAfterAMinuteOfInactivityDisabled() const; + protected: struct LastXOffset { TextPosition position{ 0, 0 }; @@ -831,6 +840,7 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client { bool mFoldsVisible{ false }; bool mFoldsIsFirst{ true }; bool mEnableFlashCursor{ false }; + bool mDisableCursorBlinkingAfterAMinuteOfInactivity{ true }; Uint32 mTabWidth; std::atomic mHighlightWordProcessing{ false }; TextRange mLinkPosition; diff --git a/include/eepp/ui/uihelper.hpp b/include/eepp/ui/uihelper.hpp index d231c39c3..9521d02f8 100644 --- a/include/eepp/ui/uihelper.hpp +++ b/include/eepp/ui/uihelper.hpp @@ -43,6 +43,7 @@ enum UIFlag { UI_TOOLTIP_ENABLED = ( 1 << 26 ), UI_SCROLLABLE = ( 1 << 27 ), UI_HIGHLIGHT = ( 1 << 28 ), + UI_PARENT_ATTRIBUTE_CHANGED = ( 1 << 29 ), }; enum UINodeType { diff --git a/src/eepp/ui/uicodeeditor.cpp b/src/eepp/ui/uicodeeditor.cpp index 134ce4096..a896d2f24 100644 --- a/src/eepp/ui/uicodeeditor.cpp +++ b/src/eepp/ui/uicodeeditor.cpp @@ -416,7 +416,8 @@ void UICodeEditor::draw() { } void UICodeEditor::scheduledUpdate( const Time& ) { - if ( mLastActivity.getElapsedTime() > Seconds( 60 ) ) { + if ( mDisableCursorBlinkingAfterAMinuteOfInactivity && + mLastActivity.getElapsedTime() > Seconds( 60 ) ) { if ( !mCursorVisible ) { mCursorVisible = true; invalidateDraw(); @@ -2538,11 +2539,15 @@ const bool& UICodeEditor::isLocked() const { void UICodeEditor::setLocked( bool locked ) { if ( mLocked != locked ) { mLocked = locked; - if ( !mLocked && hasFocus() ) { - resetCursor(); - getUISceneNode()->getWindow()->startTextInput(); - mDoc->setActiveClient( this ); - updateIMELocation(); + if ( !mLocked ) { + if ( hasFocus() ) { + resetCursor(); + getUISceneNode()->getWindow()->startTextInput(); + mDoc->setActiveClient( this ); + updateIMELocation(); + } else { + mCursorVisible = false; + } } invalidateDraw(); } @@ -5281,4 +5286,24 @@ bool UICodeEditor::isScrollable() const { ( (Int64)getTotalVisibleLines() - (Int64)getViewPortLineCount().y > 0 ); } +void UICodeEditor::setCursorVisible( bool visible ) { + if ( visible != mCursorVisible ) { + mCursorVisible = visible; + invalidateDraw(); + } +} + +bool UICodeEditor::isCursorVisible() const { + return mCursorVisible; +} + +void UICodeEditor::setDisableCursorBlinkingAfterAMinuteOfInactivity( + bool diableCursorBlinkingAfterAMinuteOfInactivity ) { + mDisableCursorBlinkingAfterAMinuteOfInactivity = diableCursorBlinkingAfterAMinuteOfInactivity; +} + +bool UICodeEditor::isCursorBlinkingAfterAMinuteOfInactivityDisabled() const { + return mDisableCursorBlinkingAfterAMinuteOfInactivity; +} + }} // namespace EE::UI diff --git a/src/eepp/ui/uiwidget.cpp b/src/eepp/ui/uiwidget.cpp index 6fd789de4..b6596a9af 100644 --- a/src/eepp/ui/uiwidget.cpp +++ b/src/eepp/ui/uiwidget.cpp @@ -100,6 +100,7 @@ UIWidget* UIWidget::setLayoutMargin( const Rectf& margin ) { mLayoutMarginPx = PixelDensity::dpToPx( mLayoutMargin ).ceil(); onMarginChange(); notifyLayoutAttrChange(); + notifyLayoutAttrChangeParent(); } return this; @@ -111,6 +112,7 @@ UIWidget* UIWidget::setLayoutMarginLeft( const Float& marginLeft ) { mLayoutMarginPx.Left = eeceil( PixelDensity::dpToPx( mLayoutMargin.Left ) ); onMarginChange(); notifyLayoutAttrChange(); + notifyLayoutAttrChangeParent(); } return this; @@ -122,6 +124,7 @@ UIWidget* UIWidget::setLayoutMarginRight( const Float& marginRight ) { mLayoutMarginPx.Right = eeceil( PixelDensity::dpToPx( mLayoutMargin.Right ) ); onMarginChange(); notifyLayoutAttrChange(); + notifyLayoutAttrChangeParent(); } return this; @@ -133,6 +136,7 @@ UIWidget* UIWidget::setLayoutMarginTop( const Float& marginTop ) { mLayoutMarginPx.Top = eeceil( PixelDensity::dpToPx( mLayoutMargin.Top ) ); onMarginChange(); notifyLayoutAttrChange(); + notifyLayoutAttrChangeParent(); } return this; @@ -144,6 +148,7 @@ UIWidget* UIWidget::setLayoutMarginBottom( const Float& marginBottom ) { mLayoutMarginPx.Bottom = eeceil( PixelDensity::dpToPx( mLayoutMargin.Bottom ) ); onMarginChange(); notifyLayoutAttrChange(); + notifyLayoutAttrChangeParent(); } return this; @@ -155,6 +160,7 @@ UIWidget* UIWidget::setLayoutPixelsMargin( const Rectf& margin ) { mLayoutMargin = PixelDensity::pxToDp( mLayoutMarginPx ).ceil(); onMarginChange(); notifyLayoutAttrChange(); + notifyLayoutAttrChangeParent(); } return this; @@ -166,6 +172,7 @@ UIWidget* UIWidget::setLayoutPixelsMarginLeft( const Float& marginLeft ) { mLayoutMargin.Left = eeceil( PixelDensity::pxToDp( mLayoutMarginPx.Left ) ); onMarginChange(); notifyLayoutAttrChange(); + notifyLayoutAttrChangeParent(); } return this; @@ -177,6 +184,7 @@ UIWidget* UIWidget::setLayoutPixelsMarginRight( const Float& marginRight ) { mLayoutMargin.Right = eeceil( PixelDensity::pxToDp( mLayoutMarginPx.Right ) ); onMarginChange(); notifyLayoutAttrChange(); + notifyLayoutAttrChangeParent(); } return this; @@ -188,6 +196,7 @@ UIWidget* UIWidget::setLayoutPixelsMarginTop( const Float& marginTop ) { mLayoutMargin.Top = eeceil( PixelDensity::pxToDp( mLayoutMarginPx.Top ) ); onMarginChange(); notifyLayoutAttrChange(); + notifyLayoutAttrChangeParent(); } return this; @@ -199,6 +208,7 @@ UIWidget* UIWidget::setLayoutPixelsMarginBottom( const Float& marginBottom ) { mLayoutMargin.Bottom = eeceil( PixelDensity::pxToDp( mLayoutMarginPx.Bottom ) ); onMarginChange(); notifyLayoutAttrChange(); + notifyLayoutAttrChangeParent(); } return this; @@ -558,9 +568,13 @@ void UIWidget::notifyLayoutAttrChange() { } void UIWidget::notifyLayoutAttrChangeParent() { - if ( 0 == mAttributesTransactionCount && NULL != mParentNode ) { + if ( NULL == mParentNode ) return; + + if ( 0 == mAttributesTransactionCount ) { NodeMessage msg( this, NodeMessage::LayoutAttributeChange ); mParentNode->messagePost( &msg ); + } else { + mFlags |= UI_PARENT_ATTRIBUTE_CHANGED; } } @@ -1151,6 +1165,12 @@ void UIWidget::endAttributesTransaction() { mFlags &= ~UI_ATTRIBUTE_CHANGED; } + + if ( mFlags & UI_PARENT_ATTRIBUTE_CHANGED ) { + notifyLayoutAttrChangeParent(); + + mFlags &= ~UI_PARENT_ATTRIBUTE_CHANGED; + } } } diff --git a/src/tools/ecode/plugins/debugger/debuggerplugin.cpp b/src/tools/ecode/plugins/debugger/debuggerplugin.cpp index b75361fad..8335254d0 100644 --- a/src/tools/ecode/plugins/debugger/debuggerplugin.cpp +++ b/src/tools/ecode/plugins/debugger/debuggerplugin.cpp @@ -1325,15 +1325,17 @@ void DebuggerPlugin::onRegisterDocument( TextDocument* doc ) { if ( exitCode == 0 ) { runCurrentConfig(); } else { - auto msgBox = - UIMessageBox::New( UIMessageBox::YES_NO, - i18n( "build_failed_debug_anyways", - "Building the project failed, do you want to " - "debug the binary anyways?" ) ); - msgBox->setTitle( i18n( "build_failed", "Build Failed" ) ); - msgBox->setCloseShortcut( { KEY_ESCAPE, KEYMOD_NONE } ); - msgBox->on( Event::OnConfirm, [this]( auto ) { runCurrentConfig(); } ); - msgBox->showWhenReady(); + getPluginContext()->getUISceneNode()->runOnMainThread( [this] { + auto msgBox = UIMessageBox::New( + UIMessageBox::YES_NO, + i18n( "build_failed_debug_anyways", + "Building the project failed, do you want to " + "debug the binary anyways?" ) ); + msgBox->setTitle( i18n( "build_failed", "Build Failed" ) ); + msgBox->setCloseShortcut( { KEY_ESCAPE, KEYMOD_NONE } ); + msgBox->on( Event::OnConfirm, [this]( auto ) { runCurrentConfig(); } ); + msgBox->showWhenReady(); + } ); } } ); }