Minor comments, tweaks

This commit is contained in:
ocornut 2016-05-07 18:10:32 +02:00
parent 313d388bba
commit ce4d731486
3 changed files with 8 additions and 5 deletions

View File

@ -158,7 +158,7 @@ namespace ImGui
IMGUI_API void SetScrollY(float scroll_y); // set scrolling amount [0..GetScrollMaxY()] IMGUI_API void SetScrollY(float scroll_y); // set scrolling amount [0..GetScrollMaxY()]
IMGUI_API void SetScrollHere(float center_y_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom. IMGUI_API void SetScrollHere(float center_y_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom.
IMGUI_API void SetScrollFromPosY(float pos_y, float center_y_ratio = 0.5f); // adjust scrolling amount to make given position valid. use GetCursorPos() or GetCursorStartPos()+offset to get valid positions. IMGUI_API void SetScrollFromPosY(float pos_y, float center_y_ratio = 0.5f); // adjust scrolling amount to make given position valid. use GetCursorPos() or GetCursorStartPos()+offset to get valid positions.
IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget. Use negative 'offset' to access previous widgets.
IMGUI_API void SetStateStorage(ImGuiStorage* tree); // replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it) IMGUI_API void SetStateStorage(ImGuiStorage* tree); // replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it)
IMGUI_API ImGuiStorage* GetStateStorage(); IMGUI_API ImGuiStorage* GetStateStorage();
@ -948,7 +948,7 @@ struct ImGuiTextBuffer
IMGUI_API void appendv(const char* fmt, va_list args); IMGUI_API void appendv(const char* fmt, va_list args);
}; };
// Helper: Key->value storage // Helper: Simple Key->value storage
// - Store collapse state for a tree (Int 0/1) // - Store collapse state for a tree (Int 0/1)
// - Store color edit options (Int using values in ImGuiColorEditMode enum). // - Store color edit options (Int using values in ImGuiColorEditMode enum).
// - Custom user storage for temporary values. // - Custom user storage for temporary values.
@ -956,6 +956,7 @@ struct ImGuiTextBuffer
// Declare your own storage if: // Declare your own storage if:
// - You want to manipulate the open/close state of a particular sub-tree in your interface (tree node uses Int 0/1 to store their state). // - You want to manipulate the open/close state of a particular sub-tree in your interface (tree node uses Int 0/1 to store their state).
// - You want to store custom debug data easily without adding or editing structures in your code. // - You want to store custom debug data easily without adding or editing structures in your code.
// Types are NOT stored, so it is up to you to make sure your Key don't collide with different types.
struct ImGuiStorage struct ImGuiStorage
{ {
struct Pair struct Pair
@ -970,7 +971,7 @@ struct ImGuiStorage
// - Get***() functions find pair, never add/allocate. Pairs are sorted so a query is O(log N) // - Get***() functions find pair, never add/allocate. Pairs are sorted so a query is O(log N)
// - Set***() functions find pair, insertion on demand if missing. // - Set***() functions find pair, insertion on demand if missing.
// - Sorted insertion is costly but should amortize. A typical frame shouldn't need to insert any new pair. // - Sorted insertion is costly, paid once. A typical frame shouldn't need to insert any new pair.
IMGUI_API void Clear(); IMGUI_API void Clear();
IMGUI_API int GetInt(ImGuiID key, int default_val = 0) const; IMGUI_API int GetInt(ImGuiID key, int default_val = 0) const;
IMGUI_API void SetInt(ImGuiID key, int val); IMGUI_API void SetInt(ImGuiID key, int val);

View File

@ -1030,9 +1030,11 @@ void ImGui::ShowTestWindow(bool* p_open)
static bool track = true; static bool track = true;
static int track_line = 50, scroll_to_px = 200; static int track_line = 50, scroll_to_px = 200;
ImGui::Checkbox("Track", &track); ImGui::Checkbox("Track", &track);
ImGui::PushItemWidth(100);
ImGui::SameLine(130); track |= ImGui::DragInt("##line", &track_line, 0.25f, 0, 99, "Line %.0f"); ImGui::SameLine(130); track |= ImGui::DragInt("##line", &track_line, 0.25f, 0, 99, "Line %.0f");
bool scroll_to = ImGui::Button("Scroll To"); bool scroll_to = ImGui::Button("Scroll To");
ImGui::SameLine(130); scroll_to |= ImGui::DragInt("##pos_y", &scroll_to_px, 1.00f, 0, 9999, "y = %.0f px"); ImGui::SameLine(130); scroll_to |= ImGui::DragInt("##pos_y", &scroll_to_px, 1.00f, 0, 9999, "y = %.0f px");
ImGui::PopItemWidth();
if (scroll_to) track = false; if (scroll_to) track = false;
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)

View File

@ -378,7 +378,7 @@ struct ImGuiState
ImGuiWindow* MovedWindow; // Track the child window we clicked on to move a window. ImGuiWindow* MovedWindow; // Track the child window we clicked on to move a window.
ImGuiID MovedWindowMoveId; // == MovedWindow->RootWindow->MoveId ImGuiID MovedWindowMoveId; // == MovedWindow->RootWindow->MoveId
ImVector<ImGuiIniData> Settings; // .ini Settings ImVector<ImGuiIniData> Settings; // .ini Settings
float SettingsDirtyTimer; // Save .ini settinngs on disk when time reaches zero float SettingsDirtyTimer; // Save .ini Settings on disk when time reaches zero
ImVector<ImGuiColMod> ColorModifiers; // Stack for PushStyleColor()/PopStyleColor() ImVector<ImGuiColMod> ColorModifiers; // Stack for PushStyleColor()/PopStyleColor()
ImVector<ImGuiStyleMod> StyleModifiers; // Stack for PushStyleVar()/PopStyleVar() ImVector<ImGuiStyleMod> StyleModifiers; // Stack for PushStyleVar()/PopStyleVar()
ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont() ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont()