Created
March 28, 2020 10:19
-
-
Save ikskuh/5bdb9e1f972678019cae8301bc40da26 to your computer and use it in GitHub Desktop.
Dunstblick (behind the scenes)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Resource ID = 1 */ | |
TabLayout | |
{ | |
margins: 0; | |
DockLayout | |
{ | |
tab-title: "Menu"; | |
Button | |
{ | |
dock-site: bottom; | |
Label { text: "Exit"; } | |
} | |
Label | |
{ | |
dock-site: top; | |
text: "Available Applications"; | |
font-family: serif; | |
} | |
StackLayout | |
{ | |
/* This is where the magic happens! */ | |
child-source: bind(1); | |
child-template: resource(2); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Resource ID = 2 */ | |
Panel | |
{ | |
DockLayout | |
{ | |
Button { | |
on-click: callback(2); | |
dock-site: right; | |
widget-name: bind(5); | |
Label { text: "Open"; } | |
} | |
Button { | |
on-click: callback(3); | |
dock-site: right; | |
widget-name: bind(5); | |
Label { text: "Close"; } | |
} | |
Label { | |
dock-site: right; | |
text: bind(4); /* port */ | |
margins: 0,4,4,4; | |
} | |
Label { | |
dock-site: right; | |
text: ":"; | |
margins: 0,4,0,4; | |
} | |
Label { | |
dock-site: right; | |
text: bind(3); /* ip */ | |
margins: 4,4,0,4; | |
} | |
Label { | |
horizontal-alignment: left; | |
text: bind(2); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Update objects in local session | |
{ | |
std::vector<DiscoveredClient> clients; | |
{ | |
std::lock_guard<std::mutex> lock{discovered_clients_lock}; | |
clients = discovered_clients; | |
} | |
ObjectList list; | |
list.reserve(clients.size()); | |
for (size_t i = 0; i < clients.size(); i++) { | |
auto const id = local_session_id(i); | |
Object obj{id}; | |
obj.add(local_app_name /* = 2 */, UIValue(clients[i].name)); | |
obj.add(local_app_port /* = 4 */, UIValue(clients[i].tcp_port)); | |
obj.add(local_app_ip /* = 3 */, UIValue(xnet::to_string(clients[i].udp_ep, false))); | |
obj.add(local_app_id /* = 5 */, UIValue(WidgetName(i + 1))); | |
list.emplace_back(obj); | |
sess.addOrUpdateObject(std::move(obj)); | |
} | |
sess.clear(local_root_obj, local_discovery_list /* = 1 */); | |
sess.insertRange(local_root_obj, local_discovery_list /* = 1 */, 0, list.size(), list.data()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment