Polyphase Game Engine
Loading...
Searching...
No Matches
EditorWidgetsInternal.h
Go to the documentation of this file.
1#pragma once
2
3#if EDITOR
4
5// Internal bridge between EditorImgui.cpp (the canonical source of the
6// inspector's asset-row primitives) and EditorWidgets.cpp (where the public
7// Polyphase::AssetRefPicker widget lives). The two helpers below were once
8// `static` inside EditorImgui.cpp; they're now non-static so the unified
9// widget can reuse them without duplicating ~300 lines of dropdown logic.
10//
11// This header is private to the Editor target — do NOT include it from
12// engine, runtime, or addon code.
13
14#include "EngineTypes.h" // PropertyOwnerType enum
15#include "imgui.h"
16
17#include <string>
18#include <vector>
19
20class Property;
21class Object;
22class Asset;
23
24namespace PolyphaseEditorInternal
25{
26 // Stateless filter signature used by every existing autocomplete caller
27 // (asset name picker, script picker, asset-replace picker). The widget
28 // used to be a template over the filter type; flattening to a function
29 // pointer lets us share one definition across translation units without
30 // pulling the implementation into a header.
31 using AutocompleteFilter = bool (*)(const std::string& suggestion,
32 const std::string& input);
33
34 // Defined in EditorImgui.cpp.
35 bool DrawAutocompleteDropdown(const char* dropdownId,
36 std::string& inputText,
37 const std::vector<std::string>& suggestions,
38 AutocompleteFilter filterFunc,
39 bool forceActive = false,
40 ImGuiID overrideInputId = 0,
41 ImVec2 overrideRectMin = ImVec2(0, 0),
42 ImVec2 overrideRectMax = ImVec2(0, 0));
43
44 // Defined in EditorImgui.cpp. Encapsulates the type-filter check (with
45 // Material polymorphism HACK) and the undo-wrapping vs direct-write
46 // branch for Property-backed asset assignment.
47 void AssignAssetToProperty(Object* owner,
48 PropertyOwnerType ownerType,
49 Property& prop,
50 uint32_t index,
51 Asset* newAsset);
52}
53
54#endif // EDITOR
PropertyOwnerType
Definition EngineTypes.h:155
Definition Asset.h:119
Definition Object.h:13
Definition Property.h:14