add support for wrapping labels
This commit is contained in:
parent
7b90fdef75
commit
d8e64f28fb
5 changed files with 56 additions and 6 deletions
11
README.md
11
README.md
|
@ -16,6 +16,15 @@ layerrule = blur, worf
|
||||||
## Additional functionality compared to Wofi (planed)
|
## Additional functionality compared to Wofi (planed)
|
||||||
* Support passing 'hidden' parameters that are not visible in the launcher but will be returned to the application
|
* Support passing 'hidden' parameters that are not visible in the launcher but will be returned to the application
|
||||||
* Window switcher for hyprland
|
* Window switcher for hyprland
|
||||||
|
* All arguments expect show are supported by config and args
|
||||||
|
|
||||||
|
### New config / command line options
|
||||||
|
* fuzzy-length: Defines how long a string must be to be considered for fuzzy match
|
||||||
|
* row-box-orientation: Allows aligning values vertically to place the label below the icon
|
||||||
|
|
||||||
|
### New Styling options
|
||||||
|
* `label`: Allows styling the label
|
||||||
|
* `row`: Allows styling to row, mainly used to disable hover effects
|
||||||
|
|
||||||
## Breaking changes to Wofi
|
## Breaking changes to Wofi
|
||||||
* Runtime behaviour is not guaranteed to be the same and won't ever be, this includes error messages and themes.
|
* Runtime behaviour is not guaranteed to be the same and won't ever be, this includes error messages and themes.
|
||||||
|
@ -28,8 +37,6 @@ layerrule = blur, worf
|
||||||
* stylesheet -> use style instead
|
* stylesheet -> use style instead
|
||||||
* color / colors -> GTK4 does not support color files
|
* color / colors -> GTK4 does not support color files
|
||||||
|
|
||||||
## New options
|
|
||||||
* --fuzzy-length: Defines how long a string must be be
|
|
||||||
|
|
||||||
|
|
||||||
## Not supported
|
## Not supported
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crossbeam::channel::Sender;
|
||||||
use gdk4::gio::{File, Menu};
|
use gdk4::gio::{File, Menu};
|
||||||
use gdk4::glib::{GString, Propagation, Unichar};
|
use gdk4::glib::{GString, Propagation, Unichar};
|
||||||
use gdk4::prelude::{Cast, DisplayExt, ListModelExtManual, MonitorExt};
|
use gdk4::prelude::{Cast, DisplayExt, ListModelExtManual, MonitorExt};
|
||||||
use gdk4::{Display, Key};
|
use gdk4::{pango, Display, Key};
|
||||||
use gtk4::prelude::{
|
use gtk4::prelude::{
|
||||||
ApplicationExt, ApplicationExtManual, BoxExt, ButtonExt, EditableExt, EntryExt, FileChooserExt,
|
ApplicationExt, ApplicationExtManual, BoxExt, ButtonExt, EditableExt, EntryExt, FileChooserExt,
|
||||||
FlowBoxChildExt, GestureSingleExt, GtkWindowExt, ListBoxRowExt, NativeExt, OrientableExt,
|
FlowBoxChildExt, GestureSingleExt, GtkWindowExt, ListBoxRowExt, NativeExt, OrientableExt,
|
||||||
|
@ -143,8 +143,6 @@ fn build_ui(
|
||||||
inner_box.set_vexpand(false);
|
inner_box.set_vexpand(false);
|
||||||
if let Some(halign) = config.halign {
|
if let Some(halign) = config.halign {
|
||||||
inner_box.set_halign(halign.into());
|
inner_box.set_halign(halign.into());
|
||||||
} else {
|
|
||||||
inner_box.set_halign(Align::Fill);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(valign) = config.valign {
|
if let Some(valign) = config.valign {
|
||||||
|
@ -435,8 +433,11 @@ fn create_menu_row(
|
||||||
row_box.append(&image);
|
row_box.append(&image);
|
||||||
}
|
}
|
||||||
|
|
||||||
let label = Label::new(Some(&menu_item.label));
|
// todo make max length configurable
|
||||||
|
let label = Label::new(Some(&wrap_text(&menu_item.label, 15)));
|
||||||
label.set_hexpand(true);
|
label.set_hexpand(true);
|
||||||
|
label.set_widget_name("label");
|
||||||
|
label.set_wrap(true);
|
||||||
row_box.append(&label);
|
row_box.append(&label);
|
||||||
|
|
||||||
if config.content_halign.unwrap() == config::Align::Start
|
if config.content_halign.unwrap() == config::Align::Start
|
||||||
|
@ -547,3 +548,26 @@ pub fn initialize_sort_scores(items: &mut Vec<MenuItem>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn wrap_text(text: &str, line_length: usize) -> String {
|
||||||
|
let mut result = String::new();
|
||||||
|
let mut line = String::new();
|
||||||
|
|
||||||
|
for word in text.split_whitespace() {
|
||||||
|
if line.len() + word.len() + 1 > line_length {
|
||||||
|
if !line.is_empty() {
|
||||||
|
result.push_str(&line.trim_end());
|
||||||
|
result.push('\n');
|
||||||
|
line.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
line.push_str(word);
|
||||||
|
line.push(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
if !line.is_empty() {
|
||||||
|
result.push_str(&line.trim_end());
|
||||||
|
}
|
||||||
|
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
8
styles/launcher/config.toml
Normal file
8
styles/launcher/config.toml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
image_size=64
|
||||||
|
columns=6
|
||||||
|
orientation="Vertical"
|
||||||
|
row_bow_orientation="Vertical"
|
||||||
|
content_halign="Center"
|
||||||
|
height="70%"
|
||||||
|
width="60%"
|
||||||
|
valign="Start"
|
|
@ -45,15 +45,21 @@
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
margin: 1rem;
|
margin: 1rem;
|
||||||
border-radius: 0.5rem;
|
border-radius: 0.5rem;
|
||||||
|
border-bottom: 5px solid rgba(32, 32, 32, 0.1);
|
||||||
|
|
||||||
}
|
}
|
||||||
#window #outer-box #scroll #inner-box #entry #img {
|
#window #outer-box #scroll #inner-box #entry #img {
|
||||||
width: 1rem;
|
width: 1rem;
|
||||||
margin-right: 0.5rem;
|
margin-right: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
#window #outer-box #scroll #inner-box #entry:selected {
|
#window #outer-box #scroll #inner-box #entry:selected {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
background-color: rgba(255, 255, 255, 0.1);
|
background-color: rgba(255, 255, 255, 0.1);
|
||||||
outline: none;
|
outline: none;
|
||||||
|
border-bottom: 5px solid rgba(214, 174, 0, 1);
|
||||||
|
border-bottom-left-radius: 0;
|
||||||
|
border-bottom-right-radius: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#row:hover {
|
#row:hover {
|
||||||
|
@ -67,3 +73,8 @@
|
||||||
outline: inherit;
|
outline: inherit;
|
||||||
outline-color: inherit;
|
outline-color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#label {
|
||||||
|
margin-top: 1rem;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue