UI: show recently selected items at the top of searches #110828

Merged
Jacques Lucke merged 24 commits from JacquesLucke/blender:recent-searches into main 2023-09-25 10:56:20 +02:00
15 changed files with 31 additions and 30 deletions
Showing only changes of commit 7c08d44da8 - Show all commits

View File

@ -274,7 +274,6 @@ set(SRC
intern/softbody.c
intern/sound.cc
intern/speaker.cc
intern/string_search.cc
intern/studiolight.cc
intern/subdiv.cc
intern/subdiv_ccg.cc
@ -485,7 +484,6 @@ set(SRC
BKE_softbody.h
BKE_sound.h
BKE_speaker.h
BKE_string_search.hh
BKE_studiolight.h
BKE_subdiv.hh
BKE_subdiv_ccg.hh

View File

@ -1,4 +1,4 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
@ -6,7 +6,7 @@
#include "BLI_string_search.hh"
namespace blender::bke::string_search {
namespace blender::ui::string_search {
/**
* Remember the string that the user chose. This allows us to put it higher up in the search items
@ -28,4 +28,4 @@ template<typename T> class StringSearch : public blender::string_search::StringS
StringSearch() : blender::string_search::StringSearch<T>(get_recent_cache()) {}
};
} // namespace blender::bke::string_search
} // namespace blender::ui::string_search

View File

@ -64,6 +64,7 @@ set(SRC
interface_region_search.cc
interface_region_tooltip.cc
interface_regions.cc
interface_string_search.cc
interface_style.cc
interface_template_asset_view.cc
interface_template_attribute_search.cc

View File

@ -39,8 +39,8 @@
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_string_search.hh"
#include "BKE_unit.h"
#include "UI_string_search.hh"
#include "ED_asset.hh"
@ -6375,7 +6375,7 @@ static void operator_enum_search_update_fn(
const EnumPropertyItem *all_items;
RNA_property_enum_items_gettexted((bContext *)C, ptr, prop, &all_items, nullptr, &do_free);
blender::bke::string_search::StringSearch<const EnumPropertyItem> search;
blender::ui::string_search::StringSearch<const EnumPropertyItem> search;
for (const EnumPropertyItem *item = all_items; item->identifier; item++) {
search.add(item->name, item);

View File

@ -45,9 +45,9 @@
#include "BKE_paint.hh"
#include "BKE_report.h"
#include "BKE_screen.h"
#include "BKE_string_search.hh"
#include "BKE_tracking.h"
#include "BKE_unit.h"
#include "UI_string_search.hh"
#include "GHOST_C-api.h"
@ -1254,7 +1254,7 @@ static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data)
uiButSearch *search_but = (uiButSearch *)but;
but->func_arg2 = search_but->item_active;
blender::bke::string_search::add_recent_search(search_but->item_active_str);
blender::ui::string_search::add_recent_search(search_but->item_active_str);
}
ui_apply_but_func(C, but);

View File

@ -1,17 +1,18 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include <sstream>
#include "BKE_appdir.h"
#include "BKE_string_search.hh"
#include "UI_string_search.hh"
#include "BLI_fileops.hh"
#include "BLI_map.hh"
#include "BLI_path_util.h"
namespace blender::bke::string_search {
namespace blender::ui::string_search {
using blender::string_search::RecentCache;
@ -94,4 +95,4 @@ void read_recent_searches_file()
}
}
} // namespace blender::bke::string_search
} // namespace blender::ui::string_search

View File

@ -16,7 +16,7 @@
#include "BLT_translation.h"
#include "BKE_attribute.hh"
#include "BKE_string_search.hh"
#include "UI_string_search.hh"
#include "NOD_geometry_nodes_log.hh"
@ -91,7 +91,7 @@ void attribute_search_add_items(StringRefNull str,
* so the items are in the same order they will appear in while searching. */
const char *string = is_first ? "" : str.c_str();
bke::string_search::StringSearch<const GeometryAttributeInfo> search;
ui::string_search::StringSearch<const GeometryAttributeInfo> search;
for (const GeometryAttributeInfo *item : infos) {
if (!bke::allow_procedural_attribute_access(item->name)) {
continue;

View File

@ -39,7 +39,7 @@
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_screen.h"
#include "BKE_string_search.hh"
#include "UI_string_search.hh"
#include "ED_screen.hh"
@ -990,7 +990,7 @@ static void menu_search_update_fn(const bContext * /*C*/,
{
MenuSearch_Data *data = (MenuSearch_Data *)arg;
blender::bke::string_search::StringSearch<MenuSearch_Item> search;
blender::ui::string_search::StringSearch<MenuSearch_Item> search;
LISTBASE_FOREACH (MenuSearch_Item *, item, &data->items) {
search.add(item->drawwstr_full, item);

View File

@ -67,7 +67,7 @@
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_shader_fx.h"
#include "BKE_string_search.hh"
#include "UI_string_search.hh"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
@ -426,7 +426,7 @@ static void id_search_cb(const bContext *C,
ListBase *lb = template_ui->idlb;
const int flag = RNA_property_flag(template_ui->prop);
blender::bke::string_search::StringSearch<ID> search;
blender::ui::string_search::StringSearch<ID> search;
/* ID listbase */
LISTBASE_FOREACH (ID *, id, lb) {

View File

@ -28,7 +28,7 @@
#include "BKE_lib_id.h"
#include "BKE_report.h"
#include "BKE_screen.h"
#include "BKE_string_search.hh"
#include "UI_string_search.hh"
#include "MEM_guardedalloc.h"
@ -519,7 +519,7 @@ void ui_rna_collection_search_update_fn(
char *name;
bool has_id_icon = false;
blender::bke::string_search::StringSearch<CollItemSearch> search;
blender::ui::string_search::StringSearch<CollItemSearch> search;
if (data->search_prop != nullptr) {
/* build a temporary list of relevant items first */

View File

@ -19,7 +19,7 @@
#include "BKE_main.h"
#include "BKE_node_tree_update.h"
#include "BKE_screen.h"
#include "BKE_string_search.hh"
#include "UI_string_search.hh"
#include "DEG_depsgraph_build.h"
@ -185,7 +185,7 @@ static void add_node_search_update_fn(
storage.update_items_tag = false;
}
bke::string_search::StringSearch<nodes::AddNodeItem> search;
ui::string_search::StringSearch<nodes::AddNodeItem> search;
for (nodes::AddNodeItem &item : storage.search_add_items) {
search.add(item.ui_name, &item, item.weight);

View File

@ -15,7 +15,7 @@
#include "BKE_node_runtime.hh"
#include "BKE_node_tree_update.h"
#include "BKE_screen.h"
#include "BKE_string_search.hh"
#include "UI_string_search.hh"
#include "NOD_socket.hh"
#include "NOD_socket_search_link.hh"
@ -359,7 +359,7 @@ static void link_drag_search_update_fn(
storage.update_items_tag = false;
}
bke::string_search::StringSearch<SocketLinkOperation> search;
ui::string_search::StringSearch<SocketLinkOperation> search;
for (SocketLinkOperation &op : storage.search_link_ops) {
search.add(op.name, &op, op.weight);

View File

@ -24,8 +24,8 @@
#include "BKE_node.hh"
#include "BKE_node_runtime.hh"
#include "BKE_node_tree_update.h"
#include "BKE_string_search.hh"
#include "BKE_workspace.h"
#include "UI_string_search.hh"
#include "ED_node.hh" /* own include */
#include "ED_screen.hh"
@ -1356,7 +1356,7 @@ static void node_find_update_fn(const bContext *C,
{
SpaceNode *snode = CTX_wm_space_node(C);
bke::string_search::StringSearch<bNode> search;
ui::string_search::StringSearch<bNode> search;
for (bNode *node : snode->edittree->all_nodes()) {
char name[256];

View File

@ -103,6 +103,7 @@ set(SRC
../include/UI_interface_c.hh
../include/UI_interface_icons.hh
../include/UI_resources.hh
../include/UI_string_search.hh
../include/UI_tree_view.hh
../include/UI_view2d.hh
)

View File

@ -54,8 +54,8 @@
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_sound.h"
#include "BKE_string_search.hh"
#include "BKE_vfont.h"
#include "UI_string_search.hh"
#include "BKE_addon.h"
#include "BKE_appdir.h"
@ -354,7 +354,7 @@ void WM_init(bContext *C, int argc, const char **argv)
ED_render_clear_mtex_copybuf();
wm_history_file_read();
blender::bke::string_search::read_recent_searches_file();
blender::ui::string_search::read_recent_searches_file();
STRNCPY(G.lib, BKE_main_blendfile_path_from_global());
@ -524,7 +524,7 @@ void WM_exit_ex(bContext *C, const bool do_python, const bool do_user_exit_actio
}
if (!G.background) {
blender::bke::string_search::write_recent_searches_file();
blender::ui::string_search::write_recent_searches_file();
}
if (do_user_exit_actions) {