Skip to content

Commit

Permalink
code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
jafl committed Jan 5, 2024
1 parent 0e3a20b commit ef9dd4e
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 58 deletions.
1 change: 0 additions & 1 deletion libjcore/Make.files
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@
.cpp ./code/JBroadcastSnooper
.cpp ./code/JMDIServer
.cpp ./code/JUpdateChecker
.cpp ./code/jMouseUtil
.cpp ./code/JStopWatch
.cpp ./code/jSysUtil_UNIX
.cpp ./code/jTime
Expand Down
1 change: 1 addition & 0 deletions libjcore/code/JCoreLibVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ static const char* kCurrentJCoreLibVersionStr = "4.1.0";
// jMath:
// *** Removed kJPi & kJE in favor of std::numbers.
// Removed unused constant kJLog10ToLog2.
// Removed JLAbs() in favor of labs().
// JString:
// Switched to an exponential reallocation model.
// *** Adjusted ctor to use NormalizeData enum instead of bool.
Expand Down
9 changes: 0 additions & 9 deletions libjcore/code/jMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ JLCeil
return JRound( ceil(x) );
}

inline long
JLAbs
(
const long x
)
{
return (x >= 0 ? x : -x);
}

inline long
JTruncate
(
Expand Down
30 changes: 0 additions & 30 deletions libjcore/code/jMouseUtil.cpp

This file was deleted.

20 changes: 18 additions & 2 deletions libjcore/code/jMouseUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,23 @@

#include "JPoint.h"

bool JMouseMoved(const JPoint& pt1, const JPoint& pt2,
const JCoordinate debounceWidth = 3);
/******************************************************************************
JMouseMoved
Returns true if the points are further apart than the debounce width.
******************************************************************************/

inline bool
JMouseMoved
(
const JPoint& pt1,
const JPoint& pt2,
const JCoordinate debounceWidth = 3
)
{
return (labs(pt2.x - pt1.x) > debounceWidth ||
labs(pt2.y - pt1.y) > debounceWidth);
}

#endif
4 changes: 0 additions & 4 deletions libjcore/libjcore.jcc
Original file line number Diff line number Diff line change
Expand Up @@ -733,10 +733,6 @@ T
F
"./code/JUpdateChecker.cpp"
T
2 "jMouseUtil.cpp"
F
"./code/jMouseUtil.cpp"
T
2 "JStopWatch.cpp"
F
"./code/JStopWatch.cpp"
Expand Down
6 changes: 0 additions & 6 deletions libjcore/test/code/test_jMath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,3 @@ JTEST(Truncate)
JAssertEqual(4, JTruncate(4.3));
JAssertEqual(4, JTruncate(4.9));
}

JTEST(Abs)
{
JAssertEqual(5, JLAbs(5));
JAssertEqual(5, JLAbs(-5));
}
4 changes: 2 additions & 2 deletions libjx/code/JXMenuTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,8 @@ JXMenuTable::MenuSelectItem

if (submenu != nullptr &&
(!checkMovement ||
(JLAbs(itsCurrPt.x - itsPrevPt.x) <= kMoveSlowDelta &&
JLAbs(itsCurrPt.y - itsPrevPt.y) <= kMoveSlowDelta)))
(labs(itsCurrPt.x - itsPrevPt.x) <= kMoveSlowDelta &&
labs(itsCurrPt.y - itsPrevPt.y) <= kMoveSlowDelta)))
{
if (itsOpenSubmenu != nullptr)
{
Expand Down
4 changes: 2 additions & 2 deletions libjx/code/JXWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1384,8 +1384,8 @@ JXWindow::AnalyzeWindowManager
WaitForWM(d, w);
assert( w->itsIsMappedFlag );

if (JLAbs(w->itsWMFrameLoc.x - p) > kWMFrameSlop ||
JLAbs(w->itsWMFrameLoc.y - p) > kWMFrameSlop)
if (labs(w->itsWMFrameLoc.x - p) > kWMFrameSlop ||
labs(w->itsWMFrameLoc.y - p) > kWMFrameSlop)
{
behavior.frameCompensateFlag = !behavior.frameCompensateFlag;
d->SetWMBehavior(behavior);
Expand Down
4 changes: 2 additions & 2 deletions tools/jx_layout_editor/code/LayoutContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ LayoutContainer::EnclosingBoundsResized
const JCoordinate dhb
)
{
if ((JLAbs(dwb) >= itsGridSpacing || JLAbs(dhb) >= itsGridSpacing) &&
if ((labs(dwb) >= JCoordinate(itsGridSpacing) || labs(dhb) >= JCoordinate(itsGridSpacing)) &&
!itsIgnoreResizeFlag && !CurrentUndoIs(LayoutUndo::kWindowResizeType))
{
auto* newUndo = jnew LayoutUndo(itsDoc, LayoutUndo::kWindowResizeType);
Expand All @@ -436,7 +436,7 @@ LayoutContainer::BoundsResized
)
{
JXWidget::BoundsResized(dw,dh);
if (JLAbs(dw) >= itsGridSpacing || JLAbs(dh) >= itsGridSpacing)
if (labs(dw) >= JCoordinate(itsGridSpacing) || labs(dh) >= JCoordinate(itsGridSpacing))
{
itsDoc->DataModified();
}
Expand Down

0 comments on commit ef9dd4e

Please sign in to comment.