1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-28 09:30:56 +01:00

Fixed Y scroll aiming when Horizontal Scrollbar is enabled (#665). Tweak log demo.

This commit is contained in:
omar 2017-08-07 21:53:57 +08:00
parent 7096fd8500
commit e36b41cbd0
2 changed files with 3 additions and 3 deletions

View File

@ -4200,7 +4200,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
if (window->ScrollTarget.y < FLT_MAX)
{
float center_ratio = window->ScrollTargetCenterRatio.y;
window->Scroll.y = window->ScrollTarget.y - ((1.0f - center_ratio) * (window->TitleBarHeight() + window->MenuBarHeight())) - (center_ratio * window->SizeFull.y);
window->Scroll.y = window->ScrollTarget.y - ((1.0f - center_ratio) * (window->TitleBarHeight() + window->MenuBarHeight())) - (center_ratio * (window->SizeFull.y - window->ScrollbarSizes.y));
window->ScrollTarget.y = FLT_MAX;
}
window->Scroll = ImMax(window->Scroll, ImVec2(0.0f, 0.0f));

View File

@ -2464,10 +2464,10 @@ static void ShowExampleAppLog(bool* p_open)
{
static ExampleAppLog log;
// Demo fill
// Demo: add random items (unless Ctrl is held)
static float last_time = -1.0f;
float time = ImGui::GetTime();
if (time - last_time >= 0.3f)
if (time - last_time >= 0.20f && !ImGui::GetIO().KeyCtrl)
{
const char* random_words[] = { "system", "info", "warning", "error", "fatal", "notice", "log" };
log.AddLog("[%s] Hello, time is %.1f, rand() %d\n", random_words[rand() % IM_ARRAYSIZE(random_words)], time, (int)rand());