Skip to content

Commit

Permalink
Refactor Ruler class to centralize common functionality and enforce s…
Browse files Browse the repository at this point in the history
…ubclass implementation

- Converted ruler file into typescript
- created base class and subclass for Horizontal and vertical ruler
- Moved the `_updatePaintTimer` method to the base `Ruler` class to avoid duplication across `HRuler` and `VRuler`.
- Added `_updateBreakPoints` as an abstract-like method in the base class, throwing an error to enforce implementation in subclasses.
- Streamlined the initialization logic in `Ruler.initializeRuler` for better readability and modularity.

Signed-off-by: Darshan-upadhyay1110 <[email protected]>
Change-Id: I8f0187588ffab533e135023285acb3dcada832d4
  • Loading branch information
Darshan-upadhyay1110 committed Jan 10, 2025
1 parent 86203fc commit 0a8e884
Show file tree
Hide file tree
Showing 7 changed files with 1,259 additions and 950 deletions.
7 changes: 5 additions & 2 deletions browser/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,10 @@ COOL_JS_LST =\
src/control/Parts.js \
src/control/Scroll.js \
src/control/Styles.js \
src/control/Ruler.js \
src/control/Ruler.ts \
src/control/VRuler.ts \
src/control/HRuler.ts \
src/control/Ruler.ts \
src/slideshow/SlideCache.ts \
src/slideshow/SlideCompositor.ts \
src/slideshow/LayerRenderer.ts \
Expand Down Expand Up @@ -988,10 +990,11 @@ pot:
src/control/Control.Zotero.js \
src/control/Parts.js \
src/control/Permission.js \
src/control/Ruler.js \
src/control/Ruler.ts \
src/control/Signing.js \
src/control/Toolbar.js \
src/control/VRuler.ts \
src/control/Ruler.ts \
src/control/jsdialog/Definitions.Menu.ts \
src/control/jsdialog/Util.SnackbarController.ts \
src/control/jsdialog/Widget.ColorPicker.ts \
Expand Down
3 changes: 2 additions & 1 deletion browser/css/leaflet.css
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,8 @@ input.clipboard {
align-items: center;
}

.cool-ruler-tabstopcontainer {
.cool-ruler-tabstopcontainer,
.cool-ruler-horizontal-tabstopcontainer {
height: 100%;
position: absolute;
}
Expand Down
10 changes: 5 additions & 5 deletions browser/src/control/Control.UIManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,11 @@ L.Control.UIManager = L.Control.extend({
if ((window.mode.isTablet() || window.mode.isDesktop()) && !app.isReadOnly()) {
var showRuler = this.getBooleanDocTypePref('ShowRuler');
var interactiveRuler = this.map.isEditMode();
var isRTL = document.documentElement.dir === 'rtl';
L.control.ruler({position: (isRTL ? 'topright' : 'topleft'), interactive:interactiveRuler, showruler: showRuler}).addTo(this.map);
if (!this.map.isPresentationOrDrawing())
L.control.vruler(this.map, {position: (isRTL ? 'topright' : 'topleft'), interactive:interactiveRuler, showruler: showRuler});
this.map.fire('rulerchanged');
// Call the static method from the Ruler class
app.definitions.ruler.initializeRuler(this.map, {
interactive: interactiveRuler,
showruler: showRuler
});
}
},

Expand Down
Loading

0 comments on commit 0a8e884

Please sign in to comment.