blob: 0c66a5762306e4dcb82c238503e5d1bbb93b6230 (
plain)
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
|
/*******************************************************************************************
*
* raylib-extras [ImGui] example - asset browser
*
* This is a more complex ImGui Integration
* It shows how to build windows on top of 2d and 3d views using a render texture
*
* Copyright (c) 2024 Jeffery Myers
*
********************************************************************************************/
#include "item_view.h"
#include "imgui.h"
#include "imgui_utils.h"
#include "rlImGuiColors.h"
#include "raylib.h"
extern ImFont* IconFont;
ViewableItem* ListItemView::Show(ViewableItemContainer& container)
{
ViewableItem* item = container.Reset();
ViewableItem* selected = nullptr;
while (item)
{
float x = ImGui::GetCursorPosX();
const char* name = TextFormat("###%s", item->Name.c_str());
if (item->Tint.a > 0)
ImGui::TextColored(rlImGuiColors::Convert(item->Tint), " %s", item->Icon.c_str());
else
ImGui::Text(" %s", item->Icon.c_str());
ImGui::SameLine(0, 0);
ImGui::Text(" %s", item->Name.c_str());
ImGui::SameLine(0, 0);
ImGui::SetCursorPosX(x);
//ImGui::SetItemAllowOverlap();
ImGui::Selectable(name);
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0))
{
selected = item;
}
item = container.Next();
}
return selected;
}
|