Conversation
- src/interface/range_popup.h - Header for the range popup dialog API
- src/interface/range_popup.c - Modal popup implementation with:
- Editable Minimum/Maximum text fields (using Xaw asciiTextWidgetClass)
- "Symmetric about Zero" button - sets range to [-max(|min|,|max|), max(|min|,|max|)]
- "Reset to Global Values" button - restores the variable's full data range
- OK / Cancel buttons
- Modal event loop (like ncview's XtGrabExclusive approach)
Modified files:
- src/interface/x_interface.c - Added "Range" button in colorbar_form (same line as the colorbar, appearing to its right), initialized the popup during x_init, wired up the callback
- src/interface/x_interface.h - Added x_set_range_button_callback() and x_range_popup_show() declarations
- src/ushow.c - Added on_range_button() callback that opens the popup with the current variable's user_min/user_max and global_min/global_max, and updates the display on OK
- Makefile - Added range_popup.c to USHOW_SRCS and its dependency rule
How it works:
1. User clicks the "Range" button (positioned after the colorbar)
2. A modal popup appears with the current min/max values pre-filled in editable text fields
3. User can type new values, click "Symmetric about Zero", or click "Reset to Global Values"
4. On "OK", the variable's display range is updated and the image redraws
5. On "Cancel", nothing changes
Here's a summary of everything that was added:
Tests (tests/test_range_popup.c - 24 tests):
- 12 range_compute_symmetric tests: positive range, negative range, spanning zero, min larger abs, already symmetric, both zero, min zero, equal magnitude, small values, large values,
result always symmetric, covers original range
- 11 range_parse_value tests: integer, float, negative, scientific notation, negative scientific, zero, whitespace, empty string, invalid string, NULL string, NULL value pointer
- 1 constants test: verifying RANGE_POPUP_OK/CANCEL values
Architecture refactoring for testability:
- Created src/interface/range_utils.h / range_utils.c - pure logic functions with no X11 dependency
- range_popup.c now includes and uses range_utils.h instead of inlining the logic
- Tests link only against range_utils.c (no X11 required)
Documentation (README.md):
- Added Range button, Min-/Min+/Max-/Max+ buttons to the Interface section with descriptions of the popup dialog features
- Added test_range_popup to the test suite list
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Modified files:
How it works:
Here's a summary of everything that was added: