MCPcopy Create free account
hub / github.com/SpartanJ/eepp / createContainer

Method createContainer

src/tools/ecode/statusterminalcontroller.cpp:50–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50UIHLinearLayoutCommandExecuter* StatusTerminalController::createContainer() {
51 if ( mContainer )
52 return mContainer;
53 static const auto XML = R"xml(
54 <hboxce id="terminal_panel" class="tab_widget_cont" lw="mp" lh="mp">
55 <TabWidget id="terminal_panel_tab_widget" lw="0dp" lh="mp" lw8="1"
56 tabbar-hide-on-single-tab="true"
57 tabbar-allow-rearrange="true"
58 tabbar-allow-drag-and-drop-tabs="true"
59 tabbar-allow-switch-tabs-in-empty-spaces="true"
60 tab-close-button-visible="true"
61 tab-closable="true"></TabWidget>
62 <vbox lw="16dp" lh="mp" class="vertical_bar">
63 <PushButton class="expand_status_bar_panel" lw="mp" tooltip="@string(expand_panel, Expand Panel)" />
64 <PushButton id="terminal_panel_add" lw="mp" icon="icon(add, 12dp)" tooltip="@string(add_terminal, Add Terminal)" />
65 </vbox>
66 </hboxce>
67 )xml";
68
69 if ( mMainSplitter->getLastWidget() != nullptr ) {
70 mMainSplitter->getLastWidget()->setVisible( false );
71 mMainSplitter->getLastWidget()->setParent( mUISceneNode );
72 }
73
74 mContainer = mUISceneNode->loadLayoutFromString( XML, mMainSplitter )
75 ->asType<UIHLinearLayoutCommandExecuter>();
76 mContainer->bind( "terminal_panel_tab_widget", mTabWidget );
77 mContainer->bind( "terminal_panel_add", mAddBtn );
78 mContainer->on( Event::OnFocus, [this]( auto ) {
79 if ( mTabWidget->getTabSelected() && mTabWidget->getTabSelected()->getOwnedWidget() )
80 mTabWidget->getTabSelected()->getOwnedWidget()->setFocus();
81 } );
82
83 mTabWidget->setAcceptsDropOfWidgetFn( []( const UIWidget* widget ) {
84 return widget->isType( UI_TYPE_TAB ) &&
85 widget->asConstType<UITab>()->getOwnedWidget()->isType( UI_TYPE_TERMINAL );
86 } );
87
88 mTabWidget->setTabTryCloseCallback(
89 [this]( UITab* tab, UITabWidget::FocusTabBehavior ) -> bool {
90 return tryTabClose( tab );
91 } );
92
93 createTerminal();
94
95 mAddBtn->onClick( [this]( auto ) { createTerminal(); } );
96
97 auto kb = mContext->getKeybind( "create-new-terminal" );
98 if ( !kb.empty() ) {
99 mAddBtn->setTooltipText(
100 String::format( "%s (%s)", mAddBtn->getTooltipText().toUtf8(), kb ) );
101 }
102
103 const auto onTabCountChange = [this]( auto ) {
104 if ( SceneManager::instance()->isShuttingDown() )
105 return;
106 auto tabCount = mTabWidget->getTabCount();
107 if ( tabCount == 0 )

Callers

nothing calls this directly

Calls 15

formatFunction · 0.85
getLastWidgetMethod · 0.80
setParentMethod · 0.80
loadLayoutFromStringMethod · 0.80
getTabSelectedMethod · 0.80
getOwnedWidgetMethod · 0.80
setTooltipTextMethod · 0.80
toUtf8Method · 0.80
getTooltipTextMethod · 0.80
getTabCountMethod · 0.80

Tested by

no test coverage detected