This repository has been archived by the owner on Sep 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathpicker.h
71 lines (65 loc) · 2.04 KB
/
picker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright 2016-2021 Doug Moen
// Licensed under the Apache License, version 2.0
// See accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0
#ifndef LIBCURV_PICKER_H
#define LIBCURV_PICKER_H
#include <libcurv/function.h>
#include <libcurv/reactive.h>
#include <libcurv/symbol.h>
namespace curv {
// A Picker is a predicate function that carries additional metadata,
// describing the type and range of a graphical value picker.
struct Picker
{
// Type, Config and State describe a graphical value picker.
enum class Type {
slider,
int_slider,
scale_picker,
checkbox,
colour_picker
};
struct Config {
Type type_;
SC_Type sctype_;
union {
struct {
double low_;
double high_;
} slider_;
struct {
int low_;
int high_;
} int_slider_;
};
Config() {}
Config(Value, const Context&);
void write_json(std::ostream&) const;
void write_curv(std::ostream&) const;
};
union State {
bool bool_;
int int_;
float num_; // not double, because ImGui sliders use float
float vec3_[3];
State(Type, Value, const Context&);
void write(std::ostream&, Type) const;
void write_json(std::ostream&, Type) const;
void write_curv(std::ostream&, Type) const;
};
};
// This is a pseudo-value that denotes a GLSL uniform variable.
// More specifically, it's one of the parameters in a parametric shape.
// These things are only used when compiling a parametric shape to GLSL.
struct Uniform_Variable : public Reactive_Value
{
Symbol_Ref name_;
std::string identifier_;
Shared<const Phrase> namephrase_;
Uniform_Variable(Symbol_Ref name, std::string id, SC_Type,
Shared<const Phrase> namephrase);
virtual void print_repr(std::ostream&, Prec) const override;
virtual Shared<Operation> expr() const override;
};
} // namespace curv
#endif // header guard