Skip to content

Commit

Permalink
Dealt with suggestions, fixed a regression in keyboard focusing upon …
Browse files Browse the repository at this point in the history
…starting/stopping filtering
  • Loading branch information
katemonster33 committed Apr 8, 2024
1 parent cfa27a8 commit f9b0f34
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
19 changes: 5 additions & 14 deletions src/cata_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ class cataimgui::window_impl
class cataimgui::filter_box_impl
{
public:
char text[255]; // NOLINT(modernize-avoid-c-arrays)
std::array<char, 255> text;
ImGuiID id;
};

Expand Down Expand Up @@ -627,9 +627,9 @@ void cataimgui::window::draw_filter( const input_context &ctxt, bool filtering_a
action_button( "TEXT.CONFIRM", ctxt.get_button_text( "TEXT.CONFIRM", _( "OK" ) ) );
ImGui::SameLine();
}
ImGui::BeginDisabled( filtering_active );
ImGui::InputText( "##FILTERBOX", filter_impl->text,
std::extent_v < decltype( filter_impl->text ) > );
ImGui::BeginDisabled( !filtering_active );
ImGui::InputText( "##FILTERBOX", filter_impl->text.data(),
filter_impl->text.size() );
ImGui::EndDisabled();
if( !filter_impl->id ) {
filter_impl->id = GImGui->LastItemData.ID;
Expand All @@ -639,7 +639,7 @@ void cataimgui::window::draw_filter( const input_context &ctxt, bool filtering_a
std::string cataimgui::window::get_filter()
{
if( filter_impl ) {
return std::string( filter_impl->text );
return std::string( filter_impl->text.data() );
} else {
return std::string();
}
Expand All @@ -655,12 +655,3 @@ void cataimgui::window::clear_filter()
}
}
}

//void cataimgui::window::set_filter( const std::string &filter )
//{
// // doesnt currently work, relies on API only available in newer ImGUi, because I can't have nice things
// //ImGuiInputTextState* input_state = ImGui::GetInputTextState( p_impl->id );
// //if( input_state ) {
// // input_state->ReloadUserBufAndSelectAll();
// //}
//}
1 change: 0 additions & 1 deletion src/cata_imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ class window
size_t str_width_to_pixels( size_t len );
size_t str_height_to_pixels( size_t len );
std::string get_filter();
//void set_filter( const std::string &filter );
void clear_filter();
void mark_resized();

Expand Down
7 changes: 2 additions & 5 deletions src/input_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,10 +698,10 @@ void keybindings_ui::draw_controls()
for( ; legend_idx < legend.size(); legend_idx++ ) {
draw_colored_text( legend[legend_idx], c_white );
}
draw_filter( *ctxt, status == kb_menu_status::filter );
if( last_status != status && status == kb_menu_status::filter ) {
ImGui::SetKeyboardFocusHere( 0 );
ImGui::SetKeyboardFocusHere( -1 );
}
draw_filter( *ctxt, status == kb_menu_status::filter );
ImGui::Separator();

if( last_status != status && status == kb_menu_status::show ) {
Expand Down Expand Up @@ -1452,9 +1452,6 @@ action_id input_context::display_menu_imgui( const bool permit_execute_action )
} else {
break;
}
} else if( action == "TEXT.INPUT_FROM_FILE" ) {
//kb_menu.set_filter( kb_menu.get_filter() + get_input_string_from_file() );
continue;
} else if( action == "HELP_KEYBINDINGS" ) {
// update available hotkeys in case they've changed
kb_menu.hotkeys = ctxt.get_available_single_char_hotkeys( display_help_hotkeys );
Expand Down

0 comments on commit f9b0f34

Please sign in to comment.