bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h | 11 ++- kit/ChildSession.cpp | 3 kit/KitHelper.hpp | 2 loleaflet/dist/images/drop-down-button.svg | 4 + loleaflet/dist/spreadsheet.css | 10 ++ loleaflet/src/layer/marker/Icon.js | 15 ++-- loleaflet/src/layer/tile/TileLayer.js | 66 +++++++++++++++++++ tools/KitClient.cpp | 1 8 files changed, 105 insertions(+), 7 deletions(-)
New commits: commit 89f37b5dd52882674c4e5f2339d365cfe338543d Author: Marco Cecchetti <marco.cecche...@collabora.com> Date: Mon Mar 19 14:08:10 2018 +0100 calc: drop down button marker Change-Id: Ic069ad40e6749f43709760e7f4f0d96b39d5a4ce Reviewed-on: https://gerrit.libreoffice.org/51598 Reviewed-by: Marco Cecchetti <mrcek...@gmail.com> Tested-by: Marco Cecchetti <mrcek...@gmail.com> diff --git a/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h b/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h index 020bbff90..300d91e1c 100644 --- a/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -570,6 +570,15 @@ typedef enum LOK_CALLBACK_WINDOW = 36, /** + * When for the current cell is defined a validity list we need to show + * a drop down button in the form of a marker. + * + * The payload format is: "x, y, visible" where x, y are the current + * cell cursor coordinates and visible is set to 0 or 1. + */ + LOK_CALLBACK_VALIDITY_LIST_BUTTON = 37, + + /** * Notification that the clipboard contents have changed. * Typically fired in response to copying to clipboard. * @@ -578,7 +587,7 @@ typedef enum * in the future the contents might be included for * convenience. */ - LOK_CALLBACK_CLIPBOARD_CHANGED = 37, + LOK_CALLBACK_CLIPBOARD_CHANGED = 38, } LibreOfficeKitCallbackType; diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp index 710c079b5..04ec7d93f 100644 --- a/kit/ChildSession.cpp +++ b/kit/ChildSession.cpp @@ -1548,6 +1548,9 @@ void ChildSession::loKitCallback(const int type, const std::string& payload) case LOK_CALLBACK_WINDOW: sendTextFrame("window: " + payload); break; + case LOK_CALLBACK_VALIDITY_LIST_BUTTON: + sendTextFrame("validitylistbutton: " + payload); + break; default: LOG_ERR("Unknown callback event (" << type << "): " << payload); } diff --git a/kit/KitHelper.hpp b/kit/KitHelper.hpp index 6dd1a0f41..bc4e2350e 100644 --- a/kit/KitHelper.hpp +++ b/kit/KitHelper.hpp @@ -117,6 +117,8 @@ namespace LOKitHelper return "CELL_ADDRESS"; case LOK_CALLBACK_WINDOW: return "WINDOW"; + case LOK_CALLBACK_VALIDITY_LIST_BUTTON: + return "VALIDITY_LIST_BUTTON"; } return std::to_string(type); diff --git a/loleaflet/dist/images/drop-down-button.svg b/loleaflet/dist/images/drop-down-button.svg new file mode 100644 index 000000000..f17c44443 --- /dev/null +++ b/loleaflet/dist/images/drop-down-button.svg @@ -0,0 +1,4 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="11px" height="11px"> + <path style="fill:#2d2d2d" d="m 2.5011982,3.0013922 5.9508648,0 -2.8796134,5.9972113 z" /> + <path style="fill:#2d2d2d;fill-rule:evenodd;" d="M 0,0 11,0 11,11 0,11 Z m 1,1 9,0 0,9 -9,0 z"/> +</svg> diff --git a/loleaflet/dist/spreadsheet.css b/loleaflet/dist/spreadsheet.css index ed5086321..01f0b0bd2 100644 --- a/loleaflet/dist/spreadsheet.css +++ b/loleaflet/dist/spreadsheet.css @@ -190,3 +190,13 @@ .spreadsheet-header-row-resize { cursor: row-resize; } + +.spreadsheet-drop-down-marker { + margin-left: 0px; + margin-top: 0px; + width: 18px; + height: 17px; + background-image: url('../images/drop-down-button.svg'); + background-size: 100% 100%; + background-repeat: no-repeat; + } diff --git a/loleaflet/src/layer/marker/Icon.js b/loleaflet/src/layer/marker/Icon.js index 58d5fd3c1..856995b23 100644 --- a/loleaflet/src/layer/marker/Icon.js +++ b/loleaflet/src/layer/marker/Icon.js @@ -47,10 +47,10 @@ L.Icon = L.Class.extend({ }, _setIconStyles: function (img, name) { - var options = this.options, - size = L.point(options[name + 'Size']), - anchor = L.point(name === 'shadow' && options.shadowAnchor || options.iconAnchor || - size && size.divideBy(2, true)); + var options = this.options; + var size = L.point(options[name + 'Size']); + var anchor = L.point(name === 'shadow' && options.shadowAnchor || options.iconAnchor || + size && size.x !== undefined && size.y !== undefined && size.divideBy(2, true)); img.className = 'leaflet-marker-' + name + ' ' + (options.className || ''); @@ -60,9 +60,12 @@ L.Icon = L.Class.extend({ } if (size) { - img.style.width = size.x + 'px'; - img.style.height = size.y + 'px'; + if (size.x !== undefined) + img.style.width = size.x + 'px'; + if (size.y !== undefined) + img.style.height = size.y + 'px'; } + }, _createImg: function (src, el) { diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 59ce81d2c..cc8fe0071 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -145,6 +145,14 @@ L.TileLayer = L.GridLayer.extend({ }); }, this)); + this._dropDownButton = L.marker(new L.LatLng(0, 0), { + icon: L.divIcon({ + className: 'spreadsheet-drop-down-marker', + iconSize: null + }), + interactive: false + }); + this._emptyTilesCount = 0; this._msgQueue = []; this._toolbarCommandValues = {}; @@ -488,6 +496,9 @@ L.TileLayer = L.GridLayer.extend({ else if (textMsg.startsWith('editor:')) { this._updateEditor(textMsg); } + else if (textMsg.startsWith('validitylistbutton:')) { + this._onValidityListButtonMsg(textMsg); + } }, toggleTileDebugMode: function() { @@ -1828,6 +1839,7 @@ L.TileLayer = L.GridLayer.extend({ if (this._cellCursorMarker) { this._map.removeLayer(this._cellCursorMarker); + this._map.removeLayer(this._dropDownButton); } this._cellCursorMarker = L.rectangle(this._cellCursor, { pointerEvents: 'none', @@ -1839,10 +1851,64 @@ L.TileLayer = L.GridLayer.extend({ return; } this._map.addLayer(this._cellCursorMarker); + + this._addDropDownMarker(); } else if (this._cellCursorMarker) { this._map.removeLayer(this._cellCursorMarker); } + this._removeDropDownMarker(); + }, + + _onValidityListButtonMsg: function(textMsg) { + var strXY = textMsg.match(/\d+/g); + var validatedCell = new L.Point(parseInt(strXY[0]), parseInt(strXY[1])); + var show = parseInt(strXY[2]) === 1; + if (show) { + if (this._validatedCellXY && !this._validatedCellXY.equals(validatedCell)) { + this._validatedCellXY = null; + this._removeDropDownMarker(); + } + this._validatedCellXY = validatedCell; + this._addDropDownMarker(); + } + else if (this._validatedCellXY && this._validatedCellXY.equals(validatedCell)) { + this._validatedCellXY = null; + this._removeDropDownMarker(); + } + }, + + _addDropDownMarker: function () { + if (this._validatedCellXY && this._cellCursorXY && this._validatedCellXY.equals(this._cellCursorXY)) { + var pos = this._cellCursor.getNorthEast(); + var cellCursorHeightPx = this._twipsToPixels(this._cellCursorTwips.getSize()).y; + var dropDownMarker = this._getDropDownMarker(cellCursorHeightPx); + dropDownMarker.setLatLng(pos); + this._map.addLayer(dropDownMarker); + } + }, + + _removeDropDownMarker: function () { + if (!this._validatedCellXY && this._dropDownButton) + this._map.removeLayer(this._dropDownButton); + }, + + _getDropDownMarker: function (height) { + if (height) { + var maxHeight = 27; // it matches the max height of the same control in core + var topMargin = 0; + if (height > maxHeight) { + topMargin = height - maxHeight; + height = maxHeight; + } + var icon = L.divIcon({ + className: 'spreadsheet-drop-down-marker', + iconSize: [undefined, height], + iconAnchor: [0, -topMargin] + }); + this._dropDownButton.setIcon(icon); + } + return this._dropDownButton; }, // Update text selection handlers. diff --git a/tools/KitClient.cpp b/tools/KitClient.cpp index c2261223b..bc756b1d7 100644 --- a/tools/KitClient.cpp +++ b/tools/KitClient.cpp @@ -80,6 +80,7 @@ extern "C" CASE(CELL_ADDRESS); CASE(RULER_UPDATE); CASE(WINDOW); + CASE(VALIDITY_LIST_BUTTON); CASE(CLIPBOARD_CHANGED); #undef CASE } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits