<commit_before>// Copyright (c) 2020 The Orbit Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "TimeGraphLayout.h"

#include <imgui.h>

#include "OrbitBase/ThreadConstants.h"

TimeGraphLayout::TimeGraphLayout() {
  text_box_height_ = 20.f;
  core_height_ = 10.f;
  thread_state_track_height_ = 4.0f;
  event_track_height_ = 10.f;
  all_threads_event_track_scale_ = 2.f;
  variable_track_height_ = 20.f;
  track_content_bottom_margin_ = 5.f;
  track_content_top_margin_ = 5.f;
  space_between_cores_ = 2.f;
  space_between_gpu_depths_ = 2.f;
  space_between_tracks_ = 10.f;
  space_between_tracks_and_thread_ = 5.f;
  space_between_subtracks_ = -5.f;
  space_between_thread_blocks_ = 35.f;
  track_label_offset_x_ = 30.f;
  slider_width_ = 15.f;
  track_tab_width_ = 350.f;
  track_tab_height_ = 25.f;
  track_tab_offset_ = 0.f;
  track_intent_offset_ = 5.f;
  collapse_button_offset_ = 15.f;
  collapse_button_size_ = 10.f;
  collapse_button_decrease_per_indentation_ = 2.f;
  rounding_radius_ = 8.f;
  rounding_num_sides_ = 16;
  text_offset_ = 5.f;
  right_margin_ = 10.f;
  scheduler_track_offset_ = 10.f;
  toolbar_icon_height_ = 24.f;
  generic_fixed_spacer_width_ = 10.f;
  scale_ = 1.f;
  time_bar_height_ = 15.f;
  font_size_ = 14;
};

#define FLOAT_SLIDER(x) FLOAT_SLIDER_MIN_MAX(x, 0, 100.f)
#define FLOAT_SLIDER_MIN_MAX(x, min, max)     \
  if (ImGui::SliderFloat(#x, &x, min, max)) { \
    needs_redraw = true;                      \
  }

bool TimeGraphLayout::DrawProperties() {
  bool needs_redraw = false;
  FLOAT_SLIDER(track_label_offset_x_);
  FLOAT_SLIDER(text_box_height_);
  FLOAT_SLIDER(core_height_);
  FLOAT_SLIDER(thread_state_track_height_);
  FLOAT_SLIDER(event_track_height_);
  FLOAT_SLIDER_MIN_MAX(all_threads_event_track_scale_, 0, 10.f);
  FLOAT_SLIDER(variable_track_height_);
  FLOAT_SLIDER(space_between_cores_);
  FLOAT_SLIDER(space_between_gpu_depths_);
  FLOAT_SLIDER(space_between_tracks_);
  FLOAT_SLIDER(space_between_tracks_and_thread_);
  FLOAT_SLIDER(space_between_subtracks_);
  FLOAT_SLIDER(space_between_thread_blocks_);
  FLOAT_SLIDER(slider_width_);
  FLOAT_SLIDER(time_bar_height_);
  FLOAT_SLIDER(track_tab_height_);
  FLOAT_SLIDER(track_tab_offset_);
  FLOAT_SLIDER(track_intent_offset_);
  FLOAT_SLIDER(collapse_button_size_);
  FLOAT_SLIDER(collapse_button_decrease_per_indentation_);

  FLOAT_SLIDER(collapse_button_offset_);
  FLOAT_SLIDER(rounding_radius_);
  FLOAT_SLIDER(rounding_num_sides_);
  FLOAT_SLIDER(text_offset_);
  FLOAT_SLIDER(right_margin_);
  FLOAT_SLIDER(scheduler_track_offset_);
  FLOAT_SLIDER_MIN_MAX(track_tab_width_, 0, 1000.f);
  FLOAT_SLIDER_MIN_MAX(track_content_bottom_margin_, 0, 20.f);
  FLOAT_SLIDER_MIN_MAX(track_content_top_margin_, 0, 20.f);
  FLOAT_SLIDER(toolbar_icon_height_);
  FLOAT_SLIDER(generic_fixed_spacer_width_);
  FLOAT_SLIDER_MIN_MAX(scale_, kMinScale, kMaxScale);
  ImGui::Checkbox("Draw Track Background", &draw_track_background_);

  return needs_redraw;
}

float TimeGraphLayout::GetCollapseButtonSize(int indentation_level) const {
  float button_size_without_scaling =
      collapse_button_size_ -
      collapse_button_decrease_per_indentation_ * static_cast<float>(indentation_level);

  // We want the button to scale slower than other elements, so we use sqrt() function.
  return button_size_without_scaling * sqrt(scale_);
}

float TimeGraphLayout::GetBottomMargin() const {
  // The bottom consists of the slider (where we have to take the width, as it
  // is rotated), and the time bar.
  return GetSliderWidth() + GetTimeBarHeight();
}

float TimeGraphLayout::GetEventTrackHeightFromTid(uint32_t tid) const {
  float height = GetEventTrackHeight();
  if (tid == orbit_base::kAllProcessThreadsTid) {
    height *= GetAllThreadsEventTrackScale();
  }
  return height;
}
<commit_msg>Change the space between subtracks<commit_after>// Copyright (c) 2020 The Orbit Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "TimeGraphLayout.h"

#include <imgui.h>

#include "OrbitBase/ThreadConstants.h"

TimeGraphLayout::TimeGraphLayout() {
  text_box_height_ = 20.f;
  core_height_ = 10.f;
  thread_state_track_height_ = 4.0f;
  event_track_height_ = 10.f;
  all_threads_event_track_scale_ = 2.f;
  variable_track_height_ = 20.f;
  track_content_bottom_margin_ = 5.f;
  track_content_top_margin_ = 5.f;
  space_between_cores_ = 2.f;
  space_between_gpu_depths_ = 2.f;
  space_between_tracks_ = 10.f;
  space_between_tracks_and_thread_ = 5.f;
  space_between_subtracks_ = 0.f;
  space_between_thread_blocks_ = 35.f;
  track_label_offset_x_ = 30.f;
  slider_width_ = 15.f;
  track_tab_width_ = 350.f;
  track_tab_height_ = 25.f;
  track_tab_offset_ = 0.f;
  track_intent_offset_ = 5.f;
  collapse_button_offset_ = 15.f;
  collapse_button_size_ = 10.f;
  collapse_button_decrease_per_indentation_ = 2.f;
  rounding_radius_ = 8.f;
  rounding_num_sides_ = 16;
  text_offset_ = 5.f;
  right_margin_ = 10.f;
  scheduler_track_offset_ = 10.f;
  toolbar_icon_height_ = 24.f;
  generic_fixed_spacer_width_ = 10.f;
  scale_ = 1.f;
  time_bar_height_ = 15.f;
  font_size_ = 14;
};

#define FLOAT_SLIDER(x) FLOAT_SLIDER_MIN_MAX(x, 0, 100.f)
#define FLOAT_SLIDER_MIN_MAX(x, min, max)     \
  if (ImGui::SliderFloat(#x, &x, min, max)) { \
    needs_redraw = true;                      \
  }

bool TimeGraphLayout::DrawProperties() {
  bool needs_redraw = false;
  FLOAT_SLIDER(track_label_offset_x_);
  FLOAT_SLIDER(text_box_height_);
  FLOAT_SLIDER(core_height_);
  FLOAT_SLIDER(thread_state_track_height_);
  FLOAT_SLIDER(event_track_height_);
  FLOAT_SLIDER_MIN_MAX(all_threads_event_track_scale_, 0, 10.f);
  FLOAT_SLIDER(variable_track_height_);
  FLOAT_SLIDER(space_between_cores_);
  FLOAT_SLIDER(space_between_gpu_depths_);
  FLOAT_SLIDER(space_between_tracks_);
  FLOAT_SLIDER(space_between_tracks_and_thread_);
  FLOAT_SLIDER(space_between_subtracks_);
  FLOAT_SLIDER(space_between_thread_blocks_);
  FLOAT_SLIDER(slider_width_);
  FLOAT_SLIDER(time_bar_height_);
  FLOAT_SLIDER(track_tab_height_);
  FLOAT_SLIDER(track_tab_offset_);
  FLOAT_SLIDER(track_intent_offset_);
  FLOAT_SLIDER(collapse_button_size_);
  FLOAT_SLIDER(collapse_button_decrease_per_indentation_);

  FLOAT_SLIDER(collapse_button_offset_);
  FLOAT_SLIDER(rounding_radius_);
  FLOAT_SLIDER(rounding_num_sides_);
  FLOAT_SLIDER(text_offset_);
  FLOAT_SLIDER(right_margin_);
  FLOAT_SLIDER(scheduler_track_offset_);
  FLOAT_SLIDER_MIN_MAX(track_tab_width_, 0, 1000.f);
  FLOAT_SLIDER_MIN_MAX(track_content_bottom_margin_, 0, 20.f);
  FLOAT_SLIDER_MIN_MAX(track_content_top_margin_, 0, 20.f);
  FLOAT_SLIDER(toolbar_icon_height_);
  FLOAT_SLIDER(generic_fixed_spacer_width_);
  FLOAT_SLIDER_MIN_MAX(scale_, kMinScale, kMaxScale);
  ImGui::Checkbox("Draw Track Background", &draw_track_background_);

  return needs_redraw;
}

float TimeGraphLayout::GetCollapseButtonSize(int indentation_level) const {
  float button_size_without_scaling =
      collapse_button_size_ -
      collapse_button_decrease_per_indentation_ * static_cast<float>(indentation_level);

  // We want the button to scale slower than other elements, so we use sqrt() function.
  return button_size_without_scaling * sqrt(scale_);
}

float TimeGraphLayout::GetBottomMargin() const {
  // The bottom consists of the slider (where we have to take the width, as it
  // is rotated), and the time bar.
  return GetSliderWidth() + GetTimeBarHeight();
}

float TimeGraphLayout::GetEventTrackHeightFromTid(uint32_t tid) const {
  float height = GetEventTrackHeight();
  if (tid == orbit_base::kAllProcessThreadsTid) {
    height *= GetAllThreadsEventTrackScale();
  }
  return height;
}

{'fraction_non_alphanumeric': 0.09231754161331626, 'fraction_numerical': 0.01997439180537772, 'mean_word_length': 5.664675767918089, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '645143', 'n_tokens_mistral': 3221, 'n_tokens_neox': 2900, 'n_words': 482}