-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
101 changed files
with
2,375 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
com.io7m.jsycamore.api/src/main/java/com/io7m/jsycamore/api/components/SyScrollBarDrag.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright © 2023 Mark Raynsford <[email protected]> https://www.io7m.com | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
|
||
package com.io7m.jsycamore.api.components; | ||
|
||
import java.util.Objects; | ||
|
||
import static java.lang.StrictMath.clamp; | ||
|
||
/** | ||
* A drag operation being performed on a scrollbar. | ||
* | ||
* @param dragKind The kind of operation | ||
* @param dragStart The scroll position at the start of the operation | ||
* @param dragNow The scroll position now | ||
*/ | ||
|
||
public record SyScrollBarDrag( | ||
Kind dragKind, | ||
double dragStart, | ||
double dragNow) | ||
{ | ||
/** | ||
* The kind of drag operation. | ||
*/ | ||
|
||
public enum Kind | ||
{ | ||
/** | ||
* Dragging just started. | ||
*/ | ||
|
||
DRAG_STARTED, | ||
|
||
/** | ||
* Dragging is being continued. | ||
*/ | ||
|
||
DRAG_CONTINUED, | ||
|
||
/** | ||
* Dragging just ended. | ||
*/ | ||
|
||
DRAG_ENDED | ||
} | ||
|
||
/** | ||
* A drag operation being performed on a scrollbar. | ||
* | ||
* @param dragKind The kind of operation | ||
* @param dragStart The scroll position at the start of the operation | ||
* @param dragNow The scroll position now | ||
*/ | ||
|
||
public SyScrollBarDrag | ||
{ | ||
Objects.requireNonNull(dragKind, "dragKind"); | ||
|
||
dragStart = clamp(dragStart, 0.0, 1.0); | ||
dragNow = clamp(dragNow, 0.0, 1.0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
...camore.api/src/main/java/com/io7m/jsycamore/api/components/SyScrollBarHorizontalType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* Copyright © 2021 Mark Raynsford <[email protected]> https://www.io7m.com | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
package com.io7m.jsycamore.api.components; | ||
|
||
import java.util.function.Consumer; | ||
|
||
/** | ||
* Write access to scrollbars. | ||
*/ | ||
|
||
public interface SyScrollBarHorizontalType | ||
extends SyScrollBarHorizontalReadableType, SyScrollBarType | ||
{ | ||
/** | ||
* Set a listener that will be executed when the left scroll button is clicked. | ||
* | ||
* @param runnable The listener | ||
*/ | ||
|
||
void setOnClickLeftListener(Runnable runnable); | ||
|
||
/** | ||
* Remove any listeners that are executed when the left button is clicked. | ||
* | ||
* @see #setOnClickLeftListener(Runnable) | ||
*/ | ||
|
||
void removeOnClickLeftListener(); | ||
|
||
/** | ||
* Set a listener that will be executed when the right scroll button is clicked. | ||
* | ||
* @param runnable The listener | ||
*/ | ||
|
||
void setOnClickRightListener(Runnable runnable); | ||
|
||
/** | ||
* Remove any listeners that are executed when the right button is clicked. | ||
* | ||
* @see #setOnClickRightListener(Runnable) | ||
*/ | ||
|
||
void removeOnClickRightListener(); | ||
|
||
/** | ||
* Set a listener that will be executed when the left scroll button is clicked. | ||
* | ||
* @param listener The listener | ||
*/ | ||
|
||
void setOnThumbDragListener(Consumer<SyScrollBarDrag> listener); | ||
|
||
/** | ||
* Remove any listeners that are executed when the left button is clicked. | ||
* | ||
* @see #setOnThumbDragListener(Consumer) | ||
*/ | ||
|
||
void removeOnThumbDragListener(); | ||
|
||
/** | ||
* Set the scroll position in the range {@code [0, 1]}. | ||
* | ||
* @param position The position | ||
*/ | ||
|
||
void setScrollPosition(double position); | ||
|
||
/** | ||
* Set the scroll position snapping value in the range {@code [0, 1]}. The | ||
* given fraction is used to determine how many divisions will be used within | ||
* the scrolling space. For example, a value of {@code 1.0 / 4.0} will yield | ||
* four possible snapped position values. | ||
* | ||
* @param fraction The fraction | ||
*/ | ||
|
||
void setScrollPositionSnapping(double fraction); | ||
|
||
/** | ||
* Scrollbars are typically used to scroll a visible portion of some larger | ||
* structure. Some implementations might want to scale the scrollbar thumb | ||
* based on the portion of the visible space that is visible. A value of | ||
* {@code 0.0} means that an infinitely small piece of the larger structure | ||
* is visible. A value of {@code 1.0} means that the entirety of the larger | ||
* structure is visible. | ||
* | ||
* @param amount The amount shown | ||
*/ | ||
|
||
void setScrollAmountShown(double amount); | ||
} |
50 changes: 50 additions & 0 deletions
50
...sycamore.api/src/main/java/com/io7m/jsycamore/api/components/SyScrollBarReadableType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright © 2021 Mark Raynsford <[email protected]> https://www.io7m.com | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
package com.io7m.jsycamore.api.components; | ||
|
||
/** | ||
* Read-only access to scrollbars. | ||
*/ | ||
|
||
public interface SyScrollBarReadableType | ||
extends SyComponentReadableType | ||
{ | ||
/** | ||
* @return The scrollbar thumb | ||
*/ | ||
|
||
SyComponentReadableType thumb(); | ||
|
||
/** | ||
* | ||
* @return The scrollbar track | ||
*/ | ||
|
||
SyComponentReadableType track(); | ||
|
||
/** | ||
* @return The scroll position in the range {@code [0, 1]} | ||
*/ | ||
|
||
double scrollPosition(); | ||
|
||
/** | ||
* @return The scroll position snapping value in the range {@code [0, 1]} | ||
*/ | ||
|
||
double scrollPositionSnapping(); | ||
} |
Oops, something went wrong.