Skip to content

Commit

Permalink
Added GetWindowFont(), GetWindowFontSize() + comments following user'…
Browse files Browse the repository at this point in the history
…s feedback
  • Loading branch information
ocornut committed Oct 25, 2014
1 parent 9f05a2b commit af37fb1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
18 changes: 15 additions & 3 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
// See ImGui::ShowTestWindow() for sample code.
// Read 'Programmer guide' below for notes on how to setup ImGui in your codebase.
// Get latest version at https://github.com/ocornut/imgui
// Developped by Omar Cornut and contributors.
// Developed by Omar Cornut and contributors.

/*
MISSION STATEMENT
=================
- easy to use to create code-driven and data-driven tools
- easy to use to create adhoc short-lived tools and long-lived, more elaborate tools
- easy to use to create ad hoc short-lived tools and long-lived, more elaborate tools
- easy to hack and improve
- minimize screen real-estate usage
- minimize setup and maintainance
- minimize state storage on user side
- portable, minimize dependencies, run on target (consoles, etc.)
- efficient runtime (nb- we do allocate when "growing" content - creating a window / opening a tree node for the first time, etc. - but a typical frame won't allocate anything)
- efficient runtime (NB- we do allocate when "growing" content - creating a window / opening a tree node for the first time, etc. - but a typical frame won't allocate anything)
- read about immediate-mode GUI principles @ http://mollyrocket.com/861, http://mollyrocket.com/forums/index.html
Designed for developers and content-creators, not the typical end-user! Some of the weaknesses includes:
Expand Down Expand Up @@ -2599,6 +2599,18 @@ ImDrawList* GetWindowDrawList()
return window->DrawList;
}

ImFont GetWindowFont()
{
ImGuiWindow* window = GetCurrentWindow();
return window->Font();
}

float GetWindowFontSize()
{
ImGuiWindow* window = GetCurrentWindow();
return window->FontSize();
}

void SetWindowFontScale(float scale)
{
ImGuiWindow* window = GetCurrentWindow();
Expand Down
9 changes: 7 additions & 2 deletions imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ namespace ImGui
ImVec2 GetWindowContentRegionMin();
ImVec2 GetWindowContentRegionMax();
ImDrawList* GetWindowDrawList(); // get rendering command-list if you want to append your own draw primitives.
ImFont GetWindowFont();
float GetWindowFontSize();
void SetWindowFontScale(float scale); // per-window font scale. Adjust IO.FontBaseScale if you want to scale all windows together.
void SetScrollPosHere(); // adjust scrolling position to center into the current cursor position.
void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use 'offset' to access sub components of a multiple component widget.
Expand Down Expand Up @@ -575,7 +577,6 @@ struct ImDrawCmd
ImVec4 clip_rect;
};

// sizeof() == 20
struct ImDrawVert
{
ImVec2 pos;
Expand All @@ -584,7 +585,11 @@ struct ImDrawVert
};

// Draw command list
// User is responsible for providing a renderer for this in ImGuiIO::RenderDrawListFn
// This is the low-level list of polygon that ImGui:: functions are filling. At the end of the frame, all command lists are passed to your ImGuiIO::RenderDrawListFn function for rendering.
// Each ImGui window contains its own ImDrawList.
// If you want to add custom rendering within a window, you can use ImGui::GetWindowDrawList() to access the current draw list and add your own primitives.
// You can interleave normal ImGui:: calls and adding primitives to the current draw list.
// Note that this only gives you access to rendering polygons. If your intent is to create custom widgets and the publicly exposed functions/data aren't sufficient, you can add code in imgui_user.inl
struct ImDrawList
{
// This is what you have to render
Expand Down

0 comments on commit af37fb1

Please sign in to comment.