mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-27 08:37:58 +03:00
SyntaxDefinitionManager: Improved JSON patterns.
UIAbstractTableView: Fixed a minor bug. WidgetTreeModel: Added ID column. ecode: Added debug node tree view.
This commit is contained in:
@@ -11,12 +11,20 @@ namespace EE { namespace UI { namespace Models {
|
||||
|
||||
class EE_API WidgetTreeModel : public Model {
|
||||
public:
|
||||
enum Column {
|
||||
Type = 0,
|
||||
ID,
|
||||
Count,
|
||||
};
|
||||
|
||||
static std::shared_ptr<WidgetTreeModel> New( Node* node );
|
||||
|
||||
virtual size_t rowCount( const ModelIndex& = ModelIndex() ) const override;
|
||||
|
||||
virtual size_t columnCount( const ModelIndex& = ModelIndex() ) const override;
|
||||
|
||||
virtual std::string columnName( const size_t& /*column*/ ) const override;
|
||||
|
||||
virtual Variant data( const ModelIndex&, ModelRole role = ModelRole::Display ) const override;
|
||||
|
||||
virtual ModelIndex index( int row, int column,
|
||||
|
||||
@@ -141,12 +141,15 @@ class EE_API UICodeEditorSplitter {
|
||||
|
||||
const std::vector<UITabWidget*>& getTabWidgets() const;
|
||||
|
||||
Node* getBaseLayout() const;
|
||||
|
||||
protected:
|
||||
UISceneNode* mUISceneNode{ nullptr };
|
||||
UICodeEditor* mCurEditor{ nullptr };
|
||||
std::map<std::string, SyntaxColorScheme> mColorSchemes;
|
||||
std::string mCurrentColorScheme;
|
||||
std::vector<UITabWidget*> mTabWidgets;
|
||||
Node* mBaseLayout{ nullptr };
|
||||
Client* mClient;
|
||||
bool mHideTabBarOnSingleTab{ true };
|
||||
|
||||
|
||||
@@ -95,27 +95,6 @@ void UIAbstractTableView::createOrUpdateColumns() {
|
||||
|
||||
auto visibleColCount = visibleColumnCount();
|
||||
|
||||
if ( mAutoColumnsWidth && visibleColCount > 1 && getModel()->rowCount() > 0 ) {
|
||||
Float contentWidth = getContentSpaceWidth();
|
||||
bool shouldVScrollBeVisible = shouldVerticalScrollBeVisible();
|
||||
if ( !mVScroll->isVisible() && shouldVScrollBeVisible )
|
||||
contentWidth -= getVerticalScrollBar()->getPixelsSize().getWidth();
|
||||
else if ( mVScroll->isVisible() && !shouldVScrollBeVisible )
|
||||
contentWidth += getVerticalScrollBar()->getPixelsSize().getWidth();
|
||||
Float usedWidth = 0;
|
||||
for ( size_t col = 0; col < count; col++ ) {
|
||||
if ( col != mMainColumn && !isColumnHidden( col ) ) {
|
||||
Float colWidth = getMaxColumnContentWidth( col, true );
|
||||
usedWidth += colWidth;
|
||||
columnData( col ).width = colWidth;
|
||||
}
|
||||
}
|
||||
Float mainColMaxWidth = getMaxColumnContentWidth( mMainColumn, true );
|
||||
columnData( mMainColumn ).width = contentWidth - usedWidth >= mainColMaxWidth
|
||||
? contentWidth - usedWidth
|
||||
: mainColMaxWidth;
|
||||
}
|
||||
|
||||
for ( size_t i = 0; i < count; i++ ) {
|
||||
ColumnData& col = columnData( i );
|
||||
if ( !col.widget ) {
|
||||
@@ -140,6 +119,29 @@ void UIAbstractTableView::createOrUpdateColumns() {
|
||||
col.widget->setPixelsSize( col.width, getHeaderHeight() );
|
||||
}
|
||||
|
||||
if ( mAutoColumnsWidth && visibleColCount > 1 && getModel()->rowCount() > 0 ) {
|
||||
Float contentWidth = getContentSpaceWidth();
|
||||
bool shouldVScrollBeVisible = shouldVerticalScrollBeVisible();
|
||||
if ( !mVScroll->isVisible() && shouldVScrollBeVisible )
|
||||
contentWidth -= getVerticalScrollBar()->getPixelsSize().getWidth();
|
||||
else if ( mVScroll->isVisible() && !shouldVScrollBeVisible )
|
||||
contentWidth += getVerticalScrollBar()->getPixelsSize().getWidth();
|
||||
Float usedWidth = 0;
|
||||
for ( size_t col = 0; col < count; col++ ) {
|
||||
if ( col != mMainColumn && !isColumnHidden( col ) ) {
|
||||
Float colWidth = getMaxColumnContentWidth( col, true );
|
||||
if ( colWidth == 0 )
|
||||
colWidth = columnData( col ).widget->getPixelsSize().getWidth();
|
||||
usedWidth += colWidth;
|
||||
columnData( col ).width = colWidth;
|
||||
}
|
||||
}
|
||||
Float mainColMaxWidth = getMaxColumnContentWidth( mMainColumn, true );
|
||||
columnData( mMainColumn ).width = contentWidth - usedWidth >= mainColMaxWidth
|
||||
? contentWidth - usedWidth
|
||||
: mainColMaxWidth;
|
||||
}
|
||||
|
||||
mHeaderHeight = 0;
|
||||
for ( size_t i = 0; i < count; i++ ) {
|
||||
ColumnData& col = columnData( i );
|
||||
|
||||
@@ -109,6 +109,7 @@ SyntaxDefinitionManager::SyntaxDefinitionManager() {
|
||||
{ { "```[Cc]", "```" }, "function", "C" },
|
||||
{ { "```[Dd]", "```" }, "function", "D" },
|
||||
{ { "```[Ll]ua", "```" }, "function", "Lua" },
|
||||
{ { "```[Jj][Ss][Oo][Nn]", "```" }, "function", "JSON" },
|
||||
{ { "```[Ja]va[Ss]cript", "```" }, "function", "JavaScript" },
|
||||
{ { "```[Tt]ype[Ss]cript", "```" }, "function", "TypeScript" },
|
||||
{ { "```[Pp]ython", "```" }, "function", "Python" },
|
||||
@@ -266,7 +267,7 @@ SyntaxDefinitionManager::SyntaxDefinitionManager() {
|
||||
add( { "JSON",
|
||||
{ "%.json$", "%.cson$" },
|
||||
{
|
||||
{ { "(\".-\")(:)" }, { "normal", "keyword", "operator" } },
|
||||
{ { "(%b\"\")(:)" }, { "normal", "keyword", "operator" } },
|
||||
{ { "\"", "\"", "\\" }, "string" },
|
||||
{ { "'", "'", "\\" }, "string" },
|
||||
{ { "`", "`", "\\" }, "string" },
|
||||
|
||||
@@ -19,23 +19,41 @@ size_t WidgetTreeModel::rowCount( const ModelIndex& index ) const {
|
||||
}
|
||||
|
||||
size_t WidgetTreeModel::columnCount( const ModelIndex& ) const {
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
std::string WidgetTreeModel::columnName( const size_t& col ) const {
|
||||
switch ( col ) {
|
||||
case Column::Type:
|
||||
return "Type";
|
||||
case Column::ID:
|
||||
return "ID";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
Variant WidgetTreeModel::data( const ModelIndex& index, ModelRole role ) const {
|
||||
const char* EMPTY = "";
|
||||
Node* node = static_cast<Node*>( index.internalData() );
|
||||
|
||||
if ( role == ModelRole::Display ) {
|
||||
if ( node->isWidget() ) {
|
||||
return Variant( node->asType<UIWidget>()->getElementTag().c_str() );
|
||||
} else if ( node->isUISceneNode() ) {
|
||||
return Variant( "UISceneNode" );
|
||||
} else if ( node->isSceneNode() ) {
|
||||
return Variant( "SceneNode" );
|
||||
} else {
|
||||
return Variant( node->getId().empty() ? "Node" : node->getId() );
|
||||
switch ( index.column() ) {
|
||||
case Column::Type: {
|
||||
if ( node->isWidget() ) {
|
||||
return Variant( node->asType<UIWidget>()->getElementTag().c_str() );
|
||||
} else if ( node->isUISceneNode() ) {
|
||||
return Variant( "UISceneNode" );
|
||||
} else if ( node->isSceneNode() ) {
|
||||
return Variant( "SceneNode" );
|
||||
} else {
|
||||
return Variant( node->getId().empty() ? "Node" : node->getId() );
|
||||
}
|
||||
}
|
||||
case Column::ID:
|
||||
return Variant( node->getId() );
|
||||
}
|
||||
}
|
||||
|
||||
return Variant( EMPTY );
|
||||
}
|
||||
|
||||
|
||||
@@ -409,6 +409,8 @@ void UICodeEditorSplitter::removeUnusedTab( UITabWidget* tabWidget ) {
|
||||
}
|
||||
|
||||
UITabWidget* UICodeEditorSplitter::createEditorWithTabWidget( Node* parent ) {
|
||||
if ( nullptr == mBaseLayout )
|
||||
mBaseLayout = parent;
|
||||
UICodeEditor* prevCurEditor = mCurEditor;
|
||||
UITabWidget* tabWidget = UITabWidget::New();
|
||||
tabWidget->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent );
|
||||
@@ -526,6 +528,10 @@ const std::vector<UITabWidget*>& UICodeEditorSplitter::getTabWidgets() const {
|
||||
return mTabWidgets;
|
||||
}
|
||||
|
||||
Node* UICodeEditorSplitter::getBaseLayout() const {
|
||||
return mBaseLayout;
|
||||
}
|
||||
|
||||
std::vector<UICodeEditor*> UICodeEditorSplitter::getAllEditors() {
|
||||
std::vector<UICodeEditor*> editors;
|
||||
forEachEditor( [&]( UICodeEditor* editor ) { editors.push_back( editor ); } );
|
||||
|
||||
@@ -448,6 +448,21 @@ App::~App() {
|
||||
eeSAFE_DELETE( mConsole );
|
||||
}
|
||||
|
||||
void App::createWidgetTreeView() {
|
||||
UIWindow* uiWin = UIWindow::NewOpt( UIWindow::LINEAR_LAYOUT );
|
||||
uiWin->setMinWindowSize( 600, 400 );
|
||||
uiWin->setWinFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_RESIZEABLE | UI_WIN_MAXIMIZE_BUTTON );
|
||||
UITreeView* widgetTree = UITreeView::New();
|
||||
widgetTree->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent );
|
||||
widgetTree->setParent( uiWin );
|
||||
widgetTree->setHeadersVisible( true );
|
||||
widgetTree->setAutoExpandOnSingleColumn( true );
|
||||
widgetTree->setExpanderIconSize( mMenuIconSize );
|
||||
widgetTree->setAutoColumnsWidth( true );
|
||||
widgetTree->setModel( WidgetTreeModel::New( mUISceneNode ) );
|
||||
uiWin->center();
|
||||
}
|
||||
|
||||
void App::updateRecentFiles() {
|
||||
UINode* node = nullptr;
|
||||
if ( mSettingsMenu && ( node = mSettingsMenu->getItem( "Recent Files" ) ) ) {
|
||||
@@ -1689,6 +1704,7 @@ std::map<KeyBindings::Shortcut, std::string> App::getLocalKeybindings() {
|
||||
{ { KEY_F6, KEYMOD_NONE }, "debug-draw-highlight-toggle" },
|
||||
{ { KEY_F7, KEYMOD_NONE }, "debug-draw-boxes-toggle" },
|
||||
{ { KEY_F8, KEYMOD_NONE }, "debug-draw-debug-data" },
|
||||
{ { KEY_F11, KEYMOD_NONE }, "debug-widget-tree-view" },
|
||||
{ { KEY_K, KeyMod::getDefaultModifier() }, "open-locatebar" },
|
||||
{ { KEY_F, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "open-global-search" },
|
||||
{ { KEY_L, KeyMod::getDefaultModifier() }, "go-to-line" },
|
||||
@@ -1949,6 +1965,7 @@ void App::onCodeEditorCreated( UICodeEditor* editor, TextDocument& doc ) {
|
||||
} );
|
||||
doc.setCommand( "debug-draw-debug-data",
|
||||
[&] { mUISceneNode->setDrawDebugData( !mUISceneNode->getDrawDebugData() ); } );
|
||||
doc.setCommand( "debug-widget-tree-view", [&] { createWidgetTreeView(); } );
|
||||
doc.setCommand( "go-to-line", [&] { mFileLocator->goToLine(); } );
|
||||
doc.setCommand( "load-current-dir", [&] { loadCurrentDirectory(); } );
|
||||
doc.setCommand( "menu-toggle", [&] { toggleSettingsMenu(); } );
|
||||
@@ -3012,14 +3029,15 @@ void App::init( std::string file, const Float& pidelDensity, const std::string&
|
||||
<TextView layout_width="wrap_content" layout_height="wrap_content" text="Search for:" margin-right="4dp" />
|
||||
<vbox layout_width="0" layout_weight="1" layout_height="wrap_content">
|
||||
<TextInput id="global_search_find" layout_width="match_parent" layout_height="wrap_content" layout_height="18dp" padding="0" margin-bottom="2dp" />
|
||||
<hbox layout_width="match_parent" layout_height="wrap_content">
|
||||
<hbox layout_width="match_parent" layout_height="wrap_content" margin-bottom="4dp">
|
||||
<CheckBox id="case_sensitive" layout_width="wrap_content" layout_height="wrap_content" text="Case sensitive" selected="true" />
|
||||
<CheckBox id="whole_word" layout_width="wrap_content" layout_height="wrap_content" text="Match Whole Word" selected="false" margin-left="8dp" />
|
||||
<CheckBox id="lua_pattern" layout_width="wrap_content" layout_height="wrap_content" text="Lua Pattern" selected="false" margin-left="8dp" />
|
||||
<CheckBox id="escape_sequence" layout_width="wrap_content" layout_height="wrap_content" text="Use escape sequences" margin-left="8dp" selected="false" tooltip="Replace \\, \t, \n, \r and \uXXXX (Unicode characters) with the corresponding control" />
|
||||
<Widget layout_width="0" layout_weight="1" layout_height="match_parent" />
|
||||
</hbox>
|
||||
<hbox layout_width="match_parent" layout_height="wrap_content">
|
||||
<TextView layout_width="wrap_content" layout_height="wrap_content" text="History:" margin-right="4dp" layout_height="18dp" />
|
||||
<DropDownList id="global_search_history" layout_width="300dp" layout_height="18dp" margin-right="4dp" />
|
||||
<DropDownList id="global_search_history" layout_width="0" layout_height="18dp" layout_weight="1" margin-right="4dp" />
|
||||
<PushButton id="global_search_clear_history" layout_width="wrap_content" layout_height="18dp" text="Clear History" margin-right="4dp" />
|
||||
<PushButton id="global_search" layout_width="wrap_content" layout_height="18dp" text="Search" margin-right="4dp" />
|
||||
<PushButton id="global_search_replace" layout_width="wrap_content" layout_height="18dp" text="Search & Replace" />
|
||||
@@ -3068,8 +3086,8 @@ void App::init( std::string file, const Float& pidelDensity, const std::string&
|
||||
{ "zoom-reset", 0xeb47 },
|
||||
{ "fullscreen", 0xed9c },
|
||||
{ "keybindings", 0xee75 },
|
||||
{ "tree-expanded", 0xea50 },
|
||||
{ "tree-contracted", 0xea54 },
|
||||
// { "tree-expanded", 0xea50 },
|
||||
// { "tree-contracted", 0xea54 },
|
||||
{ "search", 0xf0d1 },
|
||||
{ "go-up", 0xea78 },
|
||||
{ "ok", 0xeb7a },
|
||||
@@ -3151,6 +3169,8 @@ void App::init( std::string file, const Float& pidelDensity, const std::string&
|
||||
{ "file", 61766 },
|
||||
{ "folder", 0xF23B },
|
||||
{ "folder-open", 0xF23C },
|
||||
{ "tree-expanded", 0xF11E },
|
||||
{ "tree-contracted", 0xF120 },
|
||||
};
|
||||
for ( const auto& icon : mimeIcons )
|
||||
iconTheme->add( UIGlyphIcon::New( icon.first, mimeIconFont, icon.second ) );
|
||||
|
||||
@@ -24,6 +24,8 @@ class App : public UICodeEditorSplitter::Client {
|
||||
|
||||
~App();
|
||||
|
||||
void createWidgetTreeView();
|
||||
|
||||
void init( std::string file, const Float& pidelDensity, const std::string& colorScheme );
|
||||
|
||||
void setAppTitle( const std::string& title );
|
||||
|
||||
Reference in New Issue
Block a user