Browse Source

Made it possible to adjust tooltip top offset in configuration item source.tooltip_top_offset

merge-requests/413/head
eidheim 2 years ago
parent
commit
f6f2610098
  1. 2
      CMakeLists.txt
  2. 2
      src/config.cpp
  3. 1
      src/config.hpp
  4. 6
      src/tooltips.cpp

2
CMakeLists.txt

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(juci)
set(JUCI_VERSION "1.7.2")
set(JUCI_VERSION "1.7.2.1")
set(CPACK_PACKAGE_NAME "jucipp")
set(CPACK_PACKAGE_CONTACT "Ole Christian Eidheim <eidheim@gmail.com>")

2
src/config.cpp

@ -153,6 +153,7 @@ void Config::read(const JSON &cfg) {
source.enable_multiple_cursors = source_json.boolean("enable_multiple_cursors", JSON::ParseOptions::accept_string);
source.auto_reload_changed_files = source_json.boolean("auto_reload_changed_files", JSON::ParseOptions::accept_string);
source.search_for_selection = source_json.boolean("search_for_selection", JSON::ParseOptions::accept_string);
source.tooltip_top_offset = source_json.integer("tooltip_top_offset", JSON::ParseOptions::accept_string);
source.clang_format_style = source_json.string("clang_format_style");
source.clang_usages_threads = static_cast<unsigned>(source_json.integer("clang_usages_threads", JSON::ParseOptions::accept_string));
source.clang_tidy_enable = source_json.boolean("clang_tidy_enable", JSON::ParseOptions::accept_string);
@ -289,6 +290,7 @@ std::string Config::default_config() {
"enable_multiple_cursors": false,
"auto_reload_changed_files": true,
"search_for_selection": true,
"tooltip_top_offset": 0,
"clang_format_style_comment": "IndentWidth, AccessModifierOffset and UseTab are set automatically. See http://clang.llvm.org/docs/ClangFormatStyleOptions.html",
"clang_format_style": "ColumnLimit: 0, NamespaceIndentation: All",
"clang_tidy_enable_comment": "Enable clang-tidy in new C/C++ buffers",

1
src/config.hpp

@ -95,6 +95,7 @@ public:
bool enable_multiple_cursors;
bool auto_reload_changed_files;
bool search_for_selection;
int tooltip_top_offset;
std::string clang_format_style;
unsigned clang_usages_threads;

6
src/tooltips.cpp

@ -266,9 +266,9 @@ void Tooltip::show(bool disregard_drawn, const std::function<void()> &on_motion)
view->get_window(Gtk::TextWindowType::TEXT_WINDOW_TEXT)->get_root_coords(window_x, window_y, root_x, root_y);
root_x -= 3; // -1xpadding
if(root_y < size.second)
if(root_y < size.second + Config::get().source.tooltip_top_offset)
root_x += visible_rect.get_width() * 0.1; // Adjust tooltip right if it might be above cursor
rectangle.set_y(std::max(0, root_y - size.second)); // Move tooptip down if it is above screen
rectangle.set_y(std::max(Config::get().source.tooltip_top_offset, root_y - size.second)); // Move tooptip down if it is above screen
// Move tooltip left if it is right of screen
auto screen_width = Gdk::Screen::get_default()->get_width();
@ -282,7 +282,7 @@ void Tooltip::show(bool disregard_drawn, const std::function<void()> &on_motion)
if(Tooltips::drawn_tooltips_rectangle.get_width() != 0) {
if(rectangle.intersects(Tooltips::drawn_tooltips_rectangle)) { // Put tooltip above other tooltips
int new_y = Tooltips::drawn_tooltips_rectangle.get_y() - size.second;
if(new_y >= 0)
if(new_y >= Config::get().source.tooltip_top_offset)
rectangle.set_y(new_y);
else { // Put tooltip to the right if the tooltip would be placed above the screen
int new_x = Tooltips::drawn_tooltips_rectangle.get_x() + Tooltips::drawn_tooltips_rectangle.get_width() + 2;

Loading…
Cancel
Save