mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-11 17:17:42 +03:00
Add some basic keybindings to the debugger.
This commit is contained in:
@@ -254,7 +254,7 @@ class EE_API UITabWidget : public UIWidget {
|
||||
SplitFunctionCb mSplitFn;
|
||||
Float mSplitEdgePercent{ 0.1 };
|
||||
UIListView* mTabSwitcher{ nullptr };
|
||||
TabJumpMode mTabJumpMode{ TabJumpMode::Chronological };
|
||||
TabJumpMode mTabJumpMode{ TabJumpMode::Linear };
|
||||
|
||||
void onThemeLoaded();
|
||||
|
||||
|
||||
@@ -3899,6 +3899,9 @@ void App::init( const LogLevel& logLevel, std::string file, const Float& pidelDe
|
||||
UIWidgetCreator::registerWidget( "mainlayout", UIMainLayout::New );
|
||||
UIWidgetCreator::registerWidget( "statusbar", UIStatusBar::New );
|
||||
UIWidgetCreator::registerWidget( "rellayce", UIRelativeLayoutCommandExecuter::New );
|
||||
UIWidgetCreator::registerWidget( "hboxce", UIHLinearLayoutCommandExecuter::New );
|
||||
UIWidgetCreator::registerWidget( "vboxce", UIVLinearLayoutCommandExecuter::New );
|
||||
|
||||
mUISceneNode->loadLayoutFromString( baseUI, nullptr, APP_LAYOUT_STYLE_MARKER );
|
||||
mAppStyleSheet = mUISceneNode->getStyleSheet().getAllWithMarker( APP_LAYOUT_STYLE_MARKER );
|
||||
mUISceneNode->bind( "main_layout", mMainLayout );
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "statusdebuggercontroller.hpp"
|
||||
#include "../../widgetcommandexecuter.hpp"
|
||||
#include "../plugincontextprovider.hpp"
|
||||
#include "eepp/ui/uiwidgetcreator.hpp"
|
||||
#include <eepp/ui/uicheckbox.hpp>
|
||||
@@ -89,6 +90,19 @@ UIWidget* UIBreakpointsTableView::createCell( UIWidget* rowWidget, const ModelIn
|
||||
return UITableView::createCell( rowWidget, index );
|
||||
}
|
||||
|
||||
const std::map<KeyBindings::Shortcut, std::string>
|
||||
StatusDebuggerController::getLocalDefaultKeybindings() {
|
||||
return {
|
||||
{ { KEY_TAB, KeyMod::getDefaultModifier() }, "next-tab" },
|
||||
{ { KEY_TAB, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "previous-tab" },
|
||||
{ { KEY_1, KeyMod::getDefaultModifier() }, "switch-to-tab-1" },
|
||||
{ { KEY_2, KeyMod::getDefaultModifier() }, "switch-to-tab-2" },
|
||||
{ { KEY_3, KeyMod::getDefaultModifier() }, "switch-to-tab-3" },
|
||||
{ { KEY_4, KeyMod::getDefaultModifier() }, "switch-to-tab-4" },
|
||||
{ { KEY_5, KeyMod::getDefaultModifier() }, "switch-to-tab-5" },
|
||||
};
|
||||
}
|
||||
|
||||
StatusDebuggerController::StatusDebuggerController( UISplitter* mainSplitter,
|
||||
UISceneNode* uiSceneNode,
|
||||
PluginContextProvider* pluginContext ) :
|
||||
@@ -190,7 +204,7 @@ void StatusDebuggerController::createContainer() {
|
||||
background-color: none;
|
||||
}
|
||||
</style>
|
||||
<hbox id="app_debugger" lw="mp" lh="mp" visible="false">
|
||||
<hboxce id="app_debugger" lw="mp" lh="mp" visible="false">
|
||||
<TabWidget id="app_debugger_tab_widget" lw="0" lw8="1" lh="mp">
|
||||
<Splitter id="debugger_threads_and_stack" layout_width="mp" lh="mp" splitter-partition="15%">
|
||||
<TableView id="debugger_threads" layout_width="mp" layout_height="mp" />
|
||||
@@ -215,7 +229,7 @@ void StatusDebuggerController::createContainer() {
|
||||
<PushButton id="app_debugger_step_into" class="debugger_step_into" lw="mp" icon="icon(debug-step-into, 12dp)" tooltip="@string(step_into, Step Into)" />
|
||||
<PushButton id="app_debugger_step_out" class="debugger_step_out" lw="mp" icon="icon(debug-step-out, 12dp)" tooltip="@string(step_out, Step Out)" />
|
||||
</vbox>
|
||||
</hbox>
|
||||
</hboxce>
|
||||
)xml";
|
||||
|
||||
UIWidgetCreator::registerWidget( "BreakpointsTableView", UIBreakpointsTableView::New );
|
||||
@@ -227,7 +241,7 @@ void StatusDebuggerController::createContainer() {
|
||||
|
||||
mContainer = mContext->getUISceneNode()
|
||||
->loadLayoutFromString( XML, mMainSplitter )
|
||||
->asType<UILinearLayout>();
|
||||
->asType<UIHLinearLayoutCommandExecuter>();
|
||||
|
||||
mContainer->bind( "app_debugger_tab_widget", mUITabWidget );
|
||||
mContainer->bind( "debugger_threads_and_stack", mUIThreadsSplitter );
|
||||
@@ -245,6 +259,26 @@ void StatusDebuggerController::createContainer() {
|
||||
mContainer->bind( "app_debugger_step_into", mUIButStepInto );
|
||||
mContainer->bind( "app_debugger_step_out", mUIButStepOut );
|
||||
|
||||
mContainer->setCommand( "next-tab", [this] {
|
||||
if ( mUITabWidget )
|
||||
mUITabWidget->focusNextTab();
|
||||
} );
|
||||
|
||||
mContainer->setCommand( "previous-tab", [this] {
|
||||
if ( mUITabWidget )
|
||||
mUITabWidget->focusPreviousTab();
|
||||
} );
|
||||
|
||||
for ( int i = 1; i <= 5; i++ ) {
|
||||
mContainer->setCommand( String::format( "switch-to-tab-%d", i ), [this, i] {
|
||||
if ( mUITabWidget )
|
||||
mUITabWidget->setTabSelected(
|
||||
eeclamp<Int32>( i - 1, 0, mUITabWidget->getTabCount() - 1 ) );
|
||||
} );
|
||||
}
|
||||
|
||||
mContainer->getKeyBindings().addKeybinds( getLocalDefaultKeybindings() );
|
||||
|
||||
setDebuggingState( State::NotStarted );
|
||||
|
||||
mUIButStart->onClick(
|
||||
|
||||
@@ -18,6 +18,8 @@ using namespace EE::UI::Tools;
|
||||
|
||||
namespace ecode {
|
||||
|
||||
class UIHLinearLayoutCommandExecuter;
|
||||
|
||||
class UIBreakpointsTableView : public UITableView {
|
||||
public:
|
||||
static UIWidget* New() { return eeNew( UIBreakpointsTableView, () ); }
|
||||
@@ -36,6 +38,8 @@ class StatusDebuggerController : public StatusBarElement {
|
||||
public:
|
||||
enum class State { NotStarted, Running, Paused };
|
||||
|
||||
static const std::map<KeyBindings::Shortcut, std::string> getLocalDefaultKeybindings();
|
||||
|
||||
StatusDebuggerController( UISplitter* mainSplitter, UISceneNode* uiSceneNode,
|
||||
PluginContextProvider* pluginContext );
|
||||
|
||||
@@ -70,7 +74,7 @@ class StatusDebuggerController : public StatusBarElement {
|
||||
std::function<void( StatusDebuggerController*, UIWidget* )> onWidgetCreated{ nullptr };
|
||||
|
||||
protected:
|
||||
UILinearLayout* mContainer{ nullptr };
|
||||
UIHLinearLayoutCommandExecuter* mContainer{ nullptr };
|
||||
UITableView* mUIThreads{ nullptr };
|
||||
UITableView* mUIStack{ nullptr };
|
||||
UIBreakpointsTableView* mUIBreakpoints{ nullptr };
|
||||
|
||||
@@ -71,6 +71,36 @@ class UIRelativeLayoutCommandExecuter : public UIRelativeLayout, public WidgetCo
|
||||
}
|
||||
};
|
||||
|
||||
class UIHLinearLayoutCommandExecuter : public UILinearLayout, public WidgetCommandExecuter {
|
||||
public:
|
||||
static UIHLinearLayoutCommandExecuter* New() {
|
||||
return eeNew( UIHLinearLayoutCommandExecuter, () );
|
||||
}
|
||||
|
||||
UIHLinearLayoutCommandExecuter() :
|
||||
UILinearLayout( "hboxce", UIOrientation::Horizontal ),
|
||||
WidgetCommandExecuter( getUISceneNode()->getWindow()->getInput() ) {}
|
||||
|
||||
virtual Uint32 onKeyDown( const KeyEvent& event ) {
|
||||
return WidgetCommandExecuter::onKeyDown( event );
|
||||
}
|
||||
};
|
||||
|
||||
class UIVLinearLayoutCommandExecuter : public UILinearLayout, public WidgetCommandExecuter {
|
||||
public:
|
||||
static UIVLinearLayoutCommandExecuter* New() {
|
||||
return eeNew( UIVLinearLayoutCommandExecuter, () );
|
||||
}
|
||||
|
||||
UIVLinearLayoutCommandExecuter() :
|
||||
UILinearLayout( "vboxce", UIOrientation::Vertical ),
|
||||
WidgetCommandExecuter( getUISceneNode()->getWindow()->getInput() ) {}
|
||||
|
||||
virtual Uint32 onKeyDown( const KeyEvent& event ) {
|
||||
return WidgetCommandExecuter::onKeyDown( event );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ecode
|
||||
|
||||
#endif // ECODE_WIDGETCOMMANDEXECUTER_HPP
|
||||
|
||||
Reference in New Issue
Block a user