PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
OpenScalesBrowser.h
Go to the documentation of this file.
1// OpenScalesBrowser.h - Browse and download scales from OpenScales repository
2// Copyright (c) 2026 Shane T. Mueller
3// Licensed under GPL
4
5#ifndef OPENSCALES_BROWSER_H
6#define OPENSCALES_BROWSER_H
7
8#include <string>
9#include <vector>
10#include <functional>
11
13 std::string code;
14 std::string name;
15 std::string domain;
16 std::string description;
17 std::string license;
18 std::string url;
20 std::vector<std::string> languages;
21 std::string repo; // which repository (openscales, private, phenx, restricted)
22 bool isLocal; // already downloaded to workspace
23};
24
26public:
28
29 // Show the browser dialog. scalesDir is workspace/scales/ path.
30 void Show(const std::string& scalesDir);
31
32 // Render the browser UI (call each frame when visible)
33 void Render();
34
35 // Is the dialog currently visible?
36 bool IsVisible() const { return mVisible; }
37
38 // Callback after a scale is downloaded (to refresh scale list)
39 void SetOnDownload(std::function<void(const std::string&)> cb) { mOnDownload = cb; }
40
41private:
42 bool mVisible;
43 std::string mScalesDir;
44 std::vector<OpenScalesEntry> mCatalog;
45 std::vector<std::string> mDomains; // unique domains for filter
46 int mSelectedDomain; // -1 = all
47 int mSelectedIndex; // selected in filtered list
48 char mFilterText[256];
49 std::string mStatusMessage;
50 bool mFetching;
51 std::string mCachePath;
52
53 std::function<void(const std::string&)> mOnDownload;
54
55 // HTTP
56 static std::string FetchURL(const std::string& url);
57 bool FetchManifest();
58 bool DownloadScale(const std::string& code);
59
60 // Helpers
61 void LoadCachedManifest();
62 void ParseManifest(const std::string& json);
63 void UpdateDomainList();
64 void UpdateLocalStatus();
65 std::vector<int> GetFilteredIndices();
66
67 // OpenScales URLs
68 static constexpr const char* BASE_URL = "https://openscales.net";
69 struct ManifestSource {
70 const char* path; // URL path relative to BASE_URL
71 const char* repo; // repo name for display
72 const char* scaleDir; // scale directory path on server
73 };
74 static const ManifestSource MANIFESTS[];
75 static const int NUM_MANIFESTS;
76};
77
78#endif // OPENSCALES_BROWSER_H
nlohmann::json json
Definition Chain.cpp:14
void Show(const std::string &scalesDir)
void SetOnDownload(std::function< void(const std::string &)> cb)
std::string description
std::vector< std::string > languages