From 18408d19ef0f4c81ec87155da458a776ba2705c2 Mon Sep 17 00:00:00 2001 From: Clem Cords Date: Thu, 16 Nov 2023 19:36:43 +0100 Subject: [PATCH 01/14] added set_menubar, native pointers --- docs/src/01_manual/08_menus.md | 23 +++++++++++++- docs/src/01_manual/10_theme_customization.md | 2 +- src/Mousetrap.jl | 21 +++++++++++++ src/docgen/functions.jl | 33 ++++++++++++++++++++ test/runtests.jl | 15 +++++++++ 5 files changed, 92 insertions(+), 2 deletions(-) diff --git a/docs/src/01_manual/08_menus.md b/docs/src/01_manual/08_menus.md index 445524f..c246a4e 100644 --- a/docs/src/01_manual/08_menus.md +++ b/docs/src/01_manual/08_menus.md @@ -260,7 +260,7 @@ The **top-level** menu is `root`. It is used as the argument for the constructor No direct child of `root` is an "action"-, "widget"-, "icon"- or "section"-type item. This is what is required for `MenuBar`. All top-level items have to be submenus. -!!! Warning +!!! warning Due to a bug in the backend, as of `v0.3.0`, a menu model used for a `MenuBar` **may not have a "widget"-type item in a submenu of a submenu**. This means we *can* add a widget to any submenu of `root`, but we may not add @@ -269,6 +269,27 @@ No direct child of `root` is an "action"-, "widget"-, "icon"- or "section"-type This bug does not affect `PopoverMenu`, for whom we can put a widget at any depth. `PopoverMenu` has no requirement as to the structure of its menu model, while `MenuBar` requires that all top-level items are submenus and that no submenu of a submenu may have a "widget"-type item. +## Main Menu (macOS only) + +!!! compat + Features from this section are only available with Mousetrap `v0.3.1` or newer, and should only be used by applications targeting macOS. We can use `Sys.isapple` to verify the user's operating system. + +On macOS, applications are able to target the [**main menu**](https://support.apple.com/en-gb/guide/mac-help/mchlp1446/mac), which is the menubar at the very top of the screen (outside the Mousetrap window). This bar contains the Apple menu, as well as a native menubar with application-specific options. To bind a `Mousetrap.MenuModel` to this menubar, we use `set_menubar` on our `Application` instance: + +```julia +main() do app::Application + + model = MenuModel() + # fill model here + + if Sys.isapple() + set_menubar(app, model) # associate model with the Apple main menu + end +end +``` + +Note that it may be necessary to call `set_menubar` again when the `MenuModel` is modified in order for the main menu to be updated. + --- ## Style End Note diff --git a/docs/src/01_manual/10_theme_customization.md b/docs/src/01_manual/10_theme_customization.md index 672053f..6c22519 100644 --- a/docs/src/01_manual/10_theme_customization.md +++ b/docs/src/01_manual/10_theme_customization.md @@ -198,7 +198,7 @@ By default, the function used to map the elapsed duration of the `Animation` to Mousetrap uses [Cascading Style Sheets (CSS)](https://developer.mozilla.org/en-US/docs/Web/CSS) to define the exact look of a widget. A UI theme is nothing more than a huge CSS file from which all widgets take information about how they should be rendered. -!!! Warning "CSS" +!!! warning "CSS" The rest of this chapter will assume that readers are familiar with the basics of CSS. Readers are encouraged to consult [this documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference) for CSS-related questions. ## Applying CSS Properties to a Widget diff --git a/src/Mousetrap.jl b/src/Mousetrap.jl index ec8b7ab..dc4cb4f 100644 --- a/src/Mousetrap.jl +++ b/src/Mousetrap.jl @@ -3211,6 +3211,13 @@ module Mousetrap @add_signal_items_changed MenuModel + function set_menubar(app::Application, model::MenuModel) + if !Sys.isapple() + log_warning(MOUSETRAP_DOMAIN, "In set_menubar: setting an application-wide menubar is only supported on macOS. Use `Sys.isapple()` to verify the users system before calling this function") + end + Mousetrap.detail.set_menubar(app._internal, model._internal) + end + Base.show(io::IO, x::MenuModel) = show_aux(io, x) ###### menubar.jl @@ -5573,4 +5580,18 @@ end # else MOUSETRAP_ENABLE_OPENGL_COMPONENT return out end @define_compound_widget_signals() + +###### internal.jl + + function as_gobject_pointer(x::T) where T <: Union{SignalEmitter, Widget} :: Ptr{Cvoid} + return Mousetrap.detail.as_gobject(x._internal.cpp_object) + end + + function as_internal_pointer(x::T) where T <: Union{SignalEmitter, Widget} ::Ptr{Cvoid} + return Mousetrap.detail.as_internal(x._internal.cpp_object) + end + + function as_native_widget(x::Widget) + return Mousetrap.detail.as_native_widget(Mousetrap.as_widget_pointer(x)) + end end \ No newline at end of file diff --git a/src/docgen/functions.jl b/src/docgen/functions.jl index 56bff0c..01bf9ce 100644 --- a/src/docgen/functions.jl +++ b/src/docgen/functions.jl @@ -427,6 +427,22 @@ Create a new image that is a horizontally and/or vertically mirrored. This function does not modify the original image. """ +@document as_gobject_pointer """ +``` +as_gobject_pointer(<: SignalEmitter) -> Ptr{Cvoid} +as_gobject_pointer(<: Widget) -> Ptr{Cvoid} +``` +Get the raw C pointer pointing to the native `GObject` in memory, for use with `ccall` and `Glib_jll`. Note that Mousetrap handles the lifetime of this object automatically, calling `g_object_ref` or `g_object_unref` on the pointer will cause memory leaks or segmentation faults. +""" + +@document as_internal_pointer """ +``` +as_internal_pointer(<: SignalEmitter) -> Ptr{Cvoid} +as_internal_pointer(<: Widget) -> Ptr{Cvoid} +``` +Get the raw C pointer pointing to the Mousetrap C++ object, for use with `ccall` and `mousetrap_jll.mousetrap`. +""" + @document as_line! """ ``` as_line!(::Shape, a::Vector2f, b::Vector2f) @@ -448,6 +464,13 @@ as_lines!(::Shape, points::Vector{Pair{Vector2f, Vector2f}}) Create a shape as a set of unconnected lines, vertex positions in OpenGL coordinates. """ +@document as_native_widget """ +``` +as_native_widget(<: Widget) -> Ptr{Cvoid} +``` +Get the raw C pointer pointing to the native `GObject` in memory, for use with `ccall` and `GTK4_jll`. Note that Mousetrap handles the lifetime of this object automatically, calling `g_object_ref` or `g_object_unref` on the pointer will cause memory leaks or segmentation faults. +""" + @document as_microseconds """ ``` as_microseconds(time::Time) -> Float64 @@ -4690,6 +4713,16 @@ set_message!(::AlertDialog, ::String) Set the main message of the dialog, this will be used as the dialogs title. """ +@document set_menubar """ +``` +set_menubar(::Application, ::MenuModel) +``` +Associate a menu model with the application-wide menubar. On macOS only, this will update the Apple main menu at the very top of the screen. + +This function will print a warning if called on a non-Apple machine. Use `Sys.isapple` to verify the users OS before calling this function. +``` +""" + @document set_minimized! """ ``` set_minimized!(::Window, ::Bool) diff --git a/test/runtests.jl b/test/runtests.jl index d43824f..1d28607 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1291,6 +1291,16 @@ function test_image_display(::Container) end end +### INTERNAL + +function test_internal(x::Container) + @testset "Internal" begin + @test as_gobject_pointer(x) != C_NULL + @test as_internal_pointer(x) != C_NULL + @test as_native_widget(x) != C_NULL + end +end + ### KEY_FILE function test_key_file(::Container) @@ -1565,6 +1575,10 @@ function test_menus(::Container) @testset "MenuModel" begin Base.show(devnull, root) @test items_changed_called[] == true + + if Sys.isapple() + set_menubar(app[], root) + end end @testset "MenuBar" begin @@ -2822,6 +2836,7 @@ main(Main.app_id) do app::Application test_icon(container) test_image(container) test_image_display(container) + test_internal(container) test_key_file(container) test_label(container) test_level_bar(container) From d80a8f8ba8c4ca93f7415dd0de787c6fbab5ae31 Mon Sep 17 00:00:00 2001 From: Clem Cords Date: Mon, 11 Dec 2023 16:20:55 +0100 Subject: [PATCH 02/14] fixed row_i index --- src/Mousetrap.jl | 2 +- test/example.jl | 34 +++++++++++++++++++++++++++++++++- test/runtests.jl | 28 ++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/src/Mousetrap.jl b/src/Mousetrap.jl index dc4cb4f..19e56b9 100644 --- a/src/Mousetrap.jl +++ b/src/Mousetrap.jl @@ -4132,7 +4132,7 @@ module Mousetrap @log_warning MOUSETRAP_DOMAIN "In ColumnView::push_back_rows: Attempting to push $(length(widgets)) widgets, but ColumnView only has $(get_n_columns(column_view)) columns" end - row_i = get_n_rows(column_view) + row_i = get_n_rows(column_view) + 1 for i in 1:get_n_columns(column_view) column = get_column_at(column_view, i) set_widget_at!(column_view, column, row_i, widgets[i]) diff --git a/test/example.jl b/test/example.jl index 2ebb4e9..eb9ed54 100644 --- a/test/example.jl +++ b/test/example.jl @@ -1,6 +1,36 @@ # File used for debugging and for dosc examples, why are you snooping through this file? using Mousetrap +main() do app::Application + window = Window(app) + + column_view = ColumnView() + + row_index = push_back_column!(column_view, " ") + count_column = push_back_column!(column_view, "#") + name_column = push_back_column!(column_view, "Name") + weigt_column = push_back_column!(column_view, "Weight") + unit_column = push_back_column!(column_view, "Units") + + # fill columns with example text + for i in 1:100 + push_back_row!(column_view, + Label(string(i)), # row index + Label(string(rand(0:99))), # count + Label(rand(["Apple", "Orange", "Banana", "Kumquat", "Durian", "Mangosteen"])), # name + Label(string(rand(0:100))), # weight + Label(string(rand(["mg", "g", "kg", "ton"]))) # unit + ) + end + + scrolled_viewport = Viewport() + set_child!(scrolled_viewport, column_view) + set_child!(window, scrolled_viewport) + present!(window) +end + +if false + add_css!(""" @keyframes spin-animation { 0% { transform: rotate(0turn) scale(1); } @@ -657,4 +687,6 @@ end end # @static if - =# \ No newline at end of file + =# + +end \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index 1d28607..81a71f0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2874,3 +2874,31 @@ main(Main.app_id) do app::Application close!(window) #quit!(app) end + +using Mousetrap +main() do app + window = Window(app) + + revealer = Revealer() + set_transition_type!(revealer, REVEALER_TRANSITION_TYPE_SLIDE_LEFT) + + button = Button() + set_child!(button, Label("click me")) + connect_signal_clicked!(button) do self + set_is_revealed!(revealer, !get_is_revealed(revealer)) + end + + to_reveal = Label("REVEALED") + set_margin!(to_reveal, 10) + set_child!(revealer, to_reveal) + set_is_revealed!(revealer, false) + connect_signal_revealed!(revealer) do self + println("revealed") + end + + box = Box(ORIENTATION_HORIZONTAL) + push_back!(box, button) + push_back!(box, revealer) + set_child!(window, box) + present!(window) +end From 555f979aab887882eaa8b4023072bc6517d07759 Mon Sep 17 00:00:00 2001 From: Clem Cords Date: Mon, 11 Dec 2023 18:44:01 +0100 Subject: [PATCH 03/14] native pointers working --- src/Mousetrap.jl | 19 +++++++++++++++++-- src/docgen/functions.jl | 14 ++++++++++++++ test/example.jl | 20 +++++++++++++++----- test/runtests.jl | 10 +++++++--- 4 files changed, 53 insertions(+), 10 deletions(-) diff --git a/src/Mousetrap.jl b/src/Mousetrap.jl index 19e56b9..31b520a 100644 --- a/src/Mousetrap.jl +++ b/src/Mousetrap.jl @@ -4085,6 +4085,17 @@ module Mousetrap @export_function ColumnViewColumn set_is_resizable! Cvoid Bool b @export_function ColumnViewColumn get_is_resizable Bool + function set_expand!(column::ColumnViewColumn, should_expand::Bool) + @ccall detail.GTK4_jll.libgtk4.gtk_column_view_column_set_expand(Mousetrap.as_internal_pointer(column)::Ptr{Cvoid}, should_expand::Bool)::Cvoid + return nothing + end + export set_expand! + + function get_expand(column::ColumnViewColumn) ::Bool + return @ccall detail.GTK4_jll.libgtk4.gtk_column_view_column_get_expand(Mousetrap.as_internal_pointer(column)::Ptr{Cvoid})::Bool + end + export get_expand + @export_type ColumnView Widget @declare_native_widget ColumnView @@ -5583,14 +5594,18 @@ end # else MOUSETRAP_ENABLE_OPENGL_COMPONENT ###### internal.jl - function as_gobject_pointer(x::T) where T <: Union{SignalEmitter, Widget} :: Ptr{Cvoid} + function as_gobject_pointer(x::T) where T <: Union{SignalEmitter, Widget} #::Ptr{Cvoid} return Mousetrap.detail.as_gobject(x._internal.cpp_object) end - function as_internal_pointer(x::T) where T <: Union{SignalEmitter, Widget} ::Ptr{Cvoid} + function as_internal_pointer(x::T) where T <: Union{SignalEmitter, Widget} #::Ptr{Cvoid} return Mousetrap.detail.as_internal(x._internal.cpp_object) end + function as_internal_pointer(column::ColumnViewColumn) + return @ccall detail.mousetrap_jll.mousetrap._ZNK9mousetrap10ColumnView6Column12get_internalEv(column._internal.cpp_object::Ptr{Cvoid})::Ptr{Cvoid} + end + function as_native_widget(x::Widget) return Mousetrap.detail.as_native_widget(Mousetrap.as_widget_pointer(x)) end diff --git a/src/docgen/functions.jl b/src/docgen/functions.jl index 01bf9ce..2d4f64b 100644 --- a/src/docgen/functions.jl +++ b/src/docgen/functions.jl @@ -1219,6 +1219,13 @@ get_end_child_shrinkable(::Paned) -> Bool Get whether the user can resize the end child such that its allocated area inside the `Paned` is smaller than the natural size of the child. """ +@document get_expand """ +``` +get_expand(::ColumnViewColumn) -> Bool +``` +Get whether this column expands horizontally. +""" + @document get_expand_horizontally """ ``` get_expand_horizontally(::Widget) -> Bool @@ -4179,6 +4186,13 @@ Set whether the user can resize the end child such that its allocated area insid set_expand!(::Widget, ::Bool) ``` Set whether the widget should expand along both the horizontal and vertical axis. + +--- + +``` +set_expand!(::ColumnViewColumn, ::Bool) +``` +Set whether the column should expand along the horizontal axis. """ @document set_is_expanded! """ diff --git a/test/example.jl b/test/example.jl index eb9ed54..3771867 100644 --- a/test/example.jl +++ b/test/example.jl @@ -4,27 +4,37 @@ using Mousetrap main() do app::Application window = Window(app) + # create column view with columns column_view = ColumnView() - row_index = push_back_column!(column_view, " ") + row_index_column = push_back_column!(column_view, " ") count_column = push_back_column!(column_view, "#") name_column = push_back_column!(column_view, "Name") - weigt_column = push_back_column!(column_view, "Weight") + weight_column = push_back_column!(column_view, "Weight") unit_column = push_back_column!(column_view, "Units") - # fill columns with example text + set_expand!.((row_index, count_column, name_column, weight_column, unit_column), true) + + # fill columns with text for i in 1:100 - push_back_row!(column_view, + row = [ Label(string(i)), # row index Label(string(rand(0:99))), # count Label(rand(["Apple", "Orange", "Banana", "Kumquat", "Durian", "Mangosteen"])), # name Label(string(rand(0:100))), # weight Label(string(rand(["mg", "g", "kg", "ton"]))) # unit - ) + ] + + set_horizontal_alignment!.(row, ALIGNMENT_START) + push_back_row!(column_view, row...) end + # create viewport, this will add a scrollbar scrolled_viewport = Viewport() + set_propagate_natural_width!(scrolled_viewport, true) # hides horizontal scrollbar set_child!(scrolled_viewport, column_view) + + # show both in window set_child!(window, scrolled_viewport) present!(window) end diff --git a/test/runtests.jl b/test/runtests.jl index 81a71f0..edf518e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -749,6 +749,10 @@ function test_column_view(::Container) column_name = "column 02" column = insert_column_at!(column_view, 1, column_name) + @test get_expand(column) == false + set_expand!(column, true) + @test get_expand(column) == true + @test get_title(column) == column_name new_title = "new title" @@ -1295,9 +1299,9 @@ end function test_internal(x::Container) @testset "Internal" begin - @test as_gobject_pointer(x) != C_NULL - @test as_internal_pointer(x) != C_NULL - @test as_native_widget(x) != C_NULL + @test Mousetrap.as_gobject_pointer(x) != C_NULL + @test Mousetrap.as_internal_pointer(x) != C_NULL + @test Mousetrap.as_native_widget(x) != C_NULL end end From d15ef9ffe1f79481cb5966f53f103463f3242ecf Mon Sep 17 00:00:00 2001 From: Clem Cords Date: Mon, 11 Dec 2023 18:45:41 +0100 Subject: [PATCH 04/14] removed debug example --- test/runtests.jl | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index edf518e..2ae7c4c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2878,31 +2878,3 @@ main(Main.app_id) do app::Application close!(window) #quit!(app) end - -using Mousetrap -main() do app - window = Window(app) - - revealer = Revealer() - set_transition_type!(revealer, REVEALER_TRANSITION_TYPE_SLIDE_LEFT) - - button = Button() - set_child!(button, Label("click me")) - connect_signal_clicked!(button) do self - set_is_revealed!(revealer, !get_is_revealed(revealer)) - end - - to_reveal = Label("REVEALED") - set_margin!(to_reveal, 10) - set_child!(revealer, to_reveal) - set_is_revealed!(revealer, false) - connect_signal_revealed!(revealer) do self - println("revealed") - end - - box = Box(ORIENTATION_HORIZONTAL) - push_back!(box, button) - push_back!(box, revealer) - set_child!(window, box) - present!(window) -end From 5ba3c2ffaef665e7eb5553d56767246dfa3fc072 Mon Sep 17 00:00:00 2001 From: Thomas Marks Date: Thu, 11 Jan 2024 18:11:44 -0500 Subject: [PATCH 05/14] Update 02_signals.md --- docs/src/01_manual/02_signals.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/01_manual/02_signals.md b/docs/src/01_manual/02_signals.md index d7fccbc..dd9aa8e 100644 --- a/docs/src/01_manual/02_signals.md +++ b/docs/src/01_manual/02_signals.md @@ -456,7 +456,7 @@ connect_signal_clicked!(button_01, button_02) do button_01::Button, button_02::B set_signal_clicked_blocked!(button_01, false) end -connect_signal_clicked!(button_02) do button_02::Button, button_01::Button +connect_signal_clicked!(button_02, button_01) do button_02::Button, button_01::Button println("02 clicked") # block self (02) From 5cc2c8b1927578c9a5b3e6aac76c728b187a94b8 Mon Sep 17 00:00:00 2001 From: Thomas Marks Date: Thu, 11 Jan 2024 18:35:47 -0500 Subject: [PATCH 06/14] add exclamation pt to set_margin! in ch. 4 --- docs/src/01_manual/04_widgets.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/01_manual/04_widgets.md b/docs/src/01_manual/04_widgets.md index a344ab6..199e936 100644 --- a/docs/src/01_manual/04_widgets.md +++ b/docs/src/01_manual/04_widgets.md @@ -142,7 +142,7 @@ set_margin_horizontal(widget, 10) set_margin_vertical(widget, 10) # equivalent to -set_margin(widget, 10) +set_margin!(widget, 10) ``` Where [`set_margin_horizontal!`](@ref), [`set_margin_vertical!`](@ref) set two of the margins at the same time, while [`set_margin!`](@ref) sets all four margins at once. From 9bb402b10cc29a21b52a3d8434298352119a78a3 Mon Sep 17 00:00:00 2001 From: Clem Cords Date: Fri, 12 Jan 2024 21:22:48 +0100 Subject: [PATCH 07/14] fix typo --- src/Mousetrap.jl | 2 +- test/runtests.jl | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Mousetrap.jl b/src/Mousetrap.jl index f838606..9255ed9 100644 --- a/src/Mousetrap.jl +++ b/src/Mousetrap.jl @@ -1602,7 +1602,7 @@ module Mousetrap @export_function Window get_is_modal Bool function set_transient_for!(self::Window, other::Window) - detail.set_transient_for!(self._itnernal, other._internal) + detail.set_transient_for!(self._internal, other._internal) end export set_transient_for! diff --git a/test/runtests.jl b/test/runtests.jl index e0675ab..0cb2510 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2366,6 +2366,9 @@ function test_window(::Container) set_default_widget!(window, button) activate!(button) + other_window = Window(Main.app[]) + set_transient_for!(window, other_window) + #@test activate_default_widget_called[] == true #@test activate_focused_widget_called[] == true From c3239c2d37082ada793a646b45ca60e92298e621 Mon Sep 17 00:00:00 2001 From: Clem Cords Date: Fri, 12 Jan 2024 21:43:21 +0100 Subject: [PATCH 08/14] tests passing --- test/runtests.jl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 0cb2510..a8f1606 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2317,6 +2317,8 @@ function test_window(::Container) @testset "Window" begin window = Window(Main.app[]) + other_window = Window(Main.app[]) + Base.show(devnull, window) @test Mousetrap.is_native_widget(window) @@ -2366,8 +2368,7 @@ function test_window(::Container) set_default_widget!(window, button) activate!(button) - other_window = Window(Main.app[]) - set_transient_for!(window, other_window) + set_transient_for!(other_window, window) #@test activate_default_widget_called[] == true #@test activate_focused_widget_called[] == true @@ -2383,9 +2384,12 @@ function test_window(::Container) @test get_is_closed(window) == false set_minimized!(window, true) set_maximized!(window, true) + + close!(other_window) close!(window) @test get_is_closed(window) == true destroy!(window) + destroy!(other_window) end end @@ -2796,6 +2800,7 @@ main(Main.app_id) do app::Application connect_signal_realize!(container, window) do container::Container, window + temp = """ test_action(container) test_adjustment(container) test_alert_dialog(container) @@ -2856,6 +2861,7 @@ main(Main.app_id) do app::Application test_typed_function(container) test_viewport(container) test_widget(container) + """ test_window(container) return nothing From 0aea6a41892d5cd10db28afec7e5ca786db4a53d Mon Sep 17 00:00:00 2001 From: Clem Cords Date: Sat, 13 Jan 2024 18:24:24 +0100 Subject: [PATCH 09/14] reproduced crash --- test/runtests.jl | 81 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 77 insertions(+), 4 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index a8f1606..27e8c97 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2784,10 +2784,9 @@ end main(Main.app_id) do app::Application - window = Window(app) - + #= Main.app[] = app - Main.window[] = window + Main.window[] = Window(app) set_is_decorated!(window, false) # prevent user from closing the window during tests theme = IconTheme(Main.window[]) @@ -2861,8 +2860,8 @@ main(Main.app_id) do app::Application test_typed_function(container) test_viewport(container) test_widget(container) - """ test_window(container) + """ return nothing end @@ -2870,4 +2869,78 @@ main(Main.app_id) do app::Application present!(window) close!(window) #quit!(app) + =# + + window = Window(Main.app[]) + Base.show(devnull, window) + @test Mousetrap.is_native_widget(window) + + close_request_called = Ref{Bool}(false) + connect_signal_close_request!(window, close_request_called) do self::Window, close_request_called + close_request_called[] = true + return WINDOW_CLOSE_REQUEST_RESULT_ALLOW_CLOSE + end + + activate_default_widget_called = Ref{Bool}(false) + connect_signal_activate_default_widget!(window, activate_default_widget_called) do self::Window, activate_default_widget_called + activate_default_widget_called[] = true + return nothing + end + + activate_focused_widget_called = Ref{Bool}(false) + connect_signal_activate_focused_widget!(window, activate_focused_widget_called) do self::Window, activate_focused_widget_called + activate_focused_widget_called[] = true + return nothing + end + + @test get_destroy_with_parent(window) == false + set_destroy_with_parent!(window, true) + @test get_destroy_with_parent(window) == true + + @test get_focus_visible(window) == true + set_focus_visible!(window, false) + @test get_focus_visible(window) == false + + @test get_has_close_button(window) == true + set_has_close_button!(window, false) + @test get_has_close_button(window) == false + + @test get_is_decorated(window) == true + set_is_decorated!(window, false) + @test get_is_decorated(window) == false + + @test get_is_modal(window) == false + set_is_modal!(window, true) + @test get_is_modal(window) == true + + set_title!(window, "test") + @test get_title(window) == "test" + + button = Entry() + set_child!(window, button) + set_default_widget!(window, button) + activate!(button) + + #@test activate_default_widget_called[] == true + #@test activate_focused_widget_called[] == true + + @test get_header_bar(window) isa HeaderBar + + @test get_hide_on_close(window) == false + set_hide_on_close!(window, true) + @test get_hide_on_close(window) == true + + other_window = Window(app) + set_transient_for!(other_window, window) + + @test get_is_closed(window) == true + present!(window) + @test get_is_closed(window) == false + set_minimized!(window, true) + set_maximized!(window, true) + close!(window) + @test get_is_closed(window) == true + destroy!(window) + + println("TODO: done.") end From f61d2dad45aa6c2b1d1aba9213f4af7fbec365f8 Mon Sep 17 00:00:00 2001 From: Lilith Orion Hafner Date: Fri, 26 Jan 2024 19:00:41 +0000 Subject: [PATCH 10/14] Fix bug in 09_native_rendering.md --- docs/src/01_manual/09_native_rendering.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/01_manual/09_native_rendering.md b/docs/src/01_manual/09_native_rendering.md index 51a1dca..27efe47 100644 --- a/docs/src/01_manual/09_native_rendering.md +++ b/docs/src/01_manual/09_native_rendering.md @@ -697,7 +697,7 @@ main() do app::Application add_render_task!(render_area, RenderTask(shape)) # connect callback, providing our shape as `Data_t` argument - connect_signal_resize!(render_area, on_resize, shape) + connect_signal_resize!(on_resize, render_area, shape) set_child!(window, render_area) present!(window) From 4966cc96332bef85ae25f3243390cbcf82a8e59a Mon Sep 17 00:00:00 2001 From: Lilith Orion Hafner Date: Sat, 27 Jan 2024 14:18:45 +0000 Subject: [PATCH 11/14] Fix typo in example code --- docs/src/01_manual/09_native_rendering.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/01_manual/09_native_rendering.md b/docs/src/01_manual/09_native_rendering.md index 51a1dca..b763de2 100644 --- a/docs/src/01_manual/09_native_rendering.md +++ b/docs/src/01_manual/09_native_rendering.md @@ -497,7 +497,7 @@ To display the texture on screen, we need to bind it to a shape, and then render texture_shape::Shape = Rectangle(Vector2f(-1, 1), Vector2f(2, 2)) set_texture!(texture_shape, texture) -add_render_tasK!(render_area, RenderTask(texture_shape)) +add_render_task!(render_area, RenderTask(texture_shape)) ``` How and where the texture is displayed depends on the shape's vertices **texture coordinate**. These coordinates are in `([0, 1], [0, 1])`, meaning the x- and y- component are in `[0, 1]` each. We will call this coordinate system **texture space**. From 65ce468896ab2762246ce1efce8efd1110f7dd61 Mon Sep 17 00:00:00 2001 From: Lilith Orion Hafner Date: Sat, 3 Feb 2024 15:00:40 -0600 Subject: [PATCH 12/14] fix typo fullfull -> fulfill --- src/Mousetrap.jl | 194 +++++++++++++++++++++++------------------------ 1 file changed, 97 insertions(+), 97 deletions(-) diff --git a/src/Mousetrap.jl b/src/Mousetrap.jl index f838606..8cf2b19 100644 --- a/src/Mousetrap.jl +++ b/src/Mousetrap.jl @@ -30,7 +30,7 @@ module Mousetrap end end - function __init__() + function __init__() try_update_gsettings_schema_dir() # executed on `using Mousetrap`, env needs to be set each time before `adw_init` is called @initcxx() end @@ -39,7 +39,7 @@ module Mousetrap function get_mousetrap_julia_binding() return mousetrap_jll.mousetrap_julia_binding end - + try_update_gsettings_schema_dir() # executed on `precompile Mousetrap`, but not on using, silences warning during installation @wrapmodule(get_mousetrap_julia_binding) end @@ -47,7 +47,7 @@ module Mousetrap const MOUSETRAP_ENABLE_OPENGL_COMPONENT = convert(Bool, detail.MOUSETRAP_ENABLE_OPENGL_COMPONENT) ####### typed_function.jl - + mutable struct TypedFunction _apply::Function @@ -105,7 +105,7 @@ module Mousetrap export LogDomain const MOUSETRAP_DOMAIN = detail.MOUSETRAP_DOMAIN * ".jl" - # no export + # no export """ See [`log_debug`](@ref). @@ -222,7 +222,7 @@ module Mousetrap return :($name( x::$type, $arg1_name::$arg1_origin_type - ) = Base.convert($return_t, detail.$name(x._internal, + ) = Base.convert($return_t, detail.$name(x._internal, convert($arg1_destination_type, $arg1_name) ))) end @@ -254,8 +254,8 @@ module Mousetrap x::$type, $arg1_name::$arg1_origin_type, $arg2_name::$arg2_origin_type - ) = Base.convert($return_t, detail.$name(x._internal, - convert($arg1_destination_type, $arg1_name), + ) = Base.convert($return_t, detail.$name(x._internal, + convert($arg1_destination_type, $arg1_name), convert($arg2_destination_type, $arg2_name) ))) end @@ -297,10 +297,10 @@ module Mousetrap $arg1_name::$arg1_origin_type, $arg2_name::$arg2_origin_type, $arg3_name::$arg3_origin_type - ) = Base.convert($return_t, detail.$name(x._internal, - convert($arg1_destination_type, $arg1_name), - convert($arg2_destination_type, $arg2_name), - convert($arg3_destination_type, $arg3_name), + ) = Base.convert($return_t, detail.$name(x._internal, + convert($arg1_destination_type, $arg1_name), + convert($arg2_destination_type, $arg2_name), + convert($arg3_destination_type, $arg3_name), ))) end @@ -351,17 +351,17 @@ module Mousetrap $arg2_name::$arg2_origin_type, $arg3_name::$arg3_origin_type, $arg4_name::$arg4_origin_type - ) = Base.convert($return_t, detail.$name(x._internal, - convert($arg1_destination_type, $arg1_name), - convert($arg2_destination_type, $arg2_name), - convert($arg3_destination_type, $arg3_name), + ) = Base.convert($return_t, detail.$name(x._internal, + convert($arg1_destination_type, $arg1_name), + convert($arg2_destination_type, $arg2_name), + convert($arg3_destination_type, $arg3_name), convert($arg4_destination_type, $arg4_name) ))) end - + @generated function get_top_level_widget(x) ::Widget return :( - throw(AssertionError("Object of type $(typeof(x)) does not fullfill the widget interface. In order for it to be able to be treated as a widget, you need to subtype `Mousetrap.Widget` **and** add a method with signature `(::$(typeof(x))) -> Widget` to `Mousetrap.get_top_level_widget`, which should map an instance of $(typeof(x)) to its top-level widget component.")) + throw(AssertionError("Object of type $(typeof(x)) does not fulfill the widget interface. In order for it to be able to be treated as a widget, you need to subtype `Mousetrap.Widget` **and** add a method with signature `(::$(typeof(x))) -> Widget` to `Mousetrap.get_top_level_widget`, which should map an instance of $(typeof(x)) to its top-level widget component.")) ) end export get_top_level_widget @@ -510,7 +510,7 @@ module Mousetrap x::T y::T z::T - + Vector3{T}(all::Number) where T = new{T}(convert(T, all), convert(T, all), convert(T, all)) Vector3{T}(x::Number, y::Number, z::Number) where T = new{T}(convert(T, x), convert(T, y), convert(T, z)) end @@ -534,7 +534,7 @@ module Mousetrap y::T z::T w::T - + Vector4{T}(all::Number) where T = new{T}(convert(T, all), convert(T, all), convert(T, all), convert(T, all)) Vector4{T}(x::Number, y::Number, z::Number, w::Number) where T = new{T}(convert(T, x), convert(T, y), convert(T, z), convert(T, w)) end @@ -600,7 +600,7 @@ module Mousetrap Base.:(!=)(a::Time, b::Time) = !(a == b) Base.:(<)(a::Time, b::Time) = a._ns < b._ns Base.:(>)(a::Time, b::Time) = a._ns > b._ns - + Base.show(io::IO, x::Time) = print(io, "Time($(as_seconds(x))s)") @export_type Clock SignalEmitter @@ -954,46 +954,46 @@ module Mousetrap macro add_signal_items_changed(x) return :(@add_signal $x items_changed Cvoid Integer position Integer n_removed Integer n_added) end macro add_signal_closed(x) return :(@add_signal $x closed Cvoid) end macro add_signal_text_changed(x) return :(@add_signal $x text_changed Cvoid) end - + macro add_signal_drag_begin(x) return :(@add_signal $x drag_begin Cvoid AbstractFloat start_x AbstractFloat start_y) end macro add_signal_drag(x) return :(@add_signal $x drag Cvoid AbstractFloat offset_x AbstractFloat offset_y) end macro add_signal_drag_end(x) return :(@add_signal $x drag_end Cvoid AbstractFloat offset_x AbstractFloat offset_y) end - + macro add_signal_click_pressed(x) return :(@add_signal $x click_pressed Cvoid Integer n_press AbstractFloat x AbstractFloat y) end macro add_signal_click_released(x) return :(@add_signal $x click_released Cvoid Integer n_press AbstractFloat x AbstractFloat y) end macro add_signal_click_stopped(x) return :(@add_signal $x click_stopped Cvoid) end - + macro add_signal_focus_gained(x) return :(@add_signal $x focus_gained Cvoid) end macro add_signal_focus_lost(x) return :(@add_signal $x focus_lost Cvoid) end macro add_signal_pressed(x) return :(@add_signal $x pressed Cvoid AbstractFloat x AbstractFloat y) end macro add_signal_press_cancelled(x) return :(@add_signal $x press_cancelled Cvoid) end - + macro add_signal_motion_enter(x) return :(@add_signal $x motion_enter Cvoid AbstractFloat x AbstractFloat y) end macro add_signal_motion(x) return :(@add_signal $x motion Cvoid AbstractFloat x AbstractFloat y) end macro add_signal_motion_leave(x) return :(@add_signal $x motion_leave Cvoid) end - + macro add_signal_scale_changed(x) return :(@add_signal $x scale_changed Cvoid AbstractFloat scale) end macro add_signal_rotation_changed(x) return :(@add_signal $x rotation_changed Cvoid AbstractFloat angle_absolute_rads AbstractFloat angle_delta_rads) end - + macro add_signal_kinetic_scroll_decelerate(x) return :(@add_signal $x kinetic_scroll_decelerate Cvoid AbstractFloat x_velocity AbstractFloat y_velocity) end macro add_signal_scroll_begin(x) return :(@add_signal $x scroll_begin Cvoid) end macro add_signal_scroll(x) return :(@add_signal $x scroll Cvoid AbstractFloat delta_x AbstractFloat delta_y) end # sic, jl_unbox_bool(jl_nothing) == true macro add_signal_scroll_end(x) return :(@add_signal $x scroll_end Cvoid) end - + macro add_signal_stylus_up(x) return :(@add_signal $x stylus_up Cvoid AbstractFloat x AbstractFloat y) end macro add_signal_stylus_down(x) return :(@add_signal $x stylus_down Cvoid AbstractFloat x AbstractFloat y) end macro add_signal_proximity(x) return :(@add_signal $x proximity Cvoid AbstractFloat x AbstractFloat y) end - + macro add_signal_swipe(x) return :(@add_signal $x swipe Cvoid AbstractFloat x_velocity AbstractFloat y_velocity) end macro add_signal_pan(x) return :(@add_signal $x pan Cvoid PanDirection direction AbstractFloat offset) end - + macro add_signal_paint(x) return :(@add_signal $x paint Cvoid) end macro add_signal_update(x) return :(@add_signal $x update Cvoid) end - + macro add_signal_value_changed(x) return :(@add_signal $x value_changed Cvoid) end macro add_signal_properties_changed(x) return :(@add_signal $x properties_changed Cvoid) end - + macro add_signal_wrapped(x) return :(@add_signal $x wrapped Cvoid) end macro add_signal_scroll_child(x) return :(@add_signal $x scroll_child Cvoid ScrollType type Bool is_horizontal) end @@ -1005,7 +1005,7 @@ module Mousetrap macro add_signal_activate_item(T) snake_case = :activate_item - Return_t = Cvoid + Return_t = Cvoid Arg1_t = Integer arg1_name = :index @@ -1346,7 +1346,7 @@ module Mousetrap return out end - + macro add_key_event_controller_signal(T, name, Return_t) out = Expr(:block) @@ -1534,7 +1534,7 @@ module Mousetrap @add_signal_activate Application @add_signal_shutdown Application - function main(f, application_id::String = "com.julia.mousetrap") + function main(f, application_id::String = "com.julia.mousetrap") app = Application(application_id) typed_f = TypedFunction(f, Any, (Application,)) connect_signal_activate!(app) do app::Application @@ -1552,7 +1552,7 @@ module Mousetrap return run!(app) end export main - + Base.show(io::IO, x::Application) = show_aux(io, x, :is_holding, :is_marked_as_busy) ####### window.jl @@ -1788,7 +1788,7 @@ module Mousetrap import Base.== ==(x::RGBA, y::RGBA) = x.r == y.r && x.g == y.g && x.b == y.b && x.a == y.a - function ==(x::HSVA, y::HSVA) + function ==(x::HSVA, y::HSVA) hue_equal = x.h == y.h || abs(x.h - y.h) == 1 return hue_equal && x.s == y.s && x.v == y.v && x.a == y.a end @@ -1828,7 +1828,7 @@ module Mousetrap @export_type Icon Icon() = Icon(detail._Icon()) - + function Icon(path::String) out = Icon() create_from_file!(out, path) @@ -1952,7 +1952,7 @@ module Mousetrap @export_function KeyFile get_keys Vector{KeyID} GroupID group @export_function KeyFile has_key Bool GroupID group KeyID key @export_function KeyFile has_group Bool GroupID group - + set_comment_above!(file::KeyFile, group::GroupID, key::KeyID, comment::String) = detail.set_comment_above_key!(file._internal, group, key, comment) set_comment_above!(file::KeyFile, group::GroupID, comment::String) = detail.set_comment_above_group!(file._internal, group, comment) export set_comment_above! @@ -2361,7 +2361,7 @@ module Mousetrap @export_function PopupMessage get_button_action_id String @export_function PopupMessage set_is_high_priority! Cvoid Bool b @export_function PopupMessage get_is_high_priority Bool - + set_timeout!(popup_message::PopupMessage, duration::Time) = detail.set_timeout!(popup_message._internal, convert(Cfloat, as_microseconds(duration))) export set_timeout! @@ -2510,7 +2510,7 @@ module Mousetrap @export_type ClampFrame Widget @declare_native_widget ClampFrame - function ClampFrame(size::Number, orientation::Orientation = ORIENTATION_HORIZONTAL) + function ClampFrame(size::Number, orientation::Orientation = ORIENTATION_HORIZONTAL) out = ClampFrame(detail._ClampFrame(orientation)) set_maximum_size!(out, size) return out @@ -2535,7 +2535,7 @@ module Mousetrap Box(orientation::Orientation) = Box(detail._Box(orientation)) - function hbox(widgets::Widget...) + function hbox(widgets::Widget...) out = Box(ORIENTATION_HORIZONTAL) for widget in widgets push_back!(out, widget) @@ -2544,7 +2544,7 @@ module Mousetrap end export hbox - function vbox(widgets::Widget...) + function vbox(widgets::Widget...) out = Box(ORIENTATION_VERTICAL) for widget in widgets push_back!(out, widget) @@ -2624,14 +2624,14 @@ module Mousetrap detail.set_row_spacing!(box._internal, convert(Cfloat, spacing)) end export set_row_spacing! - + @export_function FlowBox get_row_spacing Cfloat function set_column_spacing!(box::FlowBox, spacing::Number) detail.set_column_spacing!(box._internal, convert(Cfloat, spacing)) end export set_column_spacing! - + @export_function FlowBox get_column_spacing Cfloat @export_function FlowBox get_n_items Cint @@ -2649,7 +2649,7 @@ module Mousetrap Button() = Button(detail._Button()) - function Button(label::Widget) + function Button(label::Widget) out = Button() set_child!(out, label) return out @@ -2694,7 +2694,7 @@ module Mousetrap @declare_native_widget CenterBox CenterBox(orientation::Orientation) = CenterBox(detail._CenterBox(orientation)) - + function CenterBox(orientation::Orientation, left::Widget, center::Widget, right::Widget) ::CenterBox out = CenterBox(orientation) set_start_child!(out, left) @@ -2702,7 +2702,7 @@ module Mousetrap set_end_child!(out, right) return out end - + function set_start_child!(center_box::CenterBox, child::Widget) detail.set_start_child!(center_box._internal, as_widget_pointer(child)) end @@ -2892,8 +2892,8 @@ module Mousetrap @add_widget_signals Viewport @add_signal_scroll_child Viewport - Base.show(io::IO, x::Viewport) = show_aux(io, x, - :propagate_natural_height, + Base.show(io::IO, x::Viewport) = show_aux(io, x, + :propagate_natural_height, :propagate_natural_width ) @@ -3068,10 +3068,10 @@ module Mousetrap @add_widget_signals Label - Base.show(io::IO, x::Label) = show_aux(io, x, - :text, - :ellipsize_mode, - :wrap_mode, + Base.show(io::IO, x::Label) = show_aux(io, x, + :text, + :ellipsize_mode, + :wrap_mode, :justify_mode ) @@ -3350,7 +3350,7 @@ module Mousetrap typed_f(DropDown(drop_down_internal_ref[])) end) end - + push_back!(drop_down::DropDown, list_widget::Widget, label_widget::Widget) = push_back!((_::DropDown) -> nothing, drop_down, list_widget, label_widget) push_back!(drop_down::DropDown, label::String) = push_back!((_::DropDown) -> nothing, drop_down, label) export push_back! @@ -3664,7 +3664,7 @@ module Mousetrap @export_function StylusEventController get_tool_type ToolType @export_function StylusEventController has_axis Bool DeviceAxis axis @export_function StylusEventController get_axis_value Float64 DeviceAxis axis - + @add_signal_stylus_up StylusEventController @add_signal_stylus_down StylusEventController @add_signal_proximity StylusEventController @@ -3726,9 +3726,9 @@ module Mousetrap @export_function SelectionModel select_all! Cvoid @export_function SelectionModel unselect_all! Cvoid @export_function SelectionModel get_n_items Int64 - + @export_function SelectionModel get_selection_mode SelectionMode - + select!(model::SelectionModel, i::Integer, unselect_others::Bool = true) = detail.select!(model._internal, from_julia_index(i), unselect_others) export select! @@ -3775,11 +3775,11 @@ module Mousetrap set_widget_at!(list_view::ListView, index::Integer, widget::Widget, iterator::ListViewIterator) = detail.set_widget_at!(list_view._internal, from_julia_index(index), as_widget_pointer(widget), iterator._internal) export set_widget_at! - function find(list_view::ListView, widget::Widget, iterator::ListViewIterator) ::Signed + function find(list_view::ListView, widget::Widget, iterator::ListViewIterator) ::Signed i = detail.find(list_view._internal, as_widget_pointer(widget), iterator._internal) return i == -1 ? -1 : to_julia_index(i) end - function find(list_view::ListView, widget::Widget) ::Signed + function find(list_view::ListView, widget::Widget) ::Signed i = detail.find(list_view._internal, as_widget_pointer(widget), Ptr{Cvoid}()) return i == -1 ? -1 : to_julia_index(i) end @@ -3787,7 +3787,7 @@ module Mousetrap get_selection_model(list_view::ListView) ::SelectionModel = SelectionModel(detail.get_selection_model(list_view._internal)) export get_selection_model - + @export_function ListView set_enable_rubberband_selection! Cvoid Bool b @export_function ListView get_enable_rubberband_selection Bool @export_function ListView set_show_separators! Cvoid Bool b @@ -3826,7 +3826,7 @@ module Mousetrap clear!(grid_view::GridView) = detail.clear!(grid_view._internal) export clear! - function find(grid_view::GridView, widget::Widget) ::Signed + function find(grid_view::GridView, widget::Widget) ::Signed i = detail.find(grid_view._internal, as_widget_pointer(widget)) return i == -1 ? -1 : to_julia_index(i) end @@ -4025,7 +4025,7 @@ module Mousetrap end export move_page_to! - remove!(notebook::Notebook, index::Integer) = detail.remove!(notebook._internal, from_julia_index(index)) + remove!(notebook::Notebook, index::Integer) = detail.remove!(notebook._internal, from_julia_index(index)) export remove! @export_function Notebook next_page! Cvoid @@ -4083,17 +4083,17 @@ module Mousetrap ColumnView(selection_mode::SelectionMode = SELECTION_MODE_NONE) = ColumnView(detail._ColumnView(selection_mode)) - function push_back_column!(column_view::ColumnView, title::String) ::ColumnViewColumn + function push_back_column!(column_view::ColumnView, title::String) ::ColumnViewColumn return ColumnViewColumn(detail.push_back_column!(column_view._internal, title)) end export push_back_column! - function push_front_column!(column_view::ColumnView, title::String) ::ColumnViewColumn + function push_front_column!(column_view::ColumnView, title::String) ::ColumnViewColumn return ColumnViewColumn(detail.push_front_column!(column_view._internal, title)) end export push_front_column! - function insert_column_at!(column_view::ColumnView, index::Integer, title::String) ::ColumnViewColumn + function insert_column_at!(column_view::ColumnView, index::Integer, title::String) ::ColumnViewColumn return ColumnViewColumn(detail.insert_column!(column_view._internal, from_julia_index(index), title)) end export insert_column_at! @@ -4196,7 +4196,7 @@ module Mousetrap set_title_widget!(header_bar::HeaderBar, widget::Widget) = detail.set_title_widget!(header_bar._internal, as_widget_pointer(widget)) export set_title_widget! - @export_function HeaderBar remove_title_widget! Cvoid + @export_function HeaderBar remove_title_widget! Cvoid push_front!(header_bar::HeaderBar, widget::Widget) = detail.push_front!(header_bar._internal, as_widget_pointer(widget)) export push_front! @@ -4224,7 +4224,7 @@ module Mousetrap set_end_child!(out, end_child) return out end - + @export_function Paned get_position Cint @export_function Paned set_position! Cvoid Integer position @@ -4367,7 +4367,7 @@ module Mousetrap @add_widget_signals ActionBar Base.show(io::IO, x::ActionBar) = show_aux(io, x, :is_revealed) - + ###### scale.jl @export_type Scale Widget @@ -4394,7 +4394,7 @@ module Mousetrap @export_function Scale set_upper! Cvoid Number => Cfloat value @export_function Scale set_step_increment! Cvoid Number => Cfloat value @export_function Scale set_value! Cvoid Number => Cfloat value - + @export_function Scale set_should_draw_value! Cvoid Bool b @export_function Scale get_should_draw_value Bool @export_function Scale set_has_origin! Cvoid Bool b @@ -4421,9 +4421,9 @@ module Mousetrap function SpinButton(lower::Number, upper::Number, step_increment::Number, orientation::Orientation = ORIENTATION_HORIZONTAL) return SpinButton(detail._SpinButton( - convert(Cfloat, lower), - convert(Cfloat, upper), - convert(Cfloat, step_increment), + convert(Cfloat, lower), + convert(Cfloat, upper), + convert(Cfloat, step_increment), orientation )) end @@ -4564,7 +4564,7 @@ module Mousetrap return_t = esc(return_t) Mousetrap.eval(:(export $name)) - return :(function $name(widget::Widget) + return :(function $name(widget::Widget) return Base.convert($return_t, detail.$name(as_widget_pointer(widget))) end) return out @@ -4573,7 +4573,7 @@ module Mousetrap macro export_widget_function(name, return_t, arg1_type, arg1_name) return_t = esc(return_t) - + if arg1_type isa Expr arg1_origin_type = arg1_type.args[2] arg1_destination_type = arg1_type.args[3] @@ -4585,7 +4585,7 @@ module Mousetrap Mousetrap.eval(:(export $name)) out = Expr(:toplevel) - return :(function $name(widget::Widget, $arg1_name::$arg1_origin_type) + return :(function $name(widget::Widget, $arg1_name::$arg1_origin_type) return Base.convert($return_t, detail.$name(as_widget_pointer(widget), convert($arg1_destination_type, $arg1_name))) end) return out @@ -4705,7 +4705,7 @@ module Mousetrap @export_type Clipboard SignalEmitter - function Clipboard(internal::Ptr{Cvoid}) + function Clipboard(internal::Ptr{Cvoid}) out = Clipboard(detail._Clipboard(internal)) end @@ -4908,7 +4908,7 @@ module Mousetrap abstract type TextureObject <: SignalEmitter end export TextureObject - + @export_enum TextureWrapMode begin TEXTURE_WRAP_MODE_ZERO TEXTURE_WRAP_MODE_ONE @@ -4990,7 +4990,7 @@ module Mousetrap if isempty(positions) @log_critical MOUSETRAP_DOMAIN "In as_points!: Vector `positions` is empty." end - + return detail.as_points!(shape._internal, positions) end export as_points! @@ -5156,7 +5156,7 @@ module Mousetrap end export get_vertex_texture_coordinate - function set_vertex_texture_coordinate!(shape::Shape, index::Integer, coordinate::Vector2f) + function set_vertex_texture_coordinate!(shape::Shape, index::Integer, coordinate::Vector2f) detail.set_vertex_texture_coordinate!(shape._internal, from_julia_index(index), coordinate) end export set_vertex_texture_coordinate! @@ -5166,7 +5166,7 @@ module Mousetrap end export get_vertex_position - function set_vertex_position!(shape::Shape, index::Integer, coordinate::Vector3f) + function set_vertex_position!(shape::Shape, index::Integer, coordinate::Vector3f) detail.set_vertex_position!(shape._internal, from_julia_index(index), coordinate) end export set_vertex_position! @@ -5383,7 +5383,7 @@ end # else MOUSETRAP_ENABLE_OPENGL_COMPONENT end @export_type Animation SignalEmitter - function Animation(target::Widget, duration::Time) + function Animation(target::Widget, duration::Time) return Animation(detail._Animation(as_widget_pointer(target), convert(Float32, as_microseconds(duration)))) end @@ -5460,7 +5460,7 @@ end # else MOUSETRAP_ENABLE_OPENGL_COMPONENT @export_function TransformBin remove_child! Cvoid @export_function TransformBin reset! Cvoid - + rotate!(bin::TransformBin, angle::Angle) = detail.rotate!(bin._internal, convert(Float32, as_degrees(angle))) export rotate! @@ -5469,9 +5469,9 @@ end # else MOUSETRAP_ENABLE_OPENGL_COMPONENT @export_function TransformBin scale! Cvoid Number => Cfloat x Number => Cfloat y scale!(bin::TransformBin, both::Number) = scale!(bin, both, both) - + @export_function TransformBin skew! Cvoid Number => Cfloat x Number => Cfloat y - + @add_widget_signals TransformBin Base.show(io::IO, x::TransformBin) = show_aux(io, x) @@ -5516,7 +5516,7 @@ end # else MOUSETRAP_ENABLE_OPENGL_COMPONENT include("./key_codes.jl") ###### documentation - + include("./docs.jl") ###### compound_widget.jl @@ -5526,43 +5526,43 @@ end # else MOUSETRAP_ENABLE_OPENGL_COMPONENT for (signal, _) in Mousetrap.signal_descriptors connect_signal_name = :connect_signal_ * signal * :! push!(out.args, esc(:( - function Mousetrap.$connect_signal_name(f, x::Widget) + function Mousetrap.$connect_signal_name(f, x::Widget) $connect_signal_name(f, Mousetrap.get_top_level_widget(x)) end ))) - + push!(out.args, esc(:( - function Mousetrap.$connect_signal_name(f, x::Widget, data::Data_t) where Data_t + function Mousetrap.$connect_signal_name(f, x::Widget, data::Data_t) where Data_t $connect_signal_name(f, Mousetrap.get_top_level_widget(x), data) end ))) - + emit_signal_name = :emit_signal_ * signal - + push!(out.args, esc(:( - function $emit_signal_name(x::Widget, args...) + function $emit_signal_name(x::Widget, args...) $emit_signal_name(Mousetrap.get_top_level_widget(x), args) end ))) - + disconnect_signal_name = :disconnect_signal_ * signal * :! - + push!(out.args, esc(:( function $disconnect_signal_name(x::Widget) $disconnect_signal_name(Mousetrap.get_top_level_widget(x)) end ))) - + set_signal_blocked_name = :set_signal_ * signal * :_blocked * :! - + push!(out.args, esc(:( function $set_signal_blocked_name(x::Widget, b) $set_signal_blocked_name(Mousetrap.get_top_level_widget(x), b) end ))) - + get_signal_blocked_name = :get_signal_ * signal * :_blocked - + push!(out.args, esc(:( function $get_signal_blocked_name(x::Widget) return $get_signal_blocked_name(Mousetrap.get_top_level_widget(x)) From 9b04ac70950bfc617591538f62ec8c3af14c960c Mon Sep 17 00:00:00 2001 From: Clem Cords Date: Thu, 8 Feb 2024 06:54:43 +0100 Subject: [PATCH 13/14] added sick leave warning --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d3b0df4..294ad6e 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ It aims to give developers of all skill levels the tools to start creating compl > **Note**: Mousetrap is under active development. Consider participating in the development by [opening an issue](https://github.com/clemapfel/mousetrap.jl) when you encounter an error, bug, question, or missing feature. +> **Note**: February 8th, 2024: I've been having some health issues at the moment, it may take me some time to get to open issues. Mousetrap is still usable and (mostly) stable, the repo will be maintained in the immediate future to the best of my abilities. Thank you for your understanding, C. --- ## Table of Contents From 40e264da4fa36887d1f31f4940276a94ed7a0c1a Mon Sep 17 00:00:00 2001 From: Clem Cords Date: Thu, 8 Feb 2024 16:57:26 +0100 Subject: [PATCH 14/14] tests passing --- src/Mousetrap.jl | 4 ++-- test/runtests.jl | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Mousetrap.jl b/src/Mousetrap.jl index 31b520a..ddd48af 100644 --- a/src/Mousetrap.jl +++ b/src/Mousetrap.jl @@ -4160,7 +4160,7 @@ module Mousetrap row_i = 1 for i in 1:get_n_columns(column_view) column = get_column_at(column_view, i) - set_widget_at!(column_view, column, from_julia_index(row_i), widgets[i]) + set_widget_at!(column_view, column, row_i, widgets[i]) end end export push_front_row! @@ -4174,7 +4174,7 @@ module Mousetrap row_i = index for i in 1:get_n_columns(column_view) column = get_column_at(column_view, i) - set_widget!(column_view, column, row_i, widgets[i]) + set_widget_at!(column_view, column, row_i, widgets[i]) end end export push_front_row! diff --git a/test/runtests.jl b/test/runtests.jl index 2ae7c4c..0fada3b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -753,6 +753,10 @@ function test_column_view(::Container) set_expand!(column, true) @test get_expand(column) == true + push_back_row!(column_view, Label(""), Label(""), Label("")) + push_front_row!(column_view, Label(""), Label(""), Label("")) + insert_row_at!(column_view, 2, Label(""), Label(""), Label("")) + @test get_title(column) == column_name new_title = "new title"