Skip to content

Commit

Permalink
Updates to UiSidebar, UiInspector, UiFeatureList
Browse files Browse the repository at this point in the history
(closes #1532)

A bunch going in here, but this is mostly an attempt to keep the sidebar more
organized, so that multiple renders don't cause the content to be appended
extra times, and so that only one thing is shown in the sidebar at a time.

- Rewrite of UiFeatureList to a class component
- Move hover handling code from PixiRenderer to UiSidebar
- Allow Mapillary Detections to be hovered  (this is new)
- Allow OSM Features to be hovered (this worked before but has been broken for a while)
  • Loading branch information
bhousel committed Sep 13, 2024
1 parent 2c88f5c commit 386d624
Show file tree
Hide file tree
Showing 12 changed files with 738 additions and 568 deletions.
2 changes: 1 addition & 1 deletion css/80_app.css
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ a.hide-toggle {
position: relative;
}

.feature-list-pane {
.feature-list-wrap {
display: flex;
flex: 1 0 0px;
flex-flow: column nowrap;
Expand Down
5 changes: 2 additions & 3 deletions data/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,7 @@ en:
unknown: Unknown
incomplete: <not downloaded>
feature_list: Search features
edit: Edit feature
edit_features: Edit features
multiselect: Multiple Selection
check:
"yes": "Yes"
"no": "No"
Expand Down Expand Up @@ -814,6 +813,7 @@ en:
osm:
tooltip: Map data from OpenStreetMap
title: OpenStreetMap Data
feature: OpenStreetMap Feature
key: O
notes:
tooltip: Note data from OpenStreetMap
Expand Down Expand Up @@ -1105,7 +1105,6 @@ en:
live: live
lose_changes: "You have unsaved changes. Switching the map server will discard them. Are you sure you want to switch servers?"
dev: dev
rapid_multiselect: Multiple Selection
rapid_splash:
welcome: Introducing AI-assisted mapping!
text: "Select the {rapidicon} option to start the Rapid walkthrough. If you're new to OSM and haven't mapped before, select the first {walkthrough} option. Finally, click the last {edit} option if you want to get straight to mapping. You can always access the walkthrough later from the help menu."
Expand Down
5 changes: 2 additions & 3 deletions data/l10n/core.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -923,8 +923,7 @@
"unknown": "Unknown",
"incomplete": "<not downloaded>",
"feature_list": "Search features",
"edit": "Edit feature",
"edit_features": "Edit features",
"multiselect": "Multiple Selection",
"check": {
"yes": "Yes",
"no": "No",
Expand Down Expand Up @@ -1033,6 +1032,7 @@
"osm": {
"tooltip": "Map data from OpenStreetMap",
"title": "OpenStreetMap Data",
"feature": "OpenStreetMap Feature",
"key": "O"
},
"notes": {
Expand Down Expand Up @@ -1401,7 +1401,6 @@
"lose_changes": "You have unsaved changes. Switching the map server will discard them. Are you sure you want to switch servers?",
"dev": "dev"
},
"rapid_multiselect": "Multiple Selection",
"rapid_splash": {
"welcome": "Introducing AI-assisted mapping!",
"text": "Select the {rapidicon} option to start the Rapid walkthrough. If you're new to OSM and haven't mapped before, select the first {walkthrough} option. Finally, click the last {edit} option if you want to get straight to mapping. You can always access the walkthrough later from the help menu.",
Expand Down
2 changes: 1 addition & 1 deletion modules/behaviors/SelectBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const FAR_TOLERANCE = 12;
* Properties available:
* `enabled` `true` if the event handlers are enabled, `false` if not.
* `lastDown` `eventData` Object for the most recent down event
* `lastUp` `eventData` Object for the most recent up event (to detect dbl clicks)
* `lastUp` `eventData` Object for the most recent up event (to detect dbl clicks)
* `lastMove` `eventData` Object for the most recent move event
* `lastSpace` `eventData` Object for the most recent move event used to trigger a spacebar click
* `lastClick` `eventData` Object for the most recent click event
Expand Down
3 changes: 1 addition & 2 deletions modules/modes/SelectOsmMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ export class SelectOsmMode extends AbstractMode {
editor.on('merge', this._merge);
hover.on('hoverchange', this._hover);

ui.sidebar
.select(entityIDs, this._newFeature);
ui.sidebar.showInspector(entityIDs, this._newFeature);

return true;
}
Expand Down
36 changes: 0 additions & 36 deletions modules/pixi/PixiRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export class PixiRenderer extends EventEmitter {

// Make sure callbacks have `this` bound correctly
this._tick = this._tick.bind(this);
this._onHoverChange = this._onHoverChange.bind(this);

// Disable mipmapping, we always want textures near the resolution they are at.
PIXI.BaseTexture.defaultOptions.mipmap = PIXI.MIPMAP_MODES.OFF;
Expand Down Expand Up @@ -163,41 +162,6 @@ export class PixiRenderer extends EventEmitter {
_sharedTextures = new PixiTextures(context);
}
this.textures = _sharedTextures;

// Event listeners to respond to any changes in selection or hover
context.behaviors.hover.on('hoverchange', this._onHoverChange);
}


/**
* _onHoverChange
* Respond to any change in hover
*/
_onHoverChange(eventData) {
const context = this.context;
const scene = this.scene;
const ui = context.systems.ui;

const target = eventData.target;
const layer = target?.layer;
const dataID = target?.dataID;

const hoverData = target?.data;
const modeID = context.mode?.id;
if (modeID !== 'select' && modeID !== 'select-osm') {
ui.sidebar.hover(hoverData ? [hoverData] : []);
}

scene.clearClass('hover');
if (layer && dataID) {
// Only set hover class if this target isn't currently drawing
const drawingIDs = layer.getDataWithClass('drawing');
if (!drawingIDs.has(dataID)) {
layer.setClass('hover', dataID);
}
}

this.render();
}


Expand Down
Loading

0 comments on commit 386d624

Please sign in to comment.