val linkstr = string("link")
val link = UiLinkData(linkstr)
val webview = webview("webview")
+ val tabview = integer("tabview")
var currentFeed: FeedCollection? = null
}
webview.loadContent(null, content, mimeType, "utf-8")
+
+ tabview.setIntValue(1)
}
}
\ No newline at end of file
import de.unixwork.ui.ColumnType
import de.unixwork.ui.SubListItem
+import de.unixwork.ui.TabViewType
import de.unixwork.ui.TableModel
import de.unixwork.ui.UiList
import de.unixwork.ui.UiString
}
}
- grid(fill = true, columnspacing = 8, rowspacing = 8, margin = 8, defvfill = true) {
- row {
- rlabel("Feed:", hfill = true)
- llabel(varname = "feedname", hexpand = true)
- }
- row {
- rlabel("Author:", hfill = true)
- llabel(varname = "author")
- }
- row {
- rlabel("Link:", hfill = true)
- linkbutton(varname = "link", styleClass = "ui-nopadding");
+ tabview(fill = true, varname = "tabview", type = TabViewType.INVISIBLE) {
+ tab {
+ // Completely empty tab, we don't want any visible UI elements
+ // when no feed item is selected.
+ // As an alternative to using a tabview, we could use a
+ // visibility state for the grid container
}
+ tab {
+ grid(fill = true, columnspacing = 8, rowspacing = 8, margin = 8, defvfill = true) {
+ row {
+ rlabel("Feed:", hfill = true)
+ llabel(varname = "feedname", hexpand = true)
+ }
+ row {
+ rlabel("Author:", hfill = true)
+ llabel(varname = "author")
+ }
+ row {
+ rlabel("Link:", hfill = true)
+ linkbutton(varname = "link", styleClass = "ui-nopadding");
+ }
- row {
- webview(varname = "webview", hfill = true, vfill = true, hexpand = true, vexpand = true, colspan = 2)
+ row {
+ webview(varname = "webview", hfill = true, vfill = true, hexpand = true, vexpand = true, colspan = 2)
+ }
+ }
}
}
}
package de.unixwork.ui;
+import java.lang.foreign.Arena;
+import java.lang.foreign.MemorySegment;
+
public class Container implements AutoCloseable {
private UiObject object;
private UiWidget widget;
}
}
+ public static Container tab(UiObject obj, String label) {
+ ContainerFuncs ui = ContainerFuncs.getInstance();
+ try (Arena arena = Arena.ofConfined()) {
+ MemorySegment cstr = MemorySegment.NULL;
+ if(label != null) {
+ cstr = arena.allocateFrom(label);
+ }
+ ui.tab_create.invoke(obj.ptr, cstr);
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
+ return new Container(obj, null);
+ }
+
public static FrameBuilder frame(UiObject obj) {
ContainerFuncs ui = ContainerFuncs.getInstance();
return new FrameBuilder(obj, ui.frame_create);
public MethodHandle container_finish;
public MethodHandle newline;
+ public MethodHandle tab_create;
private ContainerFuncs(Linker linker, SymbolLookup lib) {
FunctionDescriptor sigm_mm = FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
FunctionDescriptor sigm_m = FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
FunctionDescriptor sigv_m = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS);
FunctionDescriptor sigi_m = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS);
+ FunctionDescriptor sigv_mm = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MemorySegment ui_vbox_create_addr = lib.find("ui_vbox_create").orElseThrow();
MemorySegment ui_hbox_create_addr = lib.find("ui_hbox_create").orElseThrow();
MemorySegment ui_container_finish = lib.find("ui_container_finish").orElseThrow();
MemorySegment ui_newline_addr = lib.find("ui_newline").orElseThrow();
+ MemorySegment ui_tab_create_addr = lib.find("ui_tab_create").orElseThrow();
vbox_create = linker.downcallHandle(ui_vbox_create_addr, sigm_mm);
hbox_create = linker.downcallHandle(ui_hbox_create_addr, sigm_mm);
container_finish = linker.downcallHandle(ui_container_finish, sigi_m);
newline = linker.downcallHandle(ui_newline_addr, sigv_m);
+ tab_create = linker.downcallHandle(ui_tab_create_addr, sigv_mm);
}
static ContainerFuncs getInstance() {
Container.newline(this@Toplevel.ui)
}
+ fun tab(
+ label: String? = null,
+ ui: ContainerUI? = null
+ ) {
+ val tab = Container.tab(this@Toplevel.ui, label)
+ ui?.callback()
+ tab.close()
+ }
private fun createFrame(
container: FrameBuilder,