Skip to content

Commit

Permalink
remove resize attributes from commit windows
Browse files Browse the repository at this point in the history
  • Loading branch information
forgottosave committed Oct 28, 2024
1 parent 0baa3e2 commit 4f6ff30
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 69 deletions.
4 changes: 0 additions & 4 deletions src/core/OSTreeTUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,6 @@ int OSTreeTUI::main(const std::string& repo, const std::vector<std::string>& sta
.top = i * 4,
.width = 30,
.height = 4,
.resize_left = false,
.resize_right = false,
.resize_top = false,
.resize_down = false,
})
);
i++;
Expand Down
68 changes: 3 additions & 65 deletions src/core/commitComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,7 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions {
element,
title(),
Active(),
drag_,
resize_left_ || resize_right_ || resize_down_ || resize_top_,
(resize_left_hover_ || resize_left_) && captureable,
(resize_right_hover_ || resize_right_) && captureable,
(resize_top_hover_ || resize_top_) && captureable,
(resize_down_hover_ || resize_down_) && captureable,
drag_
};

element = render ? render(state) : DefaultRenderState(state);
Expand Down Expand Up @@ -156,23 +151,8 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions {

mouse_hover_ = box_window_.Contain(event.mouse().x, event.mouse().y);

resize_down_hover_ = false;
resize_top_hover_ = false;
resize_left_hover_ = false;
resize_right_hover_ = false;

if (mouse_hover_) {
resize_left_hover_ = event.mouse().x == left() + box_.x_min;
resize_right_hover_ =
event.mouse().x == left() + width() - 1 + box_.x_min;
resize_top_hover_ = event.mouse().y == top() + box_.y_min;
resize_down_hover_ = event.mouse().y == top() + height() - 1 + box_.y_min;

// Apply the component options:
resize_top_hover_ &= resize_top();
resize_left_hover_ &= resize_left();
resize_down_hover_ &= resize_down();
resize_right_hover_ &= resize_right();
// TODO indicate window is draggable?
}

if (captured_mouse_) {
Expand All @@ -195,24 +175,6 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions {
return true;
}

if (resize_left_) {
width() = left() + width() - event.mouse().x + box_.x_min;
left() = event.mouse().x - box_.x_min;
}

if (resize_right_) {
width() = event.mouse().x - resize_start_x - box_.x_min;
}

if (resize_top_) {
height() = top() + height() - event.mouse().y + box_.y_min;
top() = event.mouse().y - box_.y_min;
}

if (resize_down_) {
height() = event.mouse().y - resize_start_y - box_.y_min;
}

if (drag_) {
left() = event.mouse().x - drag_start_x - box_.x_min;
top() = event.mouse().y - drag_start_y - box_.y_min;
Expand Down Expand Up @@ -246,11 +208,6 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions {
return true;
}

resize_left_ = false;
resize_right_ = false;
resize_top_ = false;
resize_down_ = false;

if (!mouse_hover_) {
return false;
}
Expand All @@ -273,19 +230,11 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions {
return true;
}

resize_left_ = resize_left_hover_;
resize_right_ = resize_right_hover_;
resize_top_ = resize_top_hover_;
resize_down_ = resize_down_hover_;

resize_start_x = event.mouse().x - width() - box_.x_min;
resize_start_y = event.mouse().y - height() - box_.y_min;
drag_start_x = event.mouse().x - left() - box_.x_min;
drag_start_y = event.mouse().y - top() - box_.y_min;

// Drag only if we are not resizeing a border yet:
bool drag_old = drag_;
drag_ = !resize_right_ && !resize_down_ && !resize_top_ && !resize_left_;
drag_ = true;
if (!drag_old && drag_) { // if we start dragging
drag_initial_x = left();
drag_initial_y = top();
Expand All @@ -300,8 +249,6 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions {
CapturedMouse captured_mouse_;
int drag_start_x = 0;
int drag_start_y = 0;
int resize_start_x = 0;
int resize_start_y = 0;

int drag_initial_x = 0;
int drag_initial_y = 0;
Expand All @@ -310,15 +257,6 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions {

bool mouse_hover_ = false;
bool drag_ = false;
bool resize_top_ = false;
bool resize_left_ = false;
bool resize_down_ = false;
bool resize_right_ = false;

bool resize_top_hover_ = false;
bool resize_left_hover_ = false;
bool resize_down_hover_ = false;
bool resize_right_hover_ = false;

int& scroll_offset;

Expand Down

0 comments on commit 4f6ff30

Please sign in to comment.