summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
Diffstat (limited to 'servers')
-rw-r--r--servers/visual/visual_server_raster.cpp12
-rw-r--r--servers/visual/visual_server_raster.h4
-rw-r--r--servers/visual/visual_server_wrap_mt.h2
-rw-r--r--servers/visual_server.h2
4 files changed, 14 insertions, 6 deletions
diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp
index 532247d94c..5614d5e044 100644
--- a/servers/visual/visual_server_raster.cpp
+++ b/servers/visual/visual_server_raster.cpp
@@ -4448,12 +4448,13 @@ void VisualServerRaster::cursor_set_rotation(float p_rotation, int p_cursor) {
cursors[p_cursor].rot = p_rotation;
};
-void VisualServerRaster::cursor_set_texture(RID p_texture, const Point2 &p_center_offset, int p_cursor) {
+void VisualServerRaster::cursor_set_texture(RID p_texture, const Point2 &p_center_offset, int p_cursor, const Rect2 &p_region) {
VS_CHANGED;
ERR_FAIL_INDEX(p_cursor, MAX_CURSORS);
cursors[p_cursor].texture = p_texture;
cursors[p_cursor].center = p_center_offset;
+ cursors[p_cursor].region = p_region;
};
void VisualServerRaster::cursor_set_visible(bool p_visible, int p_cursor) {
@@ -7538,8 +7539,13 @@ void VisualServerRaster::_draw_cursors_and_margins() {
RID tex = cursors[i].texture?cursors[i].texture:default_cursor_texture;
ERR_CONTINUE( !tex );
- Point2 size(texture_get_width(tex), texture_get_height(tex));
- rasterizer->canvas_draw_rect(Rect2(cursors[i].pos, size), 0, Rect2(), tex, Color(1, 1, 1, 1));
+ if (cursors[i].region.has_no_area()) {
+ Point2 size(texture_get_width(tex), texture_get_height(tex));
+ rasterizer->canvas_draw_rect(Rect2(cursors[i].pos, size), 0, Rect2(), tex, Color(1, 1, 1, 1));
+ } else {
+ Point2 size = cursors[i].region.size;
+ rasterizer->canvas_draw_rect(Rect2(cursors[i].pos, size), Rasterizer::CANVAS_RECT_REGION, cursors[i].region, tex, Color(1, 1, 1, 1));
+ }
};
diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h
index 0480d9f5cb..228a4a7c44 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/visual/visual_server_raster.h
@@ -544,10 +544,12 @@ class VisualServerRaster : public VisualServer {
RID texture;
Point2 center;
bool visible;
+ Rect2 region;
Cursor() {
rot = 0;
visible = false;
+ region = Rect2();
};
};
@@ -1240,7 +1242,7 @@ public:
/* CURSOR */
virtual void cursor_set_rotation(float p_rotation, int p_cursor = 0); // radians
- virtual void cursor_set_texture(RID p_texture, const Point2 &p_center_offset, int p_cursor=0);
+ virtual void cursor_set_texture(RID p_texture, const Point2 &p_center_offset, int p_cursor=0, const Rect2 &p_region=Rect2());
virtual void cursor_set_visible(bool p_visible, int p_cursor = 0);
virtual void cursor_set_pos(const Point2& p_pos, int p_cursor = 0);
diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h
index a97b232c03..8c39b0bea1 100644
--- a/servers/visual/visual_server_wrap_mt.h
+++ b/servers/visual/visual_server_wrap_mt.h
@@ -680,7 +680,7 @@ public:
/* CURSOR */
FUNC2(cursor_set_rotation,float , int ); // radians
- FUNC3(cursor_set_texture,RID , const Point2 &, int );
+ FUNC4(cursor_set_texture,RID , const Point2 &, int, const Rect2 &);
FUNC2(cursor_set_visible,bool , int );
FUNC2(cursor_set_pos,const Point2& , int );
diff --git a/servers/visual_server.h b/servers/visual_server.h
index f330a6faee..64318dfd72 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -1110,7 +1110,7 @@ public:
/* CURSOR */
virtual void cursor_set_rotation(float p_rotation, int p_cursor = 0)=0; // radians
- virtual void cursor_set_texture(RID p_texture, const Point2 &p_center_offset = Point2(0, 0), int p_cursor=0)=0;
+ virtual void cursor_set_texture(RID p_texture, const Point2 &p_center_offset = Point2(0, 0), int p_cursor=0, const Rect2 &p_region=Rect2())=0;
virtual void cursor_set_visible(bool p_visible, int p_cursor = 0)=0;
virtual void cursor_set_pos(const Point2& p_pos, int p_cursor = 0)=0;