Skip to content

Commit

Permalink
WindowServer+LibGfx: Added Crosshair cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
umasankar-yedida authored and awesomekling committed Oct 30, 2020
1 parent ddad757 commit 9ccae7a
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions Base/etc/WindowServer/WindowServer.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Hand=/res/cursors/hand.png
Help=/res/cursors/help.png
Drag=/res/cursors/drag.png
Wait=/res/cursors/wait.png
Crosshair=/res/cursors/crosshair.png

[Input]
DoubleClickSpeed=250
Expand Down
Binary file added Base/res/cursors/crosshair.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions Demos/WidgetGallery/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,10 @@ int main(int argc, char** argv)
radio_cursor_arrow.on_checked = [&](bool) {
window->set_cursor(Gfx::StandardCursor::Arrow);
};
auto& radio_crosshair_arrow = cursor_group_box.add<GUI::RadioButton>("Crosshair");
radio_crosshair_arrow.on_checked = [&](bool) {
window->set_cursor(Gfx::StandardCursor::Crosshair);
};
auto& radio_cursor_i_beam = cursor_group_box.add<GUI::RadioButton>("IBeam");
radio_cursor_i_beam.on_checked = [&](bool) {
window->set_cursor(Gfx::StandardCursor::IBeam);
Expand Down
1 change: 1 addition & 0 deletions Libraries/LibGfx/StandardCursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace Gfx {
enum class StandardCursor {
None = 0,
Arrow,
Crosshair,
IBeam,
ResizeHorizontal,
ResizeVertical,
Expand Down
2 changes: 2 additions & 0 deletions Services/WindowServer/Cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ RefPtr<Cursor> Cursor::create(Gfx::StandardCursor standard_cursor)
return nullptr;
case Gfx::StandardCursor::Arrow:
return WindowManager::the().arrow_cursor();
case Gfx::StandardCursor::Crosshair:
return WindowManager::the().crosshair_cursor();
case Gfx::StandardCursor::IBeam:
return WindowManager::the().i_beam_cursor();
case Gfx::StandardCursor::ResizeHorizontal:
Expand Down
1 change: 1 addition & 0 deletions Services/WindowServer/WindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ void WindowManager::reload_config(bool set_screen)
m_move_cursor = get_cursor("Move");
m_drag_cursor = get_cursor("Drag");
m_wait_cursor = get_cursor("Wait");
m_crosshair_cursor = get_cursor("Crosshair");
}

const Gfx::Font& WindowManager::font() const
Expand Down
2 changes: 2 additions & 0 deletions Services/WindowServer/WindowManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class WindowManager : public Core::Object {

const Cursor& active_cursor() const;
const Cursor& arrow_cursor() const { return *m_arrow_cursor; }
const Cursor& crosshair_cursor() const { return *m_crosshair_cursor; }
const Cursor& hand_cursor() const { return *m_hand_cursor; }
const Cursor& help_cursor() const { return *m_help_cursor; }
const Cursor& resize_horizontally_cursor() const { return *m_resize_horizontally_cursor; }
Expand Down Expand Up @@ -260,6 +261,7 @@ class WindowManager : public Core::Object {
RefPtr<Cursor> m_move_cursor;
RefPtr<Cursor> m_drag_cursor;
RefPtr<Cursor> m_wait_cursor;
RefPtr<Cursor> m_crosshair_cursor;

InlineLinkedList<Window> m_windows_in_order;

Expand Down

0 comments on commit 9ccae7a

Please sign in to comment.