Skip to content

Commit

Permalink
Allow out of tree platforms to customize cursor values (#44841)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #44841

Out of tree platforms like react-native-macos and react-native-windows may wish to support different cursor types than are currently supported in mobile React Native (currently only "auto" and "pointer").

Since the Cursor is applied on the BaseViewProps across all platforms, we need an extension point where a platform can inject it's own header for defining a cursor. This header will also have to include it's own implementation of `fromRawValue` to parse the cursor value from RawProps into the host platform implementation of Cursor.

## Changelog

[Internal]

Differential Revision: D58301970
  • Loading branch information
rozele authored and facebook-github-bot committed Jun 11, 2024
1 parent 3c3c687 commit ae61129
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -765,14 +765,150 @@ inline void fromRawValue(
return;
}
auto stringValue = (std::string)value;
if (stringValue == "alias") {
result = Cursor::Alias;
return;
}
if (stringValue == "all-scroll") {
result = Cursor::AllScroll;
return;
}
if (stringValue == "auto") {
result = Cursor::Auto;
return;
}
if (stringValue == "cell") {
result = Cursor::Cell;
return;
}
if (stringValue == "col-resize") {
result = Cursor::ColResize;
return;
}
if (stringValue == "context-menu") {
result = Cursor::ContextMenu;
return;
}
if (stringValue == "copy") {
result = Cursor::Copy;
return;
}
if (stringValue == "crosshair") {
result = Cursor::Crosshair;
return;
}
if (stringValue == "default") {
result = Cursor::Default;
return;
}
if (stringValue == "e-resize") {
result = Cursor::EResize;
return;
}
if (stringValue == "ew-resize") {
result = Cursor::EWResize;
return;
}
if (stringValue == "grab") {
result = Cursor::Grab;
return;
}
if (stringValue == "grabbing") {
result = Cursor::Grabbing;
return;
}
if (stringValue == "help") {
result = Cursor::Help;
return;
}
if (stringValue == "move") {
result = Cursor::Move;
return;
}
if (stringValue == "n-resize") {
result = Cursor::NResize;
return;
}
if (stringValue == "ne-resize") {
result = Cursor::NEResize;
return;
}
if (stringValue == "nesw-resize") {
result = Cursor::NESWResize;
return;
}
if (stringValue == "ns-resize") {
result = Cursor::NSResize;
return;
}
if (stringValue == "nw-resize") {
result = Cursor::NWResize;
return;
}
if (stringValue == "nwse-resize") {
result = Cursor::NWSEResize;
return;
}
if (stringValue == "no-drop") {
result = Cursor::NoDrop;
return;
}
if (stringValue == "none") {
result = Cursor::None;
return;
}
if (stringValue == "not-allowed") {
result = Cursor::NotAllowed;
return;
}
if (stringValue == "pointer") {
result = Cursor::Pointer;
return;
}
if (stringValue == "progress") {
result = Cursor::Progress;
return;
}
if (stringValue == "row-resize") {
result = Cursor::RowResize;
return;
}
if (stringValue == "s-resize") {
result = Cursor::SResize;
return;
}
if (stringValue == "se-resize") {
result = Cursor::SEResize;
return;
}
if (stringValue == "sw-resize") {
result = Cursor::SWResize;
return;
}
if (stringValue == "text") {
result = Cursor::Text;
return;
}
if (stringValue == "url") {
result = Cursor::Url;
return;
}
if (stringValue == "w-resize") {
result = Cursor::WResize;
return;
}
if (stringValue == "wait") {
result = Cursor::Wait;
return;
}
if (stringValue == "zoom-in") {
result = Cursor::ZoomIn;
return;
}
if (stringValue == "zoom-out") {
result = Cursor::ZoomOut;
return;
}
LOG(ERROR) << "Could not parse Cursor:" << stringValue;
react_native_expect(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,44 @@ enum class BorderCurve : uint8_t { Circular, Continuous };

enum class BorderStyle : uint8_t { Solid, Dotted, Dashed };

enum class Cursor : uint8_t { Auto, Pointer };
enum class Cursor : uint8_t {
Auto,
Alias,
AllScroll,
Cell,
ColResize,
ContextMenu,
Copy,
Crosshair,
Default,
EResize,
EWResize,
Grab,
Grabbing,
Help,
Move,
NEResize,
NESWResize,
NResize,
NSResize,
NWResize,
NWSEResize,
NoDrop,
None,
NotAllowed,
Pointer,
Progress,
RowResize,
SResize,
SEResize,
SWResize,
Text,
Url,
WResize,
Wait,
ZoomIn,
ZoomOut,
};

enum class LayoutConformance : uint8_t { Undefined, Classic, Strict };

Expand Down

0 comments on commit ae61129

Please sign in to comment.