mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-17 01:04:19 +00:00
power saving mode which only renders upon event happening
This commit is contained in:
parent
a726bded11
commit
4f978fd312
7 changed files with 295 additions and 28 deletions
|
|
@ -757,7 +757,10 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|||
ClearActiveID();
|
||||
}
|
||||
if (pressed)
|
||||
{
|
||||
g.ActiveIdHasBeenPressedBefore = true;
|
||||
g.IO.SetNextRefresh(0, "button pressed");
|
||||
}
|
||||
}
|
||||
|
||||
// Activation highlight (this may be a remote activation)
|
||||
|
|
@ -1260,6 +1263,7 @@ bool ImGui::Checkbox(const char* label, bool* v)
|
|||
*v = checked;
|
||||
pressed = true; // return value
|
||||
MarkItemEdited(id);
|
||||
g.IO.SetNextRefresh(0, "checkbox pressed");
|
||||
}
|
||||
|
||||
const ImRect check_bb(pos, pos + ImVec2(square_sz, square_sz));
|
||||
|
|
@ -5576,9 +5580,24 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||
if (render_cursor)
|
||||
{
|
||||
state->CursorAnim += io.DeltaTime;
|
||||
bool cursor_is_visible = (!g.IO.ConfigInputTextCursorBlink) || (state->CursorAnim <= 0.0f) || ImFmod(state->CursorAnim, 1.20f) <= 0.80f;
|
||||
ImVec2 cursor_screen_pos = ImTrunc(draw_pos + cursor_offset - draw_scroll);
|
||||
ImRect cursor_screen_rect(cursor_screen_pos.x, cursor_screen_pos.y - g.FontSize + 0.5f, cursor_screen_pos.x + 1.0f, cursor_screen_pos.y - 1.5f);
|
||||
|
||||
bool cursor_is_visible = true;
|
||||
if (g.IO.ConfigInputTextCursorBlink)
|
||||
{
|
||||
float next_refresh_time = -state->CursorAnim;
|
||||
if (state->CursorAnim > 0.0f)
|
||||
{
|
||||
float modded = ImFmod(state->CursorAnim, 1.20f);
|
||||
bool now_visible_blink_phase = modded <= 0.80f;
|
||||
state->CursorAnim = modded; //prevent fp error from accumulation
|
||||
next_refresh_time = now_visible_blink_phase ? 0.80f - modded : 1.20f - modded;
|
||||
cursor_is_visible = now_visible_blink_phase;
|
||||
}
|
||||
g.IO.SetNextRefresh( next_refresh_time, "text cursor blink");
|
||||
}
|
||||
|
||||
if (cursor_is_visible && cursor_screen_rect.Overlaps(clip_rect))
|
||||
draw_window->DrawList->AddLine(cursor_screen_rect.Min, cursor_screen_rect.GetBL(), GetColorU32(ImGuiCol_InputTextCursor), 1.0f); // FIXME-DPI: Cursor thickness (#7031)
|
||||
|
||||
|
|
@ -9486,6 +9505,9 @@ bool ImGui::MenuItemEx(const char* label, const char* icon, const char* shortcut
|
|||
if (menuset_is_open)
|
||||
PopItemFlag();
|
||||
|
||||
if (pressed)
|
||||
g.IO.SetNextRefresh(0,"menu item pressed");
|
||||
|
||||
return pressed;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue