diff --git a/src/eepp/ui/uimenu.cpp b/src/eepp/ui/uimenu.cpp index 0b3a9c0c8..3e7717acf 100644 --- a/src/eepp/ui/uimenu.cpp +++ b/src/eepp/ui/uimenu.cpp @@ -137,8 +137,9 @@ bool UIMenu::widgetCheckSize( UIWidget* widget, const bool& resize ) { tItem->getIcon()->getSize().getWidth(); } if ( mFlags & UI_AUTO_SIZE ) { - if ( widget->getPixelsSize().getWidth() > (Int32)mMaxWidth ) { - mMaxWidth = widget->getPixelsSize().getWidth(); + Sizef contentSize( tItem->getContentSize() ); + if ( contentSize.getWidth() > (Int32)mMaxWidth ) { + mMaxWidth = contentSize.getWidth(); if ( resize ) { widgetsResize(); return true; diff --git a/src/eepp/ui/uimenuitem.cpp b/src/eepp/ui/uimenuitem.cpp index f05c86f2b..901aeb14f 100644 --- a/src/eepp/ui/uimenuitem.cpp +++ b/src/eepp/ui/uimenuitem.cpp @@ -8,6 +8,8 @@ UIMenuItem* UIMenuItem::New() { } UIMenuItem::UIMenuItem( const std::string& tag ) : UIPushButton( tag ), mShortcutView( NULL ) { + unsetFlags( UI_AUTO_SIZE ); + setLayoutSizePolicy( SizePolicy::Fixed, SizePolicy::WrapContent ); mIcon->setElementTag( mTag + "::icon" ); mTextBox->setElementTag( mTag + "::text" ); applyDefaultTheme(); diff --git a/src/eepp/ui/uitreeview.cpp b/src/eepp/ui/uitreeview.cpp index b8ccd4899..f0b718e28 100644 --- a/src/eepp/ui/uitreeview.cpp +++ b/src/eepp/ui/uitreeview.cpp @@ -129,6 +129,7 @@ UITableRow* UITreeView::updateRow( const int& rowIndex, const ModelIndex& index, rowWidget->setPixelsSize( getContentSize().getWidth(), getRowHeight() ); rowWidget->setPixelsPosition( {-mScrollOffset.x, yOffset - mScrollOffset.y} ); if ( getSelection().first() == index ) { + rowWidget->clearActions(); rowWidget->pushState( UIState::StateSelected ); } else { rowWidget->popState( UIState::StateSelected ); diff --git a/src/tools/codeeditor/codeeditor.cpp b/src/tools/codeeditor/codeeditor.cpp index b29f2f805..b1440f038 100644 --- a/src/tools/codeeditor/codeeditor.cpp +++ b/src/tools/codeeditor/codeeditor.cpp @@ -127,11 +127,11 @@ void App::saveFileDialog() { dialog->show(); } -void App::findPrevText( SearchState& search ) { +bool App::findPrevText( SearchState& search ) { if ( search.text.empty() ) search.text = mLastSearch; if ( !search.editor || !mEditorSplitter->editorExists( search.editor ) || search.text.empty() ) - return; + return false; search.editor->getDocument().setActiveClient( search.editor ); mLastSearch = search.text; @@ -146,19 +146,22 @@ void App::findPrevText( SearchState& search ) { TextPosition found = doc.findLast( search.text, from, search.caseSensitive, search.range ); if ( found.isValid() ) { doc.setSelection( {doc.positionOffset( found, search.text.size() ), found} ); + return true; } else { found = doc.findLast( search.text, range.end() ); if ( found.isValid() ) { doc.setSelection( {doc.positionOffset( found, search.text.size() ), found} ); + return true; } } + return false; } -void App::findNextText( SearchState& search ) { +bool App::findNextText( SearchState& search ) { if ( search.text.empty() ) search.text = mLastSearch; if ( !search.editor || !mEditorSplitter->editorExists( search.editor ) || search.text.empty() ) - return; + return false; search.editor->getDocument().setActiveClient( search.editor ); mLastSearch = search.text; @@ -173,30 +176,35 @@ void App::findNextText( SearchState& search ) { TextPosition found = doc.find( search.text, from, search.caseSensitive, range ); if ( found.isValid() ) { doc.setSelection( {doc.positionOffset( found, search.text.size() ), found} ); + return true; } else { found = doc.find( search.text, range.start(), search.caseSensitive, range ); if ( found.isValid() ) { doc.setSelection( {doc.positionOffset( found, search.text.size() ), found} ); + return true; } } + return false; } -void App::replaceSelection( SearchState& search, const String& replacement ) { +bool App::replaceSelection( SearchState& search, const String& replacement ) { if ( !search.editor || !mEditorSplitter->editorExists( search.editor ) || !search.editor->getDocument().hasSelection() ) - return; + return false; search.editor->getDocument().setActiveClient( search.editor ); search.editor->getDocument().replaceSelection( replacement ); + return true; } -void App::replaceAll( SearchState& search, const String& replace ) { +int App::replaceAll( SearchState& search, const String& replace ) { if ( !search.editor || !mEditorSplitter->editorExists( search.editor ) ) - return; + return 0; if ( search.text.empty() ) search.text = mLastSearch; if ( search.text.empty() ) - return; + return 0; + int count = 0; search.editor->getDocument().setActiveClient( search.editor ); mLastSearch = search.text; TextDocument& doc = search.editor->getDocument(); @@ -210,25 +218,27 @@ void App::replaceAll( SearchState& search, const String& replace ) { if ( found.isValid() ) { doc.setSelection( {doc.positionOffset( found, search.text.size() ), found} ); from = doc.replaceSelection( replace ); + count++; } } while ( found.isValid() ); doc.setSelection( startedPosition ); + return count; } -void App::findAndReplace( SearchState& search, const String& replace ) { +bool App::findAndReplace( SearchState& search, const String& replace ) { if ( !search.editor || !mEditorSplitter->editorExists( search.editor ) ) - return; + return false; if ( search.text.empty() ) search.text = mLastSearch; if ( search.text.empty() ) - return; + return false; search.editor->getDocument().setActiveClient( search.editor ); mLastSearch = search.text; TextDocument& doc = search.editor->getDocument(); if ( doc.hasSelection() && doc.getSelectedText() == search.text ) { - replaceSelection( search, replace ); + return replaceSelection( search, replace ); } else { - findNextText( search ); + return findNextText( search ); } } @@ -374,7 +384,11 @@ void App::initSearchBar() { mSearchState.editor->setHighlightWord( mSearchState.text ); if ( !mSearchState.text.empty() ) { mSearchState.editor->getDocument().setSelection( {0, 0} ); - findNextText( mSearchState ); + if ( !findNextText( mSearchState ) ) { + findInput->addClass( "error" ); + } else { + findInput->removeClass( "error" ); + } } else { mSearchState.editor->getDocument().setSelection( mSearchState.editor->getDocument().getSelection().start() ); @@ -1475,6 +1489,10 @@ void App::init( const std::string& file, const Float& pidelDensity ) { #doc_info > TextView { color: var(--font); } + #search_find.error, + #search_replace.error { + border-color: red; + } diff --git a/src/tools/codeeditor/codeeditor.hpp b/src/tools/codeeditor/codeeditor.hpp index e5c3e2ba1..f263b0d8a 100644 --- a/src/tools/codeeditor/codeeditor.hpp +++ b/src/tools/codeeditor/codeeditor.hpp @@ -106,9 +106,9 @@ class App : public UICodeEditorSplitter::Client { void saveFileDialog(); - void findPrevText( SearchState& search ); + bool findPrevText( SearchState& search ); - void findNextText( SearchState& search ); + bool findNextText( SearchState& search ); void closeApp(); @@ -116,11 +116,11 @@ class App : public UICodeEditorSplitter::Client { void showFindView(); - void replaceSelection( SearchState& search, const String& replacement ); + bool replaceSelection( SearchState& search, const String& replacement ); - void replaceAll( SearchState& search, const String& replace ); + int replaceAll( SearchState& search, const String& replace ); - void findAndReplace( SearchState& search, const String& replace ); + bool findAndReplace( SearchState& search, const String& replace ); void runCommand( const std::string& command );