CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
Drag.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "Common.hpp"
11
13
14#include <string_view>
15
17
18 template<typename T> inline bool drag(const String& label, T& value, const float velocity, T min, T max) {
19 return ImGui::DragScalar(label.c_str(), DataType<T>::type, &value, velocity, &min, &max);
20 }
21
22 template<typename T> inline bool drag(const String& label, T& value, const double velocity, T min, T max) {
23 return ImGui::DragScalar(label.c_str(), DataType<T>::type, &value, (float)velocity, &min, &max);
24 }
25
26 template<typename T> inline bool drag(const String& label, T& value, const float velocity, T min) {
27 return ImGui::DragScalar(label.c_str(), DataType<T>::type, &value, velocity, &min);
28 }
29
30 template<typename T> inline bool drag(const String& label, T& value, const double velocity, T min) {
31 return ImGui::DragScalar(label.c_str(), DataType<T>::type, &value, (float)velocity, &min);
32 }
33
34 template<typename T> inline bool drag(const String& label, T& value, const float velocity) {
35 return ImGui::DragScalar(label.c_str(), DataType<T>::type, &value, velocity);
36 }
37
38 template<typename T> inline bool drag(const String& label, T& value, const double velocity) {
39 return ImGui::DragScalar(label.c_str(), DataType<T>::type, &value, (float)velocity);
40 }
41
42 template<typename T, int D> inline bool drag(const String& label, TVector<D, T>& value, const float velocity, T min, T max) {
43 return ImGui::DragScalarN(label.c_str(), DataType<T>::type, &value, D, velocity, &min, &max);
44 }
45
46 template<typename T, int D> inline bool drag(const String& label, TVector<D, T>& value, const double velocity, T min, T max) {
47 return ImGui::DragScalarN(label.c_str(), DataType<T>::type, &value, D, (float)velocity, &min, &max);
48 }
49
50 template<typename T, int D> inline bool drag(const String& label, TVector<D, T>& value, const float velocity) {
51 return ImGui::DragScalarN(label.c_str(), DataType<T>::type, &value, D, velocity);
52 }
53
54 template<typename T, int D> inline bool drag(const String& label, TVector<D, T>& value, const double velocity) {
55 return ImGui::DragScalarN(label.c_str(), DataType<T>::type, &value, D, (float)velocity);
56 }
57
58 template<typename T, int C, int R> inline bool drag(const String& label, TMatrix<C, R, T>& value, const double velocity, T min, T max) {
59 bool state = false;
60 for(int r = 0; r < R; r++) {
61 T* starting = reinterpret_cast<T*>(&value) + r * C;
62 state |= ImGui::DragScalarN((label + "[" + String::from(r) + "]").c_str(), DataType<T>::type, starting, C, (float)velocity, &min, &max);
63 }
64 return state;
65 }
66
67} // namespace CeresEngine::Graphics::UI::Component
static decltype(auto) from(U value, Args &&... args)
Converts a value into it's string representation.
Definition String.hpp:386
Definition Checkbox.hpp:14
bool drag(const String &label, T &value, const float velocity, T min, T max)
Definition Drag.hpp:18
struct CeresEngine::GLState state
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25