22
22
23
23
#include " ../util/cpplibostree.hpp"
24
24
25
- #include " OSTreeTUI .hpp"
25
+ #include " ostreetui .hpp"
26
26
27
27
namespace CommitRender {
28
28
@@ -76,8 +76,8 @@ Element DefaultRenderState(const WindowRenderState& state,
76
76
class CommitComponentImpl : public ComponentBase , public WindowOptions {
77
77
public:
78
78
explicit CommitComponentImpl (size_t position, std::string commit, OSTreeTUI& ostreetui)
79
- : drag_initial_x (1 ),
80
- drag_initial_y (static_cast <int >(position) * COMMIT_WINDOW_HEIGHT),
79
+ : defaultX (1 ),
80
+ defaultY (static_cast <int >(position) * COMMIT_WINDOW_HEIGHT),
81
81
commitPosition(position),
82
82
hash(std::move(commit)),
83
83
ostreetui(ostreetui),
@@ -96,20 +96,20 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions {
96
96
Add (inner);
97
97
98
98
title = hash.substr (0 , 8 );
99
- top = drag_initial_y ;
100
- left = drag_initial_x ;
99
+ top = defaultY ;
100
+ left = defaultX ;
101
101
width = COMMIT_WINDOW_WIDTH;
102
102
height = COMMIT_WINDOW_HEIGHT;
103
103
}
104
104
105
105
private:
106
106
void resetWindow (bool positionReset = true ) {
107
107
if (positionReset) {
108
- left () = drag_initial_x ;
109
- top () = drag_initial_y ;
108
+ left () = defaultX ;
109
+ top () = defaultY ;
110
110
}
111
- width () = width_initial ;
112
- height () = height_initial ;
111
+ width () = defaultWidth ;
112
+ height () = defaultHeight ;
113
113
// reset window contents
114
114
DetachAllChildren ();
115
115
Add (simpleCommit);
@@ -202,7 +202,7 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions {
202
202
}
203
203
204
204
// Position and record the drawn area of the window.
205
- element |= reflect (box_window_ );
205
+ element |= reflect (boxWindow_ );
206
206
element |= PositionAndSize (left (), top () + ostreetui.GetScrollOffset (), width (), height ());
207
207
element |= reflect (box_);
208
208
@@ -253,22 +253,22 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions {
253
253
return true ;
254
254
}
255
255
256
- mouse_hover_ = box_window_ .Contain (event.mouse ().x , event.mouse ().y );
256
+ mouseHover_ = boxWindow_ .Contain (event.mouse ().x , event.mouse ().y );
257
257
258
- if (mouse_hover_ && event.mouse ().button == Mouse::Left) {
258
+ if (mouseHover_ && event.mouse ().button == Mouse::Left) {
259
259
ostreetui.SetSelectedCommit (commitPosition);
260
260
}
261
261
262
- if (captured_mouse_ ) {
262
+ if (capturedMouse_ ) {
263
263
if (event.mouse ().motion == Mouse::Released) {
264
264
// reset mouse
265
- captured_mouse_ = nullptr ;
265
+ capturedMouse_ = nullptr ;
266
266
// drop commit
267
267
if (event.mouse ().y > ostreetui.GetScreen ().dimy () - 8 ) {
268
268
ostreetui.SetViewMode (ViewMode::COMMIT_DROP, hash);
269
269
ostreetui.SetModeBranch (
270
270
ostreetui.GetOstreeRepo ().GetCommitList ().at (hash).branch );
271
- top () = drag_initial_y ;
271
+ top () = defaultY ;
272
272
}
273
273
// check if position matches branch & do something if it does
274
274
else if (ostreetui.GetModeBranch ().empty ()) {
@@ -281,8 +281,8 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions {
281
281
}
282
282
283
283
if (drag_) {
284
- left () = event.mouse ().x - drag_start_x - box_.x_min ;
285
- top () = event.mouse ().y - drag_start_y - box_.y_min ;
284
+ left () = event.mouse ().x - dragStartX - box_.x_min ;
285
+ top () = event.mouse ().y - dragStartY - box_.y_min ;
286
286
ostreetui.SetViewMode (ViewMode::COMMIT_DRAGGING, hash);
287
287
// check if potential commit deletion
288
288
if (event.mouse ().y > ostreetui.GetScreen ().dimy () - 8 ) {
@@ -318,7 +318,7 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions {
318
318
return true ;
319
319
}
320
320
321
- if (!mouse_hover_ ) {
321
+ if (!mouseHover_ ) {
322
322
return false ;
323
323
}
324
324
@@ -335,38 +335,37 @@ class CommitComponentImpl : public ComponentBase, public WindowOptions {
335
335
336
336
TakeFocus ();
337
337
338
- captured_mouse_ = CaptureMouse (event);
339
- if (!captured_mouse_ ) {
338
+ capturedMouse_ = CaptureMouse (event);
339
+ if (!capturedMouse_ ) {
340
340
return true ;
341
341
}
342
342
343
- drag_start_x = event.mouse ().x - left () - box_.x_min ;
344
- drag_start_y = event.mouse ().y - top () - box_.y_min ;
343
+ dragStartX = event.mouse ().x - left () - box_.x_min ;
344
+ dragStartY = event.mouse ().y - top () - box_.y_min ;
345
345
346
- const bool drag_old = drag_;
346
+ const bool dragOld = drag_;
347
347
drag_ = true ;
348
- if (!drag_old && drag_) { // if we start dragging
349
- drag_initial_x = left ();
350
- drag_initial_y = top ();
348
+ if (!dragOld && drag_) { // if we start dragging
349
+ defaultX = left ();
350
+ defaultY = top ();
351
351
}
352
352
return true ;
353
353
}
354
354
355
355
// window specific members
356
356
Box box_;
357
- Box box_window_ ;
357
+ Box boxWindow_ ;
358
358
359
- CapturedMouse captured_mouse_;
360
- int drag_start_x = 0 ;
361
- int drag_start_y = 0 ;
362
-
363
- int drag_initial_x;
364
- int drag_initial_y;
365
- int width_initial = COMMIT_WINDOW_WIDTH;
366
- int height_initial = COMMIT_WINDOW_HEIGHT;
367
-
368
- bool mouse_hover_ = false ;
359
+ bool mouseHover_ = false ;
369
360
bool drag_ = false ;
361
+ CapturedMouse capturedMouse_;
362
+ int dragStartX = 0 ;
363
+ int dragStartY = 0 ;
364
+
365
+ int defaultX;
366
+ int defaultY;
367
+ int defaultWidth = COMMIT_WINDOW_WIDTH;
368
+ int defaultHeight = COMMIT_WINDOW_HEIGHT;
370
369
371
370
// ostree-tui specific members
372
371
size_t commitPosition;
@@ -447,7 +446,7 @@ ftxui::Component CommitComponent(size_t position, const std::string& commit, OST
447
446
return ftxui::Make<CommitComponentImpl>(position, commit, ostreetui);
448
447
}
449
448
450
- ftxui::Element commitRender (OSTreeTUI& ostreetui,
449
+ ftxui::Element CommitRender (OSTreeTUI& ostreetui,
451
450
const std::unordered_map<std::string, ftxui::Color>& branchColorMap) {
452
451
using namespace ftxui ;
453
452
0 commit comments