Skip to content

Commit cf285ca

Browse files
committed
gh-87: support ui loading from xml files with code behind auto binding (like in WPF)
1 parent 691714a commit cf285ca

File tree

82 files changed

+2522
-714
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+2522
-714
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
"**/*.asset": "yaml",
102102
"**/*.shader": "yaml",
103103
"**/*.scene": "yaml",
104+
"**/*.style": "yaml",
104105
"*.moc": "cpp",
105106
"coroutine": "cpp",
106107
"resumable": "cpp",

CMakeLists.txt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,13 @@ function(wmoge_plugin name)
8181
if (NOT arg_SOURCES)
8282
message(FATAL_ERROR "[wmoge_game(${name})]: SOURCES is a required argument")
8383
endif()
84-
if (NOT arg_DEPENDENCIES)
85-
message(FATAL_ERROR "[wmoge_game(${name})]: DEPENDENCIES is a required argument")
86-
endif()
84+
8785
if (NOT arg_TYPE)
8886
set(arg_TYPE STATIC)
8987
endif()
9088

9189
add_library(${name} ${arg_TYPE} ${arg_SOURCES})
92-
target_link_libraries(${name} PUBLIC ${arg_DEPENDENCIES})
90+
target_link_libraries(${name} PUBLIC wmoge_engine ${arg_DEPENDENCIES})
9391
target_include_directories(${name} PUBLIC ${arg_INCLUDES})
9492
message(STATUS "Configure engine plugin '${name}' type ${arg_TYPE}")
9593
endfunction(wmoge_plugin name sources)
@@ -107,15 +105,12 @@ function(wmoge_game name)
107105
if (NOT arg_SOURCES)
108106
message(FATAL_ERROR "[wmoge_game(${name})]: SOURCES is a required argument")
109107
endif()
110-
if (NOT arg_DEPENDENCIES)
111-
message(FATAL_ERROR "[wmoge_game(${name})]: DEPENDENCIES is a required argument")
112-
endif()
113108

114109
set(EXE_GAME "game")
115110
set(EXE_EDITOR "editor")
116111

117112
add_executable(${EXE_GAME} ${arg_SOURCES} ${arg_ICON_GAME})
118-
target_link_libraries(${EXE_GAME} PRIVATE wmoge ${arg_DEPENDENCIES})
113+
target_link_libraries(${EXE_GAME} PRIVATE wmoge_engine ${arg_DEPENDENCIES})
119114
target_include_directories(${EXE_GAME} PRIVATE ${arg_INCLUDES})
120115
target_compile_definitions(${EXE_GAME} PRIVATE WMOGE_BUILD_TYPE_GAME)
121116
message(STATUS "Configure ${name} game exe '${EXE_GAME}' type APPLICATION")

deps/imgui/imgui.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,7 @@ ImGuiStyle::ImGuiStyle()
13481348
FramePadding = ImVec2(4,3); // Padding within a framed rectangle (used by most widgets)
13491349
FrameRounding = 0.0f; // Radius of frame corners rounding. Set to 0.0f to have rectangular frames (used by most widgets).
13501350
FrameBorderSize = 0.0f; // Thickness of border around frames. Generally set to 0.0f or 1.0f. Other values not well tested.
1351+
MenuItemTabSize = 0.0f; // Tabbing of menu items (menu item and sub menu elements). Set to 0.0f to do no tab
13511352
ItemSpacing = ImVec2(8,4); // Horizontal and vertical spacing between widgets/lines
13521353
ItemInnerSpacing = ImVec2(4,4); // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label)
13531354
CellPadding = ImVec2(4,2); // Padding within a table cell. Cellpadding.x is locked for entire table. CellPadding.y may be altered between different rows.
@@ -3566,6 +3567,7 @@ const char* ImGui::GetStyleColorName(ImGuiCol idx)
35663567
case ImGuiCol_TitleBgActive: return "TitleBgActive";
35673568
case ImGuiCol_TitleBgCollapsed: return "TitleBgCollapsed";
35683569
case ImGuiCol_MenuBarBg: return "MenuBarBg";
3570+
case ImGuiCol_MenuBarBorder: return "MenuBarBorder";
35693571
case ImGuiCol_ScrollbarBg: return "ScrollbarBg";
35703572
case ImGuiCol_ScrollbarGrab: return "ScrollbarGrab";
35713573
case ImGuiCol_ScrollbarGrabHovered: return "ScrollbarGrabHovered";
@@ -5789,9 +5791,12 @@ static void ImGui::RenderDimmedBackgrounds()
57895791
ImGuiViewport* viewport = window->Viewport;
57905792
float distance = g.FontSize;
57915793
ImRect bb = window->Rect();
5792-
bb.Expand(distance);
5793-
if (bb.GetWidth() >= viewport->Size.x && bb.GetHeight() >= viewport->Size.y)
5794-
bb.Expand(-distance - 1.0f); // If a window fits the entire viewport, adjust its highlight inward
5794+
5795+
// EORACHEV: do not use expand, it looks wiered (like some thing is broken in calculating window size)
5796+
// bb.Expand(distance);
5797+
// if (bb.GetWidth() >= viewport->Size.x && bb.GetHeight() >= viewport->Size.y)
5798+
// bb.Expand(-distance - 1.0f); // If a window fits the entire viewport, adjust its highlight inward
5799+
57955800
window->DrawList->ChannelsMerge();
57965801
if (window->DrawList->CmdBuffer.Size == 0)
57975802
window->DrawList->AddDrawCmd();
@@ -7130,7 +7135,7 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar
71307135
menu_bar_rect.ClipWith(window->Rect()); // Soft clipping, in particular child window don't have minimum size covering the menu bar so this is useful for them.
71317136
window->DrawList->AddRectFilled(menu_bar_rect.Min + ImVec2(window_border_size, 0), menu_bar_rect.Max - ImVec2(window_border_size, 0), GetColorU32(ImGuiCol_MenuBarBg), (flags & ImGuiWindowFlags_NoTitleBar) ? window_rounding : 0.0f, ImDrawFlags_RoundCornersTop);
71327137
if (style.FrameBorderSize > 0.0f && menu_bar_rect.Max.y < window->Pos.y + window->Size.y)
7133-
window->DrawList->AddLine(menu_bar_rect.GetBL(), menu_bar_rect.GetBR(), GetColorU32(ImGuiCol_Border), style.FrameBorderSize);
7138+
window->DrawList->AddLine(menu_bar_rect.GetBL(), menu_bar_rect.GetBR(), GetColorU32(ImGuiCol_MenuBarBorder), style.FrameBorderSize);
71347139
}
71357140

71367141
// Docking: Unhide tab bar (small triangle in the corner), drag from small triangle to quickly undock

deps/imgui/imgui.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,6 +1701,7 @@ enum ImGuiCol_
17011701
ImGuiCol_TitleBgActive, // Title bar when focused
17021702
ImGuiCol_TitleBgCollapsed, // Title bar when collapsed
17031703
ImGuiCol_MenuBarBg,
1704+
ImGuiCol_MenuBarBorder,
17041705
ImGuiCol_ScrollbarBg,
17051706
ImGuiCol_ScrollbarGrab,
17061707
ImGuiCol_ScrollbarGrabHovered,
@@ -2224,6 +2225,7 @@ struct ImGuiStyle
22242225
ImVec2 FramePadding; // Padding within a framed rectangle (used by most widgets).
22252226
float FrameRounding; // Radius of frame corners rounding. Set to 0.0f to have rectangular frame (used by most widgets).
22262227
float FrameBorderSize; // Thickness of border around frames. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly).
2228+
float MenuItemTabSize; // Tabbing of menu items (menu item and sub menu elements). Set to 0.0f to do no tab
22272229
ImVec2 ItemSpacing; // Horizontal and vertical spacing between widgets/lines.
22282230
ImVec2 ItemInnerSpacing; // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label).
22292231
ImVec2 CellPadding; // Padding within a table cell. Cellpadding.x is locked for entire table. CellPadding.y may be altered between different rows.

deps/imgui/imgui_draw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4336,7 +4336,7 @@ void ImGui::RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImU32 col, ImGuiDir d
43364336
{
43374337
const float h = draw_list->_Data->FontSize * 1.00f;
43384338
float r = h * 0.40f * scale;
4339-
ImVec2 center = pos + ImVec2(h * 0.50f, h * 0.50f * scale);
4339+
ImVec2 center = pos + ImVec2(h * 0.50f, h * 0.50f);
43404340

43414341
ImVec2 a, b, c;
43424342
switch (dir)

deps/imgui/imgui_widgets.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,7 @@ bool ImGui::RadioButton(const char* label, bool active)
13421342
ImVec2 center = check_bb.GetCenter();
13431343
center.x = IM_ROUND(center.x);
13441344
center.y = IM_ROUND(center.y);
1345-
const float radius = (square_sz - 1.0f) * 0.5f;
1345+
const float radius = (square_sz - 1.0f) * 0.4f;
13461346

13471347
bool hovered, held;
13481348
bool pressed = ButtonBehavior(total_bb, id, &hovered, &held);
@@ -6807,7 +6807,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
68076807
if (flags & ImGuiTreeNodeFlags_Bullet)
68086808
RenderBullet(window->DrawList, ImVec2(text_pos.x - text_offset_x * 0.5f, text_pos.y + g.FontSize * 0.5f), text_col);
68096809
else if (!is_leaf)
6810-
RenderArrow(window->DrawList, ImVec2(text_pos.x - text_offset_x + padding.x, text_pos.y + g.FontSize * 0.15f), text_col, is_open ? ((flags & ImGuiTreeNodeFlags_UpsideDownArrow) ? ImGuiDir_Up : ImGuiDir_Down) : ImGuiDir_Right, 0.70f);
6810+
RenderArrow(window->DrawList, ImVec2(text_pos.x - text_offset_x + padding.x, text_pos.y), text_col, is_open ? ((flags & ImGuiTreeNodeFlags_UpsideDownArrow) ? ImGuiDir_Up : ImGuiDir_Down) : ImGuiDir_Right, 0.70f);
68116811
if (g.LogEnabled)
68126812
LogSetNextTextDecoration(">", NULL);
68136813
}
@@ -8930,15 +8930,15 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
89308930
popup_pos = ImVec2(pos.x, pos.y - style.WindowPadding.y);
89318931
float icon_w = (icon && icon[0]) ? CalcTextSize(icon, NULL).x : 0.0f;
89328932
float checkmark_w = IM_TRUNC(g.FontSize * 1.20f);
8933-
float min_w = window->DC.MenuColumns.DeclColumns(icon_w, label_size.x, 0.0f, checkmark_w); // Feedback to next frame
8933+
float min_w = window->DC.MenuColumns.DeclColumns(icon_w, label_size.x + style.MenuItemTabSize, 0.0f, checkmark_w); // Feedback to next frame
89348934
float extra_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
8935-
ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
8935+
ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel + style.MenuItemTabSize, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
89368936
pressed = Selectable("", menu_is_open, selectable_flags | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, label_size.y));
89378937
LogSetNextTextDecoration("", ">");
89388938
RenderText(text_pos, label);
89398939
if (icon_w > 0.0f)
89408940
RenderText(pos + ImVec2(offsets->OffsetIcon, 0.0f), icon);
8941-
RenderArrow(window->DrawList, pos + ImVec2(offsets->OffsetMark + extra_w + g.FontSize * 0.30f, 0.0f), GetColorU32(ImGuiCol_Text), ImGuiDir_Right);
8941+
RenderArrow(window->DrawList, pos + ImVec2(offsets->OffsetMark + extra_w + g.FontSize * 0.30f, 0.0f), GetColorU32(ImGuiCol_Text), ImGuiDir_Right, 0.8f);
89428942
}
89438943
if (!enabled)
89448944
EndDisabled();
@@ -9142,7 +9142,7 @@ bool ImGui::MenuItemEx(const char* label, const char* icon, const char* shortcut
91429142
pressed = Selectable("", false, selectable_flags | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, label_size.y));
91439143
if (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_Visible)
91449144
{
9145-
RenderText(pos + ImVec2(offsets->OffsetLabel, 0.0f), label);
9145+
RenderText(pos + ImVec2(offsets->OffsetLabel + style.MenuItemTabSize, 0.0f), label);
91469146
if (icon_w > 0.0f)
91479147
RenderText(pos + ImVec2(offsets->OffsetIcon, 0.0f), icon);
91489148
if (shortcut_w > 0.0f)

editor/code/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ add_library(wmoge_editor_headers INTERFACE)
1515
target_include_directories(wmoge_editor_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/)
1616

1717
# engine library target link to editor library
18-
target_link_libraries(wmoge_editor PUBLIC wmoge)
18+
target_link_libraries(wmoge_editor PUBLIC wmoge_engine)
1919

2020
# editor headers target link to editor library
2121
target_link_libraries(wmoge_editor PUBLIC wmoge_editor_headers)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ description: "font"
88
import_data:
99
rtti: FreetypeImportData
1010
source_files: [{file: "editor/fonts/roboto_black.ttf"}]
11-
height: 32
11+
height: 38
1212
glyphs_in_row: 16

editor/fonts/roboto_black_italic.asset renamed to editor/fonts/roboto_black_italic.ttf.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ description: "font"
88
import_data:
99
rtti: FreetypeImportData
1010
source_files: [{file: "editor/fonts/roboto_black_italic.ttf"}]
11-
height: 32
11+
height: 38
1212
glyphs_in_row: 16
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ description: "font"
88
import_data:
99
rtti: FreetypeImportData
1010
source_files: [{file: "editor/fonts/roboto_bold.ttf"}]
11-
height: 32
11+
height: 38
1212
glyphs_in_row: 16

0 commit comments

Comments
 (0)