blueprints ui fix

This commit is contained in:
Naveen Prashanth 2026-05-07 08:48:03 +05:30
parent c3a6a44484
commit ad90c7758e
11 changed files with 14 additions and 283 deletions

2
.gitignore vendored
View file

@ -4,3 +4,5 @@
/_build
/target
/*.Dockerfile
src/ui/*.ui
src/ui/graph/*.ui

View file

@ -6,6 +6,8 @@ fn main() {
"src/ui/graph/zoomentry.blp",
];
println!("cargo:warning=Helvum build script starting...");
for blp in blp_files {
let ui = blp.replace(".blp", ".ui");
println!("cargo:rerun-if-changed={}", blp);

View file

@ -20,6 +20,11 @@
@define-color media-type-midi rgb(200, 0, 50);
@define-color media-type-unknown rgb(128, 128, 128);
.port-handle {
border-radius: 50%;
background-color: @media-type-unknown;
}
.audio {
background: @media-type-audio;
color: black;
@ -36,8 +41,6 @@
}
node {
/* Compared to the default card color, this is not transparent in dark-mode
and provides a better contrast to the background in light mode */
background-color: @headerbar_bg_color;
}
@ -49,10 +52,6 @@ port label {
padding: 4px 6px;
}
port-handle {
border-radius: 50%;
background-color: @media-type-unknown;
}
button.rounded {
padding: 6px;

View file

@ -20,8 +20,6 @@ mod node;
pub use node::*;
mod port;
pub use port::*;
mod port_handle;
pub use port_handle::*;
mod link;
pub use link::*;
mod zoomentry;

View file

@ -1,60 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
DO NOT EDIT!
This file was @generated by blueprint-compiler. Instead, edit the
corresponding .blp file and regenerate this file with blueprint-compiler.
-->
<interface>
<requires lib="gtk" version="4.0"/>
<template class="HelvumNode" parent="GtkWidget">
<style>
<class name="card"/>
</style>
<child>
<object class="GtkBox">
<property name="orientation">1</property>
<child>
<object class="GtkBox">
<style>
<class name="node-title"/>
</style>
<property name="orientation">1</property>
<property name="spacing">1</property>
<child>
<object class="GtkLabel" id="node_name">
<style>
<class name="heading"/>
</style>
<property name="wrap">true</property>
<property name="ellipsize">3</property>
<property name="lines">2</property>
<property name="max-width-chars">20</property>
</object>
</child>
<child>
<object class="GtkLabel" id="media_name">
<style>
<class name="dim-label"/>
<class name="caption"/>
</style>
<property name="visible">false</property>
<property name="wrap">true</property>
<property name="ellipsize">3</property>
<property name="lines">2</property>
<property name="max-width-chars">20</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkSeparator" id="separator">
<property name="visible">false</property>
</object>
</child>
<child>
<object class="GtkGrid" id="port_grid"></object>
</child>
</object>
</child>
</template>
</interface>

View file

@ -10,7 +10,7 @@ template HelvumPort : Widget {
max-width-chars: 20;
}
Gtk.Box handle_container {
Gtk.Box handle {
halign: center;
valign: center;
}

View file

@ -25,7 +25,6 @@ pub use imp::{PortDirection, PortMediaType};
use crate::PortId;
use libspa::{param::format::MediaType, utils::Direction};
use super::PortHandle;
mod imp {
use super::*;
@ -107,8 +106,7 @@ mod imp {
#[template_child]
pub(super) label: TemplateChild<gtk::Label>,
#[template_child]
pub(super) handle_container: TemplateChild<gtk::Box>,
pub(super) handle: PortHandle,
pub(super) handle: TemplateChild<gtk::Box>,
}
impl Default for Port {
@ -118,8 +116,7 @@ mod imp {
media_type: Cell::new(PortMediaType::Unknown),
direction: Cell::new(PortDirection::Output),
label: TemplateChild::default(),
handle_container: TemplateChild::default(),
handle: PortHandle::new(),
handle: TemplateChild::default(),
}
}
}
@ -145,7 +142,8 @@ mod imp {
fn constructed(&self) {
self.parent_constructed();
self.handle_container.append(&self.handle);
self.handle.add_css_class("port-handle");
self.handle.set_size_request(14, 14);
// Force left-to-right direction for the ports grid to avoid messed up UI when defaulting to right-to-left
gtk::prelude::WidgetExt::set_direction(&*self.obj(), gtk::TextDirection::Ltr);

View file

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
DO NOT EDIT!
This file was @generated by blueprint-compiler. Instead, edit the
corresponding .blp file and regenerate this file with blueprint-compiler.
-->
<interface>
<requires lib="gtk" version="4.0"/>
<template class="HelvumPort" parent="GtkWidget">
<property name="hexpand">true</property>
<child>
<object class="GtkLabel" id="label">
<property name="wrap">true</property>
<property name="ellipsize">3</property>
<property name="lines">2</property>
<property name="max-width-chars">20</property>
</object>
</child>
<child>
<object class="GtkBox" id="handle_container">
<property name="halign">3</property>
<property name="valign">3</property>
</object>
</child>
</template>
</interface>

View file

@ -1,84 +0,0 @@
// Copyright 2021 Tom A. Wagner <tom.a.wagner@protonmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 3 as published by
// the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: GPL-3.0-only
use adw::{glib, gtk, prelude::*, subclass::prelude::*};
mod imp {
use super::*;
#[derive(Default)]
pub struct PortHandle {}
#[glib::object_subclass]
impl ObjectSubclass for PortHandle {
const NAME: &'static str = "HelvumPortHandle";
type Type = super::PortHandle;
type ParentType = gtk::Widget;
fn class_init(klass: &mut Self::Class) {
klass.set_css_name("port-handle");
}
}
impl ObjectImpl for PortHandle {
fn constructed(&self) {
self.parent_constructed();
let obj = &*self.obj();
obj.set_halign(gtk::Align::Center);
obj.set_valign(gtk::Align::Center);
}
}
impl WidgetImpl for PortHandle {
fn request_mode(&self) -> gtk::SizeRequestMode {
gtk::SizeRequestMode::ConstantSize
}
fn measure(&self, _orientation: gtk::Orientation, _for_size: i32) -> (i32, i32, i32, i32) {
(Self::HANDLE_SIZE, Self::HANDLE_SIZE, -1, -1)
}
}
impl PortHandle {
pub const HANDLE_SIZE: i32 = 14;
}
}
glib::wrapper! {
pub struct PortHandle(ObjectSubclass<imp::PortHandle>)
@extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
}
impl PortHandle {
pub fn new() -> Self {
glib::Object::new()
}
pub fn get_link_anchor(&self) -> gtk::graphene::Point {
gtk::graphene::Point::new(
imp::PortHandle::HANDLE_SIZE as f32 / 2.0,
imp::PortHandle::HANDLE_SIZE as f32 / 2.0,
)
}
}
impl Default for PortHandle {
fn default() -> Self {
Self::new()
}
}

View file

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
DO NOT EDIT!
This file was @generated by blueprint-compiler. Instead, edit the
corresponding .blp file and regenerate this file with blueprint-compiler.
-->
<interface>
<requires lib="gtk" version="4.0"/>
<template class="HelvumZoomEntry" parent="GtkBox">
<property name="spacing">12</property>
<child>
<object class="GtkEntry" id="entry">
<property name="secondary-icon-name">go-down-symbolic</property>
<property name="input-purpose">2</property>
<property name="max-width-chars">5</property>
<style>
<class name="osd"/>
<class name="rounded"/>
</style>
</object>
</child>
<child>
<object class="GtkButton" id="zoom_out_button">
<property name="icon-name">zoom-out-symbolic</property>
<property name="tooltip-text">Zoom out</property>
<style>
<class name="osd"/>
<class name="rounded"/>
</style>
</object>
</child>
<child>
<object class="GtkButton" id="zoom_in_button">
<property name="icon-name">zoom-in-symbolic</property>
<property name="tooltip-text">Zoom in</property>
<style>
<class name="osd"/>
<class name="rounded"/>
</style>
</object>
</child>
</template>
</interface>

View file

@ -1,55 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
DO NOT EDIT!
This file was @generated by blueprint-compiler. Instead, edit the
corresponding .blp file and regenerate this file with blueprint-compiler.
-->
<interface>
<requires lib="gtk" version="4.0"/>
<menu id="primary_menu">
<item>
<attribute name="label">_About Helvum</attribute>
<attribute name="action">app.about</attribute>
</item>
</menu>
<template class="HelvumWindow" parent="AdwApplicationWindow">
<property name="default-width">1280</property>
<property name="default-height">720</property>
<property name="title">Helvum - Pipewire Patchbay</property>
<child>
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar" id="header_bar">
<child type="end">
<object class="GtkMenuButton">
<property name="icon-name">open-menu-symbolic</property>
<property name="menu-model">primary_menu</property>
</object>
</child>
</object>
</child>
<property name="content">
<object class="GtkBox">
<property name="orientation">1</property>
<child>
<object class="AdwBanner" id="connection_banner">
<property name="title" translatable="yes">Disconnected</property>
<property name="revealed">false</property>
</object>
</child>
<child>
<object class="GtkOverlay" id="overlay">
<child>
<object class="GtkScrolledWindow" id="scrolled_window">
<property name="hexpand">true</property>
<property name="vexpand">true</property>
</object>
</child>
</object>
</child>
</object>
</property>
</object>
</child>
</template>
</interface>