update headers
This commit is contained in:
59
ios/include/filagui/ImGuiExtensions.h
Normal file
59
ios/include/filagui/ImGuiExtensions.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FILAGUI_IMGUIEXTENSIONS_H
|
||||
#define FILAGUI_IMGUIEXTENSIONS_H
|
||||
|
||||
#include <utils/compiler.h>
|
||||
|
||||
struct ImVec2;
|
||||
|
||||
/**
|
||||
* Namespace for custom widgets that follow the API conventions used by ImGui.
|
||||
* For example, the prototype for ImGuiExt::DirectionWidget is similar to ImGui::DragFloat3.
|
||||
*/
|
||||
namespace ImGuiExt {
|
||||
/*
|
||||
* Draws an arrow widget for manipulating a unit vector (inspired by AntTweakBar).
|
||||
*
|
||||
* This adds a draggable 3D arrow widget to the current ImGui window, as well as a label and
|
||||
* three spin boxes that can be dragged or double-clicked for manual entry.
|
||||
*
|
||||
* The widget allow users to enter arbitrary vectors, so clients should copy the UI value
|
||||
* then normalize it. Clients should not directly normalize the UI value as this would cause
|
||||
* surprises for users who attempt to type in individual components.
|
||||
*/
|
||||
UTILS_PUBLIC
|
||||
bool DirectionWidget(const char* label, float v[3]);
|
||||
|
||||
/**
|
||||
* Draws a plot with multiple series. The parameters are the same as for ImGui::ImPlotLines
|
||||
* except for the following:
|
||||
* - series_start: called when a new series starts rendering, this can be used to customize
|
||||
* the series' style for instance
|
||||
* - series_end: called when a series is done rendering
|
||||
* - values_getter: the first parameter indicates which series is being rendered
|
||||
*/
|
||||
UTILS_PUBLIC
|
||||
void PlotLinesSeries(const char* label, int series_count,
|
||||
void (*series_start)(int series),
|
||||
float (*values_getter)(int series, void* data, int idx),
|
||||
void (*series_end)(int series),
|
||||
void* data, int values_count, int values_offset, const char* overlay_text,
|
||||
float scale_min, float scale_max, ImVec2 graph_size);
|
||||
}
|
||||
|
||||
#endif // FILAGUI_IMGUIEXTENSIONS_H
|
||||
102
ios/include/filagui/ImGuiHelper.h
Normal file
102
ios/include/filagui/ImGuiHelper.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FILAGUI_IMGUIHELPER_H_
|
||||
#define FILAGUI_IMGUIHELPER_H_
|
||||
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
#include <filament/Engine.h>
|
||||
#include <filament/IndexBuffer.h>
|
||||
#include <filament/Material.h>
|
||||
#include <filament/MaterialInstance.h>
|
||||
#include <filament/Texture.h>
|
||||
#include <filament/TextureSampler.h>
|
||||
#include <filament/VertexBuffer.h>
|
||||
#include <filament/View.h>
|
||||
|
||||
#include <utils/Entity.h>
|
||||
#include <utils/Path.h>
|
||||
|
||||
struct ImDrawData;
|
||||
struct ImGuiIO;
|
||||
struct ImGuiContext;
|
||||
|
||||
namespace filagui {
|
||||
|
||||
// Translates ImGui's draw commands into Filament primitives, textures, vertex buffers, etc.
|
||||
// Creates a UI-specific Scene object and populates it with a Renderable. Does not handle
|
||||
// event processing; clients can simply call ImGui::GetIO() directly and set the mouse state.
|
||||
class UTILS_PUBLIC ImGuiHelper {
|
||||
public:
|
||||
// Using std::function instead of a vanilla C callback to make it easy for clients to pass in
|
||||
// lambdas that have captures.
|
||||
using Callback = std::function<void(filament::Engine*, filament::View*)>;
|
||||
|
||||
// The constructor creates its own Scene and places it in the given View.
|
||||
ImGuiHelper(filament::Engine* engine, filament::View* view, const utils::Path& fontPath,
|
||||
ImGuiContext* imGuiContext = nullptr);
|
||||
~ImGuiHelper();
|
||||
|
||||
// Informs ImGui of the current display size, as well as a scaling factor when scissoring.
|
||||
void setDisplaySize(int width, int height, float scaleX = 1.0f,
|
||||
float scaleY = 1.0f, bool flipVertical = false);
|
||||
|
||||
// High-level utility method that takes a callback for creating all ImGui windows and widgets.
|
||||
// Clients are responsible for rendering the View. This should be called on every frame,
|
||||
// regardless of whether the Renderer wants to skip or not.
|
||||
void render(float timeStepInSeconds, Callback imguiCommands);
|
||||
|
||||
// Low-level alternative to render() that consumes an ImGui command list and translates it into
|
||||
// various Filament calls. This includes updating the vertex buffer, setting up material
|
||||
// instances, and rebuilding the Renderable component that encompasses the entire UI. Since this
|
||||
// makes Filament calls, it must be called from the main thread.
|
||||
void processImGuiCommands(ImDrawData* commands, const ImGuiIO& io);
|
||||
|
||||
// Helper method called after resolving fontPath; public so fonts can be added by caller.
|
||||
void createAtlasTexture(filament::Engine* engine);
|
||||
|
||||
// Returns the client-owned view, useful for drawing 2D overlays.
|
||||
filament::View* getView() const { return mView; }
|
||||
|
||||
private:
|
||||
void createBuffers(int numRequiredBuffers);
|
||||
void populateVertexData(size_t bufferIndex, size_t vbSizeInBytes, void* vbData,
|
||||
size_t ibSizeInBytes, void* ibData);
|
||||
void createVertexBuffer(size_t bufferIndex, size_t capacity);
|
||||
void createIndexBuffer(size_t bufferIndex, size_t capacity);
|
||||
void syncThreads();
|
||||
filament::Engine* mEngine;
|
||||
filament::View* mView; // The view is owned by the client.
|
||||
filament::Scene* mScene;
|
||||
filament::Material* mMaterial = nullptr;
|
||||
filament::Camera* mCamera = nullptr;
|
||||
std::vector<filament::VertexBuffer*> mVertexBuffers;
|
||||
std::vector<filament::IndexBuffer*> mIndexBuffers;
|
||||
std::vector<filament::MaterialInstance*> mMaterialInstances;
|
||||
utils::Entity mRenderable;
|
||||
utils::Entity mCameraEntity;
|
||||
filament::Texture* mTexture = nullptr;
|
||||
bool mHasSynced = false;
|
||||
ImGuiContext* mImGuiContext;
|
||||
filament::TextureSampler mSampler;
|
||||
bool mFlipVertical = false;
|
||||
};
|
||||
|
||||
} // namespace filagui
|
||||
|
||||
#endif /* FILAGUI_IMGUIHELPER_H_ */
|
||||
30
ios/include/filagui/ImGuiMath.h
Normal file
30
ios/include/filagui/ImGuiMath.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FILAGUI_IMGUIMATH_H_
|
||||
#define FILAGUI_IMGUIMATH_H_
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs) {
|
||||
return { lhs.x+rhs.x, lhs.y+rhs.y };
|
||||
}
|
||||
|
||||
static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) {
|
||||
return { lhs.x-rhs.x, lhs.y-rhs.y };
|
||||
}
|
||||
|
||||
#endif /* FILAGUI_IMGUIMATH_H_ */
|
||||
Reference in New Issue
Block a user