yaze 0.2.0
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
style.h
Go to the documentation of this file.
1#ifndef YAZE_APP_CORE_STYLE_H
2#define YAZE_APP_CORE_STYLE_H
3
4#include <functional>
5#include <vector>
6
7#include "ImGuiColorTextEdit/TextEditor.h"
8#include "absl/status/status.h"
9#include "absl/strings/string_view.h"
10#include "app/core/constants.h"
11#include "app/gfx/bitmap.h"
12#include "imgui/imgui.h"
13#include "imgui/misc/cpp/imgui_stdlib.h"
14
15namespace yaze {
16namespace app {
17namespace gui {
18
19void BeginWindowWithDisplaySettings(const char *id, bool *active,
20 const ImVec2 &size = ImVec2(0, 0),
21 ImGuiWindowFlags flags = 0);
22
24
25void BeginPadding(int i);
26void EndPadding();
27
28void BeginNoPadding();
29void EndNoPadding();
30
31void BeginChildWithScrollbar(const char *str_id);
32
33void BeginChildBothScrollbars(int id);
34
35void DrawDisplaySettings(ImGuiStyle *ref = nullptr);
36
37void TextWithSeparators(const absl::string_view &text);
38
39void ColorsYaze();
40
41TextEditor::LanguageDefinition GetAssemblyLanguageDef();
42
43void DrawBitmapViewer(const std::vector<gfx::Bitmap> &bitmaps, float scale,
44 int &current_bitmap);
45
46// ============================================================================
47
48static const char *ExampleNames[] = {
49 "Artichoke", "Arugula", "Asparagus", "Avocado",
50 "Bamboo Shoots", "Bean Sprouts", "Beans", "Beet",
51 "Belgian Endive", "Bell Pepper", "Bitter Gourd", "Bok Choy",
52 "Broccoli", "Brussels Sprouts", "Burdock Root", "Cabbage",
53 "Calabash", "Capers", "Carrot", "Cassava",
54 "Cauliflower", "Celery", "Celery Root", "Celcuce",
55 "Chayote", "Chinese Broccoli", "Corn", "Cucumber"};
56
58 const int ITEMS_COUNT = 10000;
59 void Update() {
60 // Use default selection.Adapter: Pass index to
61 // SetNextItemSelectionUserData(), store index in Selection
62 static ImGuiSelectionBasicStorage selection;
63
64 ImGui::Text("Selection: %d/%d", selection.Size, ITEMS_COUNT);
65 if (ImGui::BeginChild(
66 "##Basket", ImVec2(-FLT_MIN, ImGui::GetFontSize() * 20),
67 ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY)) {
68 ImGuiMultiSelectFlags flags = ImGuiMultiSelectFlags_ClearOnEscape |
69 ImGuiMultiSelectFlags_BoxSelect1d;
70 ImGuiMultiSelectIO *ms_io =
71 ImGui::BeginMultiSelect(flags, selection.Size, ITEMS_COUNT);
72 selection.ApplyRequests(ms_io);
73
74 ImGuiListClipper clipper;
75 clipper.Begin(ITEMS_COUNT);
76 if (ms_io->RangeSrcItem != -1)
77 clipper.IncludeItemByIndex(
78 (int)ms_io->RangeSrcItem); // Ensure RangeSrc item is not clipped.
79 while (clipper.Step()) {
80 for (int n = clipper.DisplayStart; n < clipper.DisplayEnd; n++) {
81 char label[64];
82 // sprintf(label, "Object %05d: %s", n,
83 // ExampleNames[n % IM_ARRAYSIZE(ExampleNames)]);
84 bool item_is_selected = selection.Contains((ImGuiID)n);
85 ImGui::SetNextItemSelectionUserData(n);
86 ImGui::Selectable(label, item_is_selected);
87 }
88 }
89
90 ms_io = ImGui::EndMultiSelect();
91 selection.ApplyRequests(ms_io);
92 }
93 ImGui::EndChild();
94 ImGui::TreePop();
95 }
96};
97
98} // namespace gui
99} // namespace app
100} // namespace yaze
101
102#endif
void DrawDisplaySettings(ImGuiStyle *ref)
Definition style.cc:60
TextEditor::LanguageDefinition GetAssemblyLanguageDef()
Definition style.cc:596
void EndPadding()
Definition style.cc:40
void BeginChildWithScrollbar(const char *str_id)
Definition style.cc:48
void BeginPadding(int i)
Definition style.cc:36
void BeginWindowWithDisplaySettings(const char *id, bool *active, const ImVec2 &size, ImGuiWindowFlags flags)
Definition style.cc:11
void BeginChildBothScrollbars(int id)
Definition style.cc:53
void ColorsYaze()
Definition style.cc:431
void EndNoPadding()
Definition style.cc:46
void DrawBitmapViewer(const std::vector< gfx::Bitmap > &bitmaps, float scale, int &current_bitmap_id)
Definition style.cc:530
void TextWithSeparators(const absl::string_view &text)
Definition style.cc:424
void BeginNoPadding()
Definition style.cc:42
void EndWindowWithDisplaySettings()
Definition style.cc:31
Definition common.cc:22