Fri, 20 Oct 2023 16:34:33 +0200
add minimal working dnd implementation (WinUI3)
196
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | * Copyright 2023 Olaf Wintermann. All rights reserved. |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | |
205
b1ac0dd1d38b
new winui vs project, add toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
204
diff
changeset
|
29 | #include "pch.h" |
b1ac0dd1d38b
new winui vs project, add toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
204
diff
changeset
|
30 | |
196
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | #include "list.h" |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | #include "container.h" |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | #include "util.h" |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | #include "../common/context.h" |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | #include "../common/object.h" |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
37 | |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
38 | |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
39 | using namespace winrt; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
40 | using namespace Microsoft::UI::Xaml; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | using namespace Microsoft::UI::Xaml::Controls; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
42 | using namespace Windows::UI::Xaml::Interop; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
43 | using namespace winrt::Windows::Foundation; |
221
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
44 | using namespace Microsoft::UI::Xaml::Markup; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
45 | using namespace Microsoft::UI::Xaml::Media; |
196
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
46 | using namespace winrt::Microsoft::UI::Xaml::Controls::Primitives; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
47 | |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
48 | UIWIDGET ui_listview_create(UiObject* obj, UiListArgs args) { |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
49 | UiObject* current = uic_current_obj(obj); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
50 | |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
51 | // create listview and toolkit wrapper |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
52 | ListView listview = ListView(); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
53 | if (args.multiselection) { |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
54 | listview.SelectionMode(ListViewSelectionMode::Extended); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
55 | } |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
57 | bool clickEnabled = listview.IsItemClickEnabled(); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
58 | listview.IsItemClickEnabled(true); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
59 | |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
60 | |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
61 | UIElement elm = listview; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
62 | UiWidget* widget = new UiWidget(elm); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
63 | widget->data1 = args.model; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
64 | widget->data2 = args.getvalue; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
65 | ui_context_add_widget_destructor(current->ctx, widget); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
66 | |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
67 | // bind var |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
68 | UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.list, args.varname, UI_VAR_LIST); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
69 | if (var) { |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
70 | UiList* list = (UiList*)var->value; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
71 | list->update = ui_simple_list_update; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
72 | list->obj = widget; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
73 | ui_simple_list_update(list, 0); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
74 | } |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
75 | |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
76 | if (args.onselection) { |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
77 | ui_callback onselection = args.onselection; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
78 | void* cbdata = args.onselectiondata; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
79 | listview.SelectionChanged([onselection, cbdata, obj](IInspectable const& sender, RoutedEventArgs evtargs) { |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
80 | std::vector<int> selectedRows = ui_create_listview_selection(sender.as<ListView>()); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
81 | |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
82 | UiListSelection selection; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
83 | selection.rows = selectedRows.data(); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
84 | selection.count = selectedRows.size(); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
85 | |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
86 | UiEvent evt; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
87 | evt.obj = obj; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
88 | evt.window = obj->window; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
89 | evt.document = obj->ctx->document; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
90 | evt.eventdata = &selection; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
91 | evt.intval = 0; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
92 | onselection(&evt, cbdata); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
93 | }); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
94 | } |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
95 | if (args.onactivate) { |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
96 | ui_callback cb = args.onactivate; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
97 | void* cbdata = args.onactivatedata; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
98 | listview.ItemClick([cb, cbdata, obj](IInspectable const& sender, RoutedEventArgs evtargs) { |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
99 | std::vector<int> selectedRows = ui_create_listview_selection(sender.as<ListView>()); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
100 | UiListSelection selection; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
101 | selection.rows = selectedRows.data(); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
102 | selection.count = selectedRows.size(); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
103 | |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
104 | UiEvent evt; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
105 | evt.obj = obj; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
106 | evt.window = obj->window; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
107 | evt.document = obj->ctx->document; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
108 | evt.eventdata = &selection; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
109 | evt.intval = 0; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
110 | cb(&evt, cbdata); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
111 | }); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
112 | } |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
113 | |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
114 | // add listview to current container |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
115 | UI_APPLY_LAYOUT1(current, args); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
116 | |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
117 | current->container->Add(listview, false); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
118 | |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
119 | return widget; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
120 | } |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
121 | |
197
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
122 | |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
123 | UIWIDGET ui_combobox_create(UiObject* obj, UiListArgs args) { |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
124 | UiObject* current = uic_current_obj(obj); |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
125 | |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
126 | // create listview and toolkit wrapper |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
127 | ComboBox combobox = ComboBox(); |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
128 | |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
129 | UIElement elm = combobox; |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
130 | UiWidget* widget = new UiWidget(elm); |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
131 | widget->data1 = args.model; |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
132 | widget->data2 = args.getvalue; |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
133 | ui_context_add_widget_destructor(current->ctx, widget); |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
134 | |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
135 | // bind var |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
136 | UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.list, args.varname, UI_VAR_LIST); |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
137 | if (var) { |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
138 | UiList* list = (UiList*)var->value; |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
139 | list->update = ui_simple_list_update; |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
140 | list->obj = widget; |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
141 | ui_simple_list_update(list, 0); |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
142 | } |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
143 | |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
144 | if (args.onactivate) { |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
145 | ui_callback cb = args.onactivate; |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
146 | void* cbdata = args.onactivatedata; |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
147 | combobox.SelectionChanged([cb, cbdata, obj](IInspectable const& sender, RoutedEventArgs evtargs) { |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
148 | int selectedrow = sender.as<ComboBox>().SelectedIndex(); |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
149 | UiListSelection selection; |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
150 | selection.count = 1; |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
151 | selection.rows = &selectedrow; |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
152 | |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
153 | UiEvent evt; |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
154 | evt.obj = obj; |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
155 | evt.window = obj->window; |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
156 | evt.document = obj->ctx->document; |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
157 | evt.eventdata = &selection; |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
158 | evt.intval = selectedrow; |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
159 | cb(&evt, cbdata); |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
160 | }); |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
161 | } |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
162 | |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
163 | // add listview to current container |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
164 | UI_APPLY_LAYOUT1(current, args); |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
165 | |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
166 | current->container->Add(combobox, false); |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
167 | |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
168 | return widget; |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
169 | } |
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
170 | |
204
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
171 | UIEXPORT UIWIDGET ui_breadcrumbbar_create(UiObject* obj, UiListArgs args) { |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
172 | UiObject* current = uic_current_obj(obj); |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
173 | |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
174 | // create listview and toolkit wrapper |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
175 | BreadcrumbBar bcbar = BreadcrumbBar(); |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
176 | |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
177 | UIElement elm = bcbar; |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
178 | UiWidget* widget = new UiWidget(elm); |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
179 | widget->data1 = args.model; |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
180 | widget->data2 = args.getvalue; |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
181 | ui_context_add_widget_destructor(current->ctx, widget); |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
182 | |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
183 | // bind var |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
184 | UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.list, args.varname, UI_VAR_LIST); |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
185 | if (var) { |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
186 | UiList* list = (UiList*)var->value; |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
187 | list->update = ui_breadcrumbbar_update; |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
188 | list->obj = widget; |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
189 | ui_breadcrumbbar_update(list, 0); |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
190 | } |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
191 | |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
192 | if (args.onactivate) { |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
193 | ui_callback cb = args.onactivate; |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
194 | void* cbdata = args.onactivatedata; |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
195 | bcbar.ItemClicked([cb, cbdata, obj](IInspectable const& sender, BreadcrumbBarItemClickedEventArgs evtargs) { |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
196 | UiEvent evt; |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
197 | evt.obj = obj; |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
198 | evt.window = obj->window; |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
199 | evt.document = obj->ctx->document; |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
200 | evt.eventdata = nullptr; |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
201 | evt.intval = evtargs.Index(); |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
202 | cb(&evt, cbdata); |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
203 | }); |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
204 | } |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
205 | |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
206 | // add listview to current container |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
207 | UI_APPLY_LAYOUT1(current, args); |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
208 | |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
209 | current->container->Add(bcbar, false); |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
210 | |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
211 | return widget; |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
212 | } |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
213 | |
221
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
214 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
215 | extern "C" static void destroy_ui_pathbar(void* ptr) { |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
216 | UiPathBar* pb = (UiPathBar*)ptr; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
217 | delete pb; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
218 | } |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
219 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
220 | static void ui_context_add_pathbar_destructor(UiContext* ctx, UiPathBar* pb) { |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
221 | cxMempoolRegister(ctx->mp, pb, destroy_ui_pathbar); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
222 | } |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
223 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
224 | UIEXPORT UIWIDGET ui_pathbar_create(UiObject* obj, UiPathBarArgs args) { |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
225 | UiObject* current = uic_current_obj(obj); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
226 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
227 | // create view and toolkit wrapper |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
228 | Border pathbar = Border(); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
229 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
230 | IInspectable bgRes = Application::Current().Resources().Lookup(box_value(L"TextControlBackground")); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
231 | IInspectable borderThicknessRes = Application::Current().Resources().Lookup(box_value(L"TextControlBorderThemeThickness")); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
232 | IInspectable borderBrushRes = Application::Current().Resources().Lookup(box_value(L"TextControlBorderBrush")); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
233 | // IInspectable cornerRes = Application::Current().Resources().Lookup(box_value(L"TextControlCornerRadius")); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
234 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
235 | Brush bgBrush = unbox_value<Brush>(bgRes); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
236 | Thickness border = unbox_value<Thickness>(borderThicknessRes); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
237 | Brush borderBrush = unbox_value<Brush>(borderBrushRes); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
238 | CornerRadius cornerRadius = { 4, 4, 4, 4 }; //unbox_value<CornerRadius>(cornerRes); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
239 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
240 | pathbar.Background(bgBrush); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
241 | pathbar.BorderBrush(borderBrush); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
242 | pathbar.BorderThickness(border); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
243 | pathbar.CornerRadius(cornerRadius); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
244 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
245 | Grid content = Grid(); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
246 | pathbar.Child(content); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
247 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
248 | GridLength gl; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
249 | gl.Value = 1; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
250 | gl.GridUnitType = GridUnitType::Star; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
251 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
252 | ColumnDefinition coldef = ColumnDefinition(); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
253 | coldef.Width(gl); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
254 | content.ColumnDefinitions().Append(coldef); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
255 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
256 | TextBox pathTextBox = TextBox(); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
257 | Thickness t = { 0, 0, 0, 0 }; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
258 | CornerRadius c = { 0 ,0, 0, 0 }; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
259 | pathTextBox.BorderThickness(t); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
260 | //pathTextBox.CornerRadius(c); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
261 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
262 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
263 | pathTextBox.HorizontalAlignment(HorizontalAlignment::Stretch); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
264 | content.SetColumn(pathTextBox, 0); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
265 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
266 | content.Children().Append(pathTextBox); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
267 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
268 | // stackpanel for buttons |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
269 | StackPanel buttons = StackPanel(); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
270 | buttons.Orientation(Orientation::Horizontal); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
271 | buttons.Visibility(Visibility::Collapsed); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
272 | content.SetColumn(buttons, 0); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
273 | content.Children().Append(buttons); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
274 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
275 | if (args.ontextinput) { |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
276 | // TODO |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
277 | } |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
278 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
279 | //pathTextBox.Visibility(Visibility::Collapsed); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
280 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
281 | UiPathBar* uipathbar = new UiPathBar; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
282 | ui_context_add_pathbar_destructor(current->ctx, uipathbar); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
283 | uipathbar->grid = content; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
284 | uipathbar->buttons = buttons; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
285 | uipathbar->textbox = pathTextBox; |
222
1121b61f8828
implement pathbar action (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
221
diff
changeset
|
286 | uipathbar->obj = obj; |
221
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
287 | uipathbar->enabledrag = args.enabledrag; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
288 | uipathbar->enabledrop = args.enabledrop; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
289 | uipathbar->getvalue = args.getvalue; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
290 | uipathbar->model = args.model; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
291 | uipathbar->onactivate = args.onactivate; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
292 | uipathbar->onactivatedata = args.onactivatedata; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
293 | uipathbar->ondragstart = args.ondragstart; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
294 | uipathbar->ondragstartdata = args.ondragstartdata; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
295 | uipathbar->ondragcomplete = args.ondragcomplete; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
296 | uipathbar->ondragcompletedata = args.ondragcompletedata; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
297 | uipathbar->ondrop = args.ondrop; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
298 | uipathbar->ondropdata = args.ondropsdata; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
299 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
300 | UIElement elm = pathbar; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
301 | UiWidget* widget = new UiWidget(elm); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
302 | widget->data1 = uipathbar; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
303 | ui_context_add_widget_destructor(current->ctx, widget); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
304 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
305 | // bind var |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
306 | UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.list, args.varname, UI_VAR_LIST); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
307 | if (var) { |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
308 | UiList* list = (UiList*)var->value; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
309 | list->update = ui_pathbar_update; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
310 | list->obj = widget; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
311 | ui_pathbar_update(list, 0); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
312 | } |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
313 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
314 | // add listview to current container |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
315 | UI_APPLY_LAYOUT1(current, args); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
316 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
317 | current->container->Add(pathbar, false); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
318 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
319 | return widget; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
320 | } |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
321 | |
196
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
322 | static void* getstrvalue(void* elm, int ignore) { |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
323 | return elm; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
324 | } |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
325 | |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
326 | void ui_simple_list_update(UiList* list, int i) { |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
327 | UiWidget* widget = (UiWidget*)list->obj; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
328 | UiModel* model = (UiModel*)widget->data1; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
329 | ui_getvaluefunc getvalue = (ui_getvaluefunc)widget->data2; |
197
8a82ebe23822
add combobox (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
196
diff
changeset
|
330 | ItemsControl listview = widget->uielement.as<ItemsControl>(); |
196
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
331 | auto items = listview.Items(); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
332 | |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
333 | // priority: getvalue, model.getvalue, getstrvalue (fallback) |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
334 | if (getvalue == nullptr) { |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
335 | if (model && model->getvalue) { |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
336 | getvalue = model->getvalue; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
337 | } else { |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
338 | getvalue = getstrvalue; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
339 | } |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
340 | } |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
341 | |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
342 | // add list elements to listview.Items |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
343 | items.Clear(); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
344 | void* elm = list->first(list); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
345 | while (elm) { |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
346 | char* value = (char*)getvalue(elm, 0); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
347 | wchar_t* wstr = str2wstr(value, nullptr); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
348 | items.Append(box_value(wstr)); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
349 | free(wstr); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
350 | |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
351 | elm = list->next(list); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
352 | } |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
353 | } |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
354 | |
204
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
355 | extern "C" void ui_breadcrumbbar_update(UiList * list, int i) { |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
356 | UiWidget* widget = (UiWidget*)list->obj; |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
357 | UiModel* model = (UiModel*)widget->data1; |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
358 | ui_getvaluefunc getvalue = (ui_getvaluefunc)widget->data2; |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
359 | |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
360 | // priority: getvalue, model.getvalue, getstrvalue (fallback) |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
361 | if (getvalue == nullptr) { |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
362 | if (model && model->getvalue) { |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
363 | getvalue = model->getvalue; |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
364 | } |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
365 | else { |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
366 | getvalue = getstrvalue; |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
367 | } |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
368 | } |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
369 | |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
370 | BreadcrumbBar bar = widget->uielement.as<BreadcrumbBar>(); |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
371 | |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
372 | Windows::Foundation::Collections::IVector<Windows::Foundation::IInspectable> items { winrt::single_threaded_vector<Windows::Foundation::IInspectable>() }; |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
373 | void* elm = list->first(list); |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
374 | while (elm) { |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
375 | char* value = (char*)getvalue(elm, 0); |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
376 | wchar_t* wstr = str2wstr(value, nullptr); |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
377 | items.Append(box_value(wstr)); |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
378 | free(wstr); |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
379 | |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
380 | elm = list->next(list); |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
381 | } |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
382 | |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
383 | bar.ItemsSource(items); |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
384 | } |
4a258d47f964
add breadcrumb bar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
197
diff
changeset
|
385 | |
221
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
386 | static void ui_pathbar_clear(StackPanel &buttons) { |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
387 | for (int i = buttons.Children().Size() - 1; i >= 0; i--) { |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
388 | buttons.Children().RemoveAt(i); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
389 | } |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
390 | } |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
391 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
392 | extern "C" void ui_pathbar_update(UiList * list, int i) { |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
393 | UiWidget* widget = (UiWidget*)list->obj; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
394 | UiPathBar* pb = (UiPathBar*)widget->data1; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
395 | Grid grid = pb->grid; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
396 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
397 | UiModel* model = pb->model; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
398 | ui_getvaluefunc getvalue = pb->getvalue; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
399 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
400 | // priority: getvalue, model.getvalue, getstrvalue (fallback) |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
401 | if (getvalue == nullptr) { |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
402 | if (model && model->getvalue) { |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
403 | getvalue = model->getvalue; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
404 | } |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
405 | else { |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
406 | getvalue = getstrvalue; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
407 | } |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
408 | } |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
409 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
410 | // hide textbox, show button panel |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
411 | pb->textbox.Visibility(Visibility::Collapsed); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
412 | pb->buttons.Visibility(Visibility::Visible); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
413 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
414 | // clear old buttons |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
415 | ui_pathbar_clear(pb->buttons); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
416 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
417 | // add new buttons |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
418 | void* elm = list->first(list); |
222
1121b61f8828
implement pathbar action (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
221
diff
changeset
|
419 | int j = 0; |
221
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
420 | while (elm) { |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
421 | char* value = (char*)getvalue(elm, 0); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
422 | wchar_t* wstr = str2wstr(value, nullptr); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
423 | Button button = Button(); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
424 | button.Content(box_value(wstr)); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
425 | free(wstr); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
426 | |
222
1121b61f8828
implement pathbar action (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
221
diff
changeset
|
427 | if (pb->onactivate) { |
1121b61f8828
implement pathbar action (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
221
diff
changeset
|
428 | button.Click([pb, j](IInspectable const& sender, RoutedEventArgs) { |
1121b61f8828
implement pathbar action (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
221
diff
changeset
|
429 | UiEvent evt; |
1121b61f8828
implement pathbar action (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
221
diff
changeset
|
430 | evt.obj = pb->obj; |
1121b61f8828
implement pathbar action (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
221
diff
changeset
|
431 | evt.window = evt.obj->window; |
1121b61f8828
implement pathbar action (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
221
diff
changeset
|
432 | evt.document = evt.obj->ctx->document; |
1121b61f8828
implement pathbar action (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
221
diff
changeset
|
433 | evt.eventdata = nullptr; |
1121b61f8828
implement pathbar action (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
221
diff
changeset
|
434 | evt.intval = j; |
1121b61f8828
implement pathbar action (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
221
diff
changeset
|
435 | pb->onactivate(&evt, pb->onactivatedata); |
1121b61f8828
implement pathbar action (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
221
diff
changeset
|
436 | }); |
1121b61f8828
implement pathbar action (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
221
diff
changeset
|
437 | } |
1121b61f8828
implement pathbar action (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
221
diff
changeset
|
438 | |
221
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
439 | Thickness t = { 0, 0, 1, 0 }; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
440 | CornerRadius c = { 0 ,0, 0, 0 }; |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
441 | button.BorderThickness(t); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
442 | button.CornerRadius(c); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
443 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
444 | pb->buttons.Children().Append(button); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
445 | |
222
1121b61f8828
implement pathbar action (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
221
diff
changeset
|
446 | j++; |
221
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
447 | elm = list->next(list); |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
448 | } |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
449 | } |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
450 | |
a82d9beaa94a
add semi-functional pathbar (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
205
diff
changeset
|
451 | |
196
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
452 | std::vector<int> ui_create_listview_selection(ListView listview) { |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
453 | std::vector<int> selection; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
454 | int p = 0; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
455 | auto ranges = listview.SelectedRanges(); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
456 | for (auto range : ranges) { |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
457 | int begin = range.FirstIndex(); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
458 | int end = range.LastIndex(); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
459 | for (int i = begin; i <= end; i++) { |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
460 | selection.push_back(i); |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
461 | } |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
462 | } |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
463 | return selection; |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
464 | } |
320d85f3cd14
add listview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
465 |