MCPcopy Create free account
hub / github.com/bluescan/tacentview / ShowThumbnailViewDialog

Method ShowThumbnailViewDialog

Src/ThumbnailView.cpp:101–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99
100
101void Viewer::ShowThumbnailViewDialog(bool* popen)
102{
103 ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoScrollbar;
104 tVector2 windowPos = Gutil::GetDialogOrigin(Gutil::DialogID::ThumbnailView);
105
106 Config::ProfileData& profile = Config::GetProfileData();
107 tVector2 initialSize = Gutil::GetUIParamExtent(tVector2(800.0f, 610.0f), tVector2(1200.0f, 800.0f));
108
109 ImGui::SetNextWindowPos(windowPos, ImGuiCond_FirstUseEver);
110 ImGui::SetNextWindowSize(initialSize, ImGuiCond_FirstUseEver);
111
112 if (!ImGui::Begin("Thumbnail View", popen, windowFlags))
113 {
114 ImGui::End();
115 return;
116 }
117
118 float barHeight = Gutil::GetUIParamScaled(4.0f, 2.5f);
119 float viewOptionsHeight = Gutil::GetUIParamScaled(66.0f, 2.5f) + barHeight;
120 float optionsHeight = Gutil::GetUIParamScaled(20.0f, 2.5f) + barHeight;
121 float progressTextOffset = Gutil::GetUIParamScaled(460.0f, 2.5f);
122 float thumbItemInfoHeight = Gutil::GetUIParamScaled(32.0f, 2.5f);
123 float minSpacing = Gutil::GetUIParamScaled(4.0f, 2.5f);
124
125 ImGuiWindowFlags thumbWindowFlags = 0;
126 ImGui::BeginChild("Thumbnails", tVector2(ImGui::GetWindowContentRegionWidth(), ImGui::GetWindowHeight()-viewOptionsHeight), false, thumbWindowFlags);
127
128 ImGuiStyle& style = ImGui::GetStyle();
129 float visibleW = ImGui::GetWindowPos().x + ImGui::GetWindowContentRegionMax().x;
130
131 float numPerRowF = ImGui::GetWindowContentRegionMax().x / (profile.ThumbnailWidth + minSpacing);
132 int numPerRow = tMath::tClampMin(int(numPerRowF), 1);
133 float extra = ImGui::GetWindowContentRegionMax().x - (float(numPerRow) * (profile.ThumbnailWidth + minSpacing));
134 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, tVector2(minSpacing + extra/float(numPerRow), minSpacing));
135 tVector2 thumbButtonSize(profile.ThumbnailWidth, profile.ThumbnailWidth*9.0f/16.0f);
136 int thumbNum = 0;
137 int numGeneratedThumbs = 0;
138 static int numThumbsWhenSorted = 0;
139
140 for (Image* i = Images.First(); i; i = i->Next(), thumbNum++)
141 {
142 tVector2 cursor = ImGui::GetCursorPos();
143 if ((thumbNum % numPerRow) == 0)
144 ImGui::SetCursorPos(tVector2(0.5f*extra/float(numPerRow), cursor.y));
145
146 ImGui::PushID(thumbNum);
147 ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, tVector2::zero);
148 bool isCurr = (i == CurrImage);
149
150 // It's ok to call bind even if a request has not been made yet. Takes no time.
151 // Calling bind also frees up the worker threads when requests are fulfilled.
152 uint64 thumbnailTexID = i->BindThumbnail();
153 if (thumbnailTexID)
154 numGeneratedThumbs++;
155
156 // Unlike other widgets, BeginChild ALWAYS needs a corresponding EndChild, even if it's invisible.
157 bool visible = ImGui::BeginChild("ThumbItem", thumbButtonSize+tVector2(0.0f, thumbItemInfoHeight), false, ImGuiWindowFlags_NoDecoration);
158 int maxNonVisibleThumbThreads = 3;

Callers

nothing calls this directly

Calls 6

GetCursorPosFunction · 0.85
BindThumbnailMethod · 0.80
RequestThumbnailMethod · 0.80
BindMethod · 0.80
GetSortKeyMethod · 0.80

Tested by

no test coverage detected