ui: update to egui 0.31

This commit is contained in:
ardocrat
2025-05-27 16:10:29 +03:00
parent 1987d0553c
commit 98619cc362
27 changed files with 896 additions and 585 deletions
Generated
+632 -359
View File
File diff suppressed because it is too large Load Diff
+12 -11
View File
@@ -45,8 +45,8 @@ grin_wallet_util = "5.3.3"
grin_wallet_controller = "5.3.3"
## ui
egui = { version = "0.29.1", default-features = false }
egui_extras = { version = "0.29.1", features = ["image", "svg"] }
egui = { version = "0.31.1", default-features = false }
egui_extras = { version = "0.31.1", features = ["image", "svg"] }
rust-i18n = "2.3.1"
## other
@@ -75,6 +75,7 @@ qrcode = "0.14.1"
ur = "0.4.1"
gif = "0.13.1"
rkv = { version = "0.19.0", features = ["lmdb"] }
usvg = "0.45.1"
## tor
arti-client = { version = "0.29.0", features = ["pt-client", "static", "onion-service-service", "onion-service-client"] }
@@ -110,23 +111,23 @@ nokhwa-mac = { git = "https://github.com/l1npengtul/nokhwa", rev = "612c861ef153
[target.'cfg(not(target_os = "android"))'.dependencies]
env_logger = "0.11.3"
winit = { version = "0.30.5" }
eframe = { version = "0.29.1", features = ["wgpu", "glow"] }
winit = { version = "0.30.7" }
eframe = { version = "0.31.1", features = ["wgpu", "glow"] }
arboard = "3.2.0"
rfd = "0.15.0"
interprocess = { version = "2.2.1", features = ["tokio"] }
[target.'cfg(target_os = "android")'.dependencies]
android_logger = "0.14.1"
android_logger = "0.15.0"
jni = "0.21.1"
wgpu = "22.1.0"
wgpu = "25.0.0"
android-activity = { version = "0.6.0", features = ["game-activity"] }
winit = { version = "0.30.5", features = ["android-game-activity"] }
eframe = { version = "0.29.1", features = ["wgpu", "android-game-activity"] }
winit = { version = "0.30.7", features = ["android-game-activity"] }
eframe = { version = "0.31.1", features = ["wgpu", "android-game-activity"] }
[patch.crates-io]
egui_extras = { git = "https://github.com/emilk/egui", rev = "5b846b4554fe47269affb43efef2cad8710a8a47" }
egui = { git = "https://github.com/emilk/egui", rev = "5b846b4554fe47269affb43efef2cad8710a8a47" }
eframe = { git = "https://github.com/emilk/egui", rev = "5b846b4554fe47269affb43efef2cad8710a8a47" }
egui_extras = { git = "https://github.com/ardocrat/egui", branch = "back_button_android" }
egui = { git = "https://github.com/ardocrat/egui", branch = "back_button_android" }
eframe = { git = "https://github.com/ardocrat/egui", branch = "back_button_android" }
### patch grin store
#grin_store = { path = "../grin-store" }
+14 -13
View File
@@ -14,7 +14,7 @@
use std::sync::atomic::{AtomicBool, Ordering};
use lazy_static::lazy_static;
use egui::{Align, Context, CursorIcon, Layout, Modifiers, ResizeDirection, Rounding, Stroke, UiBuilder, ViewportCommand};
use egui::{Align, Context, CornerRadius, CursorIcon, Layout, Modifiers, ResizeDirection, Stroke, UiBuilder, ViewportCommand, StrokeKind};
use egui::epaint::{RectShape};
use crate::AppConfig;
@@ -163,9 +163,10 @@ impl<Platform: PlatformCallbacks> App<Platform> {
r
};
let content_bg = RectShape::new(content_bg_rect,
Rounding::ZERO,
CornerRadius::ZERO,
Colors::fill_lite(),
View::default_stroke());
View::default_stroke(),
StrokeKind::Middle);
// Draw content background.
ui.painter().add(content_bg);
@@ -174,7 +175,7 @@ impl<Platform: PlatformCallbacks> App<Platform> {
content_rect = content_rect.shrink(Content::WINDOW_FRAME_MARGIN);
}
// Draw window content.
ui.allocate_new_ui(UiBuilder::new().max_rect(content_rect), |ui| {
ui.scope_builder(UiBuilder::new().max_rect(content_rect), |ui| {
// Draw window title.
self.window_title_ui(ui, is_fullscreen);
ui.add_space(-1.0);
@@ -217,7 +218,7 @@ impl<Platform: PlatformCallbacks> App<Platform> {
rect.max.y = rect.min.y + View::get_top_inset() + TitlePanel::HEIGHT;
rect
};
let title_bg = RectShape::filled(title_rect, Rounding::ZERO, Colors::yellow());
let title_bg = RectShape::filled(title_rect, CornerRadius::ZERO, Colors::yellow());
ui.painter().add(title_bg);
}
@@ -236,15 +237,15 @@ impl<Platform: PlatformCallbacks> App<Platform> {
};
let is_mac = egui::os::OperatingSystem::from_target_os() == egui::os::OperatingSystem::Mac;
let window_title_bg = RectShape::new(title_bg_rect, if is_fullscreen || is_mac {
Rounding::ZERO
CornerRadius::ZERO
} else {
Rounding {
nw: 8.0,
ne: 8.0,
sw: 0.0,
se: 0.0,
CornerRadius {
nw: 8.0 as u8,
ne: 8.0 as u8,
sw: 0.0 as u8,
se: 0.0 as u8,
}
}, Colors::yellow_dark(), Stroke::new(1.0, Colors::STROKE));
}, Colors::yellow_dark(), Stroke::new(1.0, Colors::STROKE), StrokeKind::Middle);
// Draw title background.
ui.painter().add(window_title_bg);
@@ -294,7 +295,7 @@ impl<Platform: PlatformCallbacks> App<Platform> {
Colors::title(true),
);
ui.allocate_new_ui(UiBuilder::new().max_rect(title_rect), |ui| {
ui.scope_builder(UiBuilder::new().max_rect(title_rect), |ui| {
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
// Draw button to close window.
View::title_button_small(ui, X, |_| {
+1 -1
View File
@@ -78,7 +78,7 @@ impl CameraContent {
r.min.x = r.max.x - 52.0;
r
};
ui.allocate_new_ui(UiBuilder::new().max_rect(r), |ui| {
ui.scope_builder(UiBuilder::new().max_rect(r), |ui| {
let rotate_img = CAMERA_ROTATE.to_string();
View::button(ui, rotate_img, Colors::white_or_black(false), || {
cb.switch_camera();
+6 -2
View File
@@ -15,7 +15,7 @@
use std::fs;
use std::sync::atomic::{AtomicBool, Ordering};
use egui::os::OperatingSystem;
use egui::{Align, Layout, RichText};
use egui::{Align, Layout, RichText, StrokeKind};
use lazy_static::lazy_static;
use crate::gui::Colors;
@@ -317,7 +317,11 @@ impl Content {
// Draw round background.
let bg_rect = rect.clone();
let item_rounding = View::item_rounding(index, len, false);
ui.painter().rect(bg_rect, item_rounding, Colors::fill(), View::item_stroke());
ui.painter().rect(bg_rect,
item_rounding,
Colors::fill(),
View::item_stroke(),
StrokeKind::Middle);
ui.allocate_ui_with_layout(rect.size(), Layout::right_to_left(Align::Center), |ui| {
// Draw button to select language.
+2 -3
View File
@@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use eframe::emath::Align;
use egui::{Layout, TextBuffer, TextStyle, Widget};
use egui::{Layout, TextBuffer, TextStyle, Widget, Align};
use egui::text_edit::TextEditState;
use crate::gui::Colors;
use crate::gui::icons::{CLIPBOARD_TEXT, COPY, EYE, EYE_SLASH, SCAN};
@@ -49,7 +48,7 @@ pub struct TextEdit {
impl TextEdit {
/// Default height of [`egui::TextEdit`] view.
const TEXT_EDIT_HEIGHT: f32 = 37.0;
const TEXT_EDIT_HEIGHT: f32 = 41.0;
pub fn new(id: egui::Id) -> Self {
Self {
+20 -22
View File
@@ -12,9 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use eframe::emath::Align;
use eframe::epaint::{Margin, Shadow};
use egui::{Align2, Button, Color32, CursorIcon, Layout, Rect, Response, RichText, Vec2, Widget};
use egui::{Align, Align2, Button, Color32, CursorIcon, Layout, Margin, Rect, Response, RichText, Shadow, Vec2, Widget};
use lazy_static::lazy_static;
use parking_lot::RwLock;
use std::sync::atomic::{AtomicBool, Ordering};
@@ -73,15 +71,15 @@ impl KeyboardContent {
.frame(egui::Frame {
shadow: Shadow {
offset: Default::default(),
blur: 30.0,
spread: 3.0,
blur: 30.0 as u8,
spread: 3.0 as u8,
color: Color32::from_black_alpha(32),
},
inner_margin: Margin {
left: View::get_left_inset(),
right: View::get_right_inset(),
top: 1.0,
bottom: View::get_bottom_inset(),
inner_margin: Margin {
left: View::get_left_inset() as i8,
right: View::get_right_inset() as i8,
top: 1.0 as i8,
bottom: View::get_bottom_inset() as i8,
},
fill: Colors::fill(),
..Default::default()
@@ -125,7 +123,7 @@ impl KeyboardContent {
KeyboardLayout::SYMBOLS => Self::symbols_ui(ui),
KeyboardLayout::NUMBERS => Self::numbers_ui(ui),
};
ui.add_space(2.0);
ui.add_space(1.0);
// Draw bottom keyboard buttons.
let bottom_size = {
@@ -141,7 +139,7 @@ impl KeyboardContent {
ui.allocate_ui_with_layout(bottom_size, Layout::right_to_left(Align::Center), |ui| {
if self.layout == KeyboardLayout::NUMBERS {
ui.horizontal_centered(|ui| {
ui.set_max_width(button_width * 2.0 + 1.0);
ui.set_max_width(button_width * 2.0);
Self::custom_button_ui(KEY_RETURN.to_string(),
Colors::white_or_black(false),
Some(Colors::green()),
@@ -161,7 +159,7 @@ impl KeyboardContent {
} else {
// Enter key input.
ui.horizontal_centered(|ui| {
ui.set_max_width(button_width * 2.0 + 1.0);
ui.set_max_width(button_width * 2.0);
Self::custom_button_ui(KEY_RETURN.to_string(),
Colors::white_or_black(false),
Some(Colors::green()),
@@ -255,7 +253,7 @@ impl KeyboardContent {
button_rect = Self::input_button_ui(s, !last, &mut columns[index]);
}
});
ui.add_space(2.0);
ui.add_space(1.0);
let tl_1: Vec<&str> = vec!["4", "5", "6", "+"];
ui.columns(tl_1.len(), |columns| {
@@ -264,7 +262,7 @@ impl KeyboardContent {
Self::input_button_ui(s, !last, &mut columns[index]);
}
});
ui.add_space(2.0);
ui.add_space(1.0);
let tl_2: Vec<&str> = vec!["7", "8", "9", BACKSPACE];
ui.columns(tl_2.len(), |columns| {
@@ -295,7 +293,7 @@ impl KeyboardContent {
button_rect = Self::input_button_ui(s, true, &mut columns[index]);
}
});
ui.add_space(2.0);
ui.add_space(1.0);
let tl_1: Vec<&str> = vec!["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "p1"];
ui.columns(tl_1.len(), |columns| {
@@ -303,7 +301,7 @@ impl KeyboardContent {
Self::input_button_ui(s, true, &mut columns[index]);
}
});
ui.add_space(2.0);
ui.add_space(1.0);
let tl_2: Vec<&str> = vec!["a", "s", "d", "f", "g", "h", "j", "k", "l", "l1", "l2"];
ui.columns(tl_2.len(), |columns| {
@@ -311,7 +309,7 @@ impl KeyboardContent {
Self::input_button_ui(s, true, &mut columns[index]);
}
});
ui.add_space(2.0);
ui.add_space(1.0);
let tl_3: Vec<&str> = vec!["z1", "z", "x", "c", "v", "b", "n", "m", "m1", "m2", "m3"];
ui.columns(tl_3.len(), |columns| {
@@ -332,7 +330,7 @@ impl KeyboardContent {
button_rect = Self::input_button_ui(s, false, &mut columns[index]);
}
});
ui.add_space(2.0);
ui.add_space(1.0);
let tl_1: Vec<&str> = vec!["_", "\\", "|", "~", "<", ">", "", "", "π", ""];
ui.columns(tl_1.len(), |columns| {
@@ -340,7 +338,7 @@ impl KeyboardContent {
Self::input_button_ui(s, false, &mut columns[index]);
}
});
ui.add_space(2.0);
ui.add_space(1.0);
let tl_2: Vec<&str> = vec!["-", "/", ":", ";", "(", ")", "`", "&", "@", "\""];
ui.columns(tl_2.len(), |columns| {
@@ -348,7 +346,7 @@ impl KeyboardContent {
Self::input_button_ui(s, false, &mut columns[index]);
}
});
ui.add_space(2.0);
ui.add_space(1.0);
let tl_3: Vec<&str> = vec![".", ",", "?", "!", "", "£", "¥", "$", "¢", ""];
ui.columns(tl_3.len(), |columns| {
@@ -385,7 +383,7 @@ impl KeyboardContent {
s.to_string()
};
let mut button = Button::new(RichText::new(label.clone()).size(17.0).color(color))
.rounding(egui::Rounding::ZERO);
.corner_radius(egui::CornerRadius::ZERO);
if let Some(bg) = bg {
button = button.fill(bg);
}
+26 -26
View File
@@ -12,17 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use lazy_static::lazy_static;
use std::sync::Arc;
use parking_lot::RwLock;
use std::sync::atomic::{AtomicBool, Ordering};
use egui::{Align2, RichText, Rounding, Stroke, UiBuilder, Vec2};
use egui::epaint::{RectShape, Shadow};
use egui::os::OperatingSystem;
use egui::{Align2, CornerRadius, RichText, Stroke, UiBuilder, Vec2, StrokeKind};
use lazy_static::lazy_static;
use parking_lot::RwLock;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use crate::gui::Colors;
use crate::gui::views::{Content, KeyboardContent, View};
use crate::gui::views::types::{ModalPosition, ModalState};
use crate::gui::views::{Content, KeyboardContent, View};
use crate::gui::Colors;
lazy_static! {
/// Showing [`Modal`] state to be accessible from different ui parts.
@@ -242,11 +242,11 @@ impl Modal {
.frame(egui::Frame {
shadow: Shadow {
offset: Default::default(),
blur: 30.0,
spread: 3.0,
blur: 30.0 as u8,
spread: 3.0 as u8,
color: egui::Color32::from_black_alpha(32),
},
rounding: Rounding::same(8.0),
corner_radius: CornerRadius::same(8.0 as u8),
..Default::default()
})
.show(ctx, |ui| {
@@ -301,20 +301,20 @@ impl Modal {
// Create background shape.
let mut bg_shape = RectShape::new(rect, if self.title.is_none() {
Rounding::same(8.0)
CornerRadius::same(8.0 as u8)
} else {
Rounding {
nw: 0.0,
ne: 0.0,
sw: 8.0,
se: 8.0,
CornerRadius {
nw: 0.0 as u8,
ne: 0.0 as u8,
sw: 8.0 as u8,
se: 8.0 as u8,
}
}, Colors::fill(), Stroke::NONE);
let bg_idx = ui.painter().add(bg_shape);
}, Colors::fill(), Stroke::NONE, StrokeKind::Middle);
let bg_idx = ui.painter().add(bg_shape.clone());
rect.min += egui::emath::vec2(6.0, 0.0);
rect.max -= egui::emath::vec2(6.0, 0.0);
let resp = ui.allocate_new_ui(UiBuilder::new().max_rect(rect), |ui| {
let resp = ui.scope_builder(UiBuilder::new().max_rect(rect), |ui| {
(add_content)(ui, self);
}).response;
@@ -335,13 +335,13 @@ fn title_ui(title: &String, ui: &mut egui::Ui) {
let rect = ui.available_rect_before_wrap();
// Create background shape.
let mut bg_shape = RectShape::new(rect, Rounding {
nw: 8.0,
ne: 8.0,
sw: 0.0,
se: 0.0,
}, Colors::yellow(), Stroke::NONE);
let bg_idx = ui.painter().add(bg_shape);
let mut bg_shape = RectShape::new(rect, CornerRadius {
nw: 8.0 as u8,
ne: 8.0 as u8,
sw: 0.0 as u8,
se: 0.0 as u8,
}, Colors::yellow(), Stroke::NONE, StrokeKind::Middle);
let bg_idx = ui.painter().add(bg_shape.clone());
// Draw title content.
let resp = ui.vertical_centered(|ui| {
+10 -6
View File
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use egui::{Align, Layout, RichText, Rounding};
use egui::{Align, Layout, RichText, CornerRadius, StrokeKind};
use crate::AppConfig;
use crate::gui::Colors;
@@ -113,7 +113,7 @@ impl ConnectionsContent {
View::item_button(ui, button_rounding, TRASH, None, || {
ConnectionsConfig::remove_ext_conn(conn.id);
});
View::item_button(ui, Rounding::default(), PENCIL, None, || {
View::item_button(ui, CornerRadius::default(), PENCIL, None, || {
self.show_add_ext_conn_modal(Some(conn.clone()));
});
});
@@ -128,7 +128,7 @@ impl ConnectionsContent {
let mut rect = ui.available_rect_before_wrap();
rect.set_height(78.0);
let rounding = View::item_rounding(0, 1, false);
ui.painter().rect(rect, rounding, Colors::fill(), View::item_stroke());
ui.painter().rect(rect, rounding, Colors::fill(), View::item_stroke(), StrokeKind::Middle);
ui.allocate_ui_with_layout(rect.size(), Layout::right_to_left(Align::Center), |ui| {
// Draw custom button.
@@ -137,11 +137,11 @@ impl ConnectionsContent {
// Draw buttons to start/stop node.
if Node::get_error().is_none() {
if !Node::is_running() {
View::item_button(ui, Rounding::default(), POWER, Some(Colors::green()), || {
View::item_button(ui, CornerRadius::default(), POWER, Some(Colors::green()), || {
Node::start();
});
} else if !Node::is_starting() && !Node::is_stopping() && !Node::is_restarting() {
View::item_button(ui, Rounding::default(), POWER, Some(Colors::red()), || {
View::item_button(ui, CornerRadius::default(), POWER, Some(Colors::red()), || {
Node::stop(false);
});
}
@@ -200,7 +200,11 @@ impl ConnectionsContent {
// Draw round background.
let bg_rect = rect.clone();
let item_rounding = View::item_rounding(index, len, false);
ui.painter().rect(bg_rect, item_rounding, Colors::fill(), View::item_stroke());
ui.painter().rect(bg_rect,
item_rounding,
Colors::fill(),
View::item_stroke(),
StrokeKind::Middle);
ui.allocate_ui_with_layout(rect.size(), Layout::right_to_left(Align::Center), |ui| {
// Draw provided buttons.
+12 -12
View File
@@ -58,10 +58,10 @@ impl NetworkContent {
.resizable(false)
.frame(egui::Frame {
inner_margin: Margin {
left: View::get_left_inset() + View::TAB_ITEMS_PADDING,
right: View::far_right_inset_margin(ui) + View::TAB_ITEMS_PADDING,
top: View::TAB_ITEMS_PADDING,
bottom: View::get_bottom_inset() + View::TAB_ITEMS_PADDING,
left: (View::get_left_inset() + View::TAB_ITEMS_PADDING) as i8,
right: (View::far_right_inset_margin(ui) + View::TAB_ITEMS_PADDING) as i8,
top: View::TAB_ITEMS_PADDING as i8,
bottom: (View::get_bottom_inset() + View::TAB_ITEMS_PADDING) as i8,
},
fill: Colors::fill(),
..Default::default()
@@ -94,10 +94,10 @@ impl NetworkContent {
egui::CentralPanel::default()
.frame(egui::Frame {
inner_margin: Margin {
left: View::get_left_inset() + 4.0,
right: View::far_right_inset_margin(ui) + 4.0,
top: 3.0,
bottom: 4.0,
left: (View::get_left_inset() + 4.0) as i8,
right: (View::far_right_inset_margin(ui) + 4.0) as i8,
top: 3.0 as i8,
bottom: 4.0 as i8,
},
..Default::default()
})
@@ -143,14 +143,14 @@ impl NetworkContent {
View::get_left_inset() + 4.0
} else {
0.0
},
} as i8,
right: if show_connections {
View::far_right_inset_margin(ui) + 4.0
} else {
0.0
},
top: 3.0,
bottom: 4.0 + View::get_bottom_inset(),
} as i8,
top: 3.0 as i8,
bottom:(4.0 + View::get_bottom_inset()) as i8,
},
..Default::default()
})
+7 -3
View File
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use egui::{RichText, Rounding, ScrollArea, vec2};
use egui::{RichText, CornerRadius, ScrollArea, vec2, StrokeKind};
use egui::scroll_area::ScrollBarVisibility;
use grin_core::consensus::{DAY_HEIGHT, GRIN_BASE, HOUR_SEC, REWARD};
use grin_servers::{DiffBlock, ServerStats};
@@ -138,7 +138,7 @@ fn blocks_ui(ui: &mut egui::Ui, stats: &ServerStats) {
}
/// Draw block difficulty item.
fn block_item_ui(ui: &mut egui::Ui, db: &DiffBlock, rounding: Rounding) {
fn block_item_ui(ui: &mut egui::Ui, db: &DiffBlock, rounding: CornerRadius) {
let mut rect = ui.available_rect_before_wrap();
rect.set_height(BLOCK_ITEM_HEIGHT);
ui.allocate_ui(rect.size(), |ui| {
@@ -150,7 +150,11 @@ fn block_item_ui(ui: &mut egui::Ui, db: &DiffBlock, rounding: Rounding) {
// Draw round background.
rect.min += vec2(8.0, 0.0);
rect.max -= vec2(8.0, 0.0);
ui.painter().rect(rect, rounding, Colors::white_or_black(false), View::item_stroke());
ui.painter().rect(rect,
rounding,
Colors::white_or_black(false),
View::item_stroke(),
StrokeKind::Middle);
// Draw block hash.
ui.horizontal(|ui| {
+7 -3
View File
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use egui::{RichText, Rounding, ScrollArea};
use egui::{RichText, CornerRadius, ScrollArea, StrokeKind};
use egui::scroll_area::ScrollBarVisibility;
use grin_chain::SyncStatus;
use grin_servers::WorkerStats;
@@ -190,13 +190,17 @@ impl NodeTab for NetworkMining {
const WORKER_ITEM_HEIGHT: f32 = 76.0;
/// Draw worker statistics item.
fn worker_item_ui(ui: &mut egui::Ui, ws: &WorkerStats, rounding: Rounding) {
fn worker_item_ui(ui: &mut egui::Ui, ws: &WorkerStats, rounding: CornerRadius) {
ui.horizontal_wrapped(|ui| {
ui.vertical_centered_justified(|ui| {
// Draw round background.
let mut rect = ui.available_rect_before_wrap();
rect.set_height(WORKER_ITEM_HEIGHT);
ui.painter().rect(rect, rounding, Colors::white_or_black(false), View::item_stroke());
ui.painter().rect(rect,
rounding,
Colors::white_or_black(false),
View::item_stroke(),
StrokeKind::Middle);
ui.add_space(2.0);
ui.horizontal(|ui| {
+3 -3
View File
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use egui::{RichText, Rounding, ScrollArea};
use egui::{RichText, CornerRadius, ScrollArea, StrokeKind};
use egui::scroll_area::ScrollBarVisibility;
use grin_servers::PeerStats;
@@ -176,7 +176,7 @@ fn node_stats_ui(ui: &mut egui::Ui) {
const PEER_ITEM_HEIGHT: f32 = 77.0;
/// Draw connected peer info item.
fn peer_item_ui(ui: &mut egui::Ui, peer: &PeerStats, rounding: Rounding) {
fn peer_item_ui(ui: &mut egui::Ui, peer: &PeerStats, rounding: CornerRadius) {
let mut rect = ui.available_rect_before_wrap();
rect.set_height(PEER_ITEM_HEIGHT);
ui.allocate_ui(rect.size(), |ui| {
@@ -184,7 +184,7 @@ fn peer_item_ui(ui: &mut egui::Ui, peer: &PeerStats, rounding: Rounding) {
ui.add_space(4.0);
// Draw round background.
ui.painter().rect(rect, rounding, Colors::fill_lite(), View::item_stroke());
ui.painter().rect(rect, rounding, Colors::fill_lite(), View::item_stroke(), StrokeKind::Middle);
// Draw IP address.
ui.horizontal(|ui| {
+6 -2
View File
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use egui::{Align, Id, Layout, RichText};
use egui::{Align, Id, Layout, RichText, StrokeKind};
use grin_core::global::ChainTypes;
use crate::AppConfig;
@@ -775,7 +775,11 @@ fn peer_item_ui(ui: &mut egui::Ui,
let mut bg_rect = rect.clone();
bg_rect.min += egui::emath::vec2(6.0, 0.0);
let item_rounding = View::item_rounding(index, len, false);
ui.painter().rect(bg_rect, item_rounding, Colors::white_or_black(false), View::item_stroke());
ui.painter().rect(bg_rect,
item_rounding,
Colors::white_or_black(false),
View::item_stroke(),
StrokeKind::Middle);
ui.vertical(|ui| {
ui.allocate_ui_with_layout(rect.size(), Layout::right_to_left(Align::Center), |ui| {
+5 -4
View File
@@ -237,14 +237,15 @@ impl QrCodeContent {
// Create background shape.
let mut bg_shape = RectShape::new(
rect,
egui::Rounding::default(),
egui::CornerRadius::default(),
egui::Color32::WHITE,
egui::Stroke::NONE
egui::Stroke::NONE,
egui::StrokeKind::Outside
);
let bg_idx = ui.painter().add(bg_shape);
let bg_idx = ui.painter().add(bg_shape.clone());
// Draw QR code image content.
let mut content_rect = ui.allocate_new_ui(UiBuilder::new().max_rect(rect), |ui| {
let mut content_rect = ui.scope_builder(UiBuilder::new().max_rect(rect), |ui| {
ui.add_space(10.0);
let size = SizeHint::Size(ui.available_width() as u32, ui.available_width() as u32);
self.texture_handle = Some(View::svg_image(ui, "qr_code", svg.as_slice(), Some(size)));
+8 -19
View File
@@ -16,7 +16,7 @@ use egui::{Margin, Id, Layout, Align, UiBuilder};
use crate::gui::Colors;
use crate::gui::views::{Content, View};
use crate::gui::views::types::{LinePosition, TitleContentType, TitleType};
use crate::gui::views::types::{TitleContentType, TitleType};
/// Title panel with left/right action buttons and text in the middle.
pub struct TitlePanel {
@@ -46,10 +46,10 @@ impl TitlePanel {
.exact_height(Self::HEIGHT + View::get_top_inset())
.frame(egui::Frame {
inner_margin: Margin {
left: View::far_left_inset_margin(ui),
right: View::far_right_inset_margin(ui),
top: View::get_top_inset(),
bottom: 0.0,
left: View::far_left_inset_margin(ui) as i8,
right: View::far_right_inset_margin(ui) as i8,
top: View::get_top_inset() as i8,
bottom: 0.0 as i8,
},
..Default::default()
})
@@ -72,7 +72,7 @@ impl TitlePanel {
r.max.x -= Self::HEIGHT;
r
};
ui.allocate_new_ui(UiBuilder::new().max_rect(content_rect), |ui| {
ui.scope_builder(UiBuilder::new().max_rect(content_rect), |ui| {
Self::title_text_content(ui, content);
});
}
@@ -84,7 +84,7 @@ impl TitlePanel {
r
};
// Draw first title content.
ui.allocate_new_ui(UiBuilder::new().max_rect(first_rect), |ui| {
ui.scope_builder(UiBuilder::new().max_rect(first_rect), |ui| {
Self::title_text_content(ui, first);
});
@@ -95,23 +95,12 @@ impl TitlePanel {
r
};
// Draw second title content.
ui.allocate_new_ui(UiBuilder::new().max_rect(second_rect), |ui| {
ui.scope_builder(UiBuilder::new().max_rect(second_rect), |ui| {
Self::title_text_content(ui, second);
});
}
}
});
// Draw content divider line.
let r = {
let mut r = rect.clone();
r.min.x -= View::far_left_inset_margin(ui);
r.max.x += View::far_right_inset_margin(ui);
r
};
if Content::is_dual_panel_mode(ui.ctx()) {
View::line(ui, LinePosition::BOTTOM, &r, Colors::stroke());
}
});
}
+24 -23
View File
@@ -16,11 +16,12 @@ use lazy_static::lazy_static;
use std::sync::atomic::{AtomicI32, Ordering};
use egui::epaint::text::TextWrapping;
use egui::epaint::{Color32, FontId, PathShape, PathStroke, RectShape, Rounding, Stroke};
use egui::epaint::{Color32, FontId, PathShape, PathStroke, RectShape, Stroke};
use egui::load::SizedTexture;
use egui::os::OperatingSystem;
use egui::text::{LayoutJob, TextFormat};
use egui::{lerp, Button, CursorIcon, PointerState, Rect, Response, Rgba, RichText, Sense, SizeHint, Spinner, TextureHandle, TextureOptions, UiBuilder, Widget};
use egui::{lerp, Button, CornerRadius, CursorIcon, PointerState, Rect, Response, Rgba, RichText, Sense, SizeHint, Spinner, StrokeKind, TextureHandle, TextureOptions, UiBuilder, Widget};
use egui::emath::GuiRounding;
use egui_extras::image::load_svg_bytes_with_size;
use crate::gui::icons::{CHECK_SQUARE, SQUARE};
@@ -187,7 +188,7 @@ impl View {
ui.style_mut().visuals.widgets.inactive.bg_stroke = Stroke::NONE;
ui.style_mut().visuals.widgets.hovered.bg_stroke = Stroke::NONE;
ui.style_mut().visuals.widgets.active.bg_stroke = Stroke::NONE;
ui.style_mut().visuals.widgets.active.rounding = Rounding::default();
ui.style_mut().visuals.widgets.active.corner_radius = CornerRadius::default();
ui.style_mut().visuals.widgets.active.expansion = 0.0;
// Setup text.
@@ -310,7 +311,7 @@ impl View {
/// Draw list item [`Button`] with provided rounding.
pub fn item_button(ui: &mut egui::Ui,
rounding: Rounding,
rounding: CornerRadius,
text: &'static str,
color: Option<Color32>,
action: impl FnOnce()) {
@@ -339,7 +340,7 @@ impl View {
// Show button.
let br = Button::new(RichText::new(text).size(20.0).color(text_color))
.rounding(rounding)
.corner_radius(rounding)
.min_size(button_size)
.ui(ui)
.on_hover_cursor(CursorIcon::PointingHand);
@@ -360,7 +361,7 @@ impl View {
}
/// Calculate item background/button rounding based on item index.
pub fn item_rounding(index: usize, len: usize, is_button: bool) -> Rounding {
pub fn item_rounding(index: usize, len: usize, is_button: bool) -> CornerRadius {
let corners = if is_button {
if len == 1 {
[false, true, true, false]
@@ -382,11 +383,11 @@ impl View {
[false, false, false, false]
}
};
Rounding {
nw: if corners[0] { 8.0 } else { 0.0 },
ne: if corners[1] { 8.0 } else { 0.0 },
sw: if corners[3] { 8.0 } else { 0.0 },
se: if corners[2] { 8.0 } else { 0.0 },
CornerRadius {
nw: if corners[0] { 8.0 as u8 } else { 0.0 as u8 },
ne: if corners[1] { 8.0 as u8 } else { 0.0 as u8 },
sw: if corners[3] { 8.0 as u8 } else { 0.0 as u8 },
se: if corners[2] { 8.0 as u8 } else { 0.0 as u8 },
}
}
@@ -398,16 +399,16 @@ impl View {
let rect = ui.available_rect_before_wrap();
// Create background shape.
let mut bg_shape = RectShape::new(rect, Rounding {
nw: if r[0] { 8.0 } else { 0.0 },
ne: if r[1] { 8.0 } else { 0.0 },
sw: if r[2] { 8.0 } else { 0.0 },
se: if r[3] { 8.0 } else { 0.0 },
}, Colors::fill_lite(), Self::item_stroke());
let bg_idx = ui.painter().add(bg_shape);
let mut bg_shape = RectShape::new(rect, CornerRadius {
nw: if r[0] { 8.0 as u8 } else { 0.0 as u8 },
ne: if r[1] { 8.0 as u8 } else { 0.0 as u8 },
sw: if r[2] { 8.0 as u8 } else { 0.0 as u8 },
se: if r[3] { 8.0 as u8 } else { 0.0 as u8 },
}, Colors::fill_lite(), Self::item_stroke(), StrokeKind::Middle);
let bg_idx = ui.painter().add(bg_shape.clone());
// Draw box content.
let content_resp = ui.allocate_new_ui(UiBuilder::new().max_rect(rect), |ui| {
let content_resp = ui.scope_builder(UiBuilder::new().max_rect(rect), |ui| {
ui.vertical_centered_justified(|ui| {
ui.add_space(4.0);
ui.scope(|ui| {
@@ -447,7 +448,7 @@ impl View {
let side_margin = 28.0;
rect.min += egui::emath::vec2(side_margin, ui.available_height() / 2.0 - height / 2.0);
rect.max -= egui::emath::vec2(side_margin, 0.0);
ui.allocate_new_ui(UiBuilder::new().max_rect(rect), |ui| {
ui.scope_builder(UiBuilder::new().max_rect(rect), |ui| {
(content)(ui);
});
});
@@ -506,7 +507,7 @@ impl View {
let (line_rect, _) = ui.allocate_exact_size(line_size, Sense::hover());
let painter = ui.painter();
painter.hline(line_rect.x_range(),
painter.round_to_pixel(line_rect.center().y),
line_rect.center().y.round_to_pixels(painter.pixels_per_point()),
Stroke { width: 1.0, color });
}
@@ -556,7 +557,7 @@ impl View {
name: &str,
svg: &[u8],
size: Option<SizeHint>) -> TextureHandle {
let color_img = load_svg_bytes_with_size(svg, size).unwrap();
let color_img = load_svg_bytes_with_size(svg, size, &usvg::Options::default()).unwrap();
// Create image texture.
let texture_handle = ui.ctx().load_texture(name,
color_img.clone(),
@@ -605,7 +606,7 @@ impl View {
if resp.clicked() || resp.dragged() {
on_click();
}
let shape = RectShape::filled(resp.rect, Rounding::ZERO, Colors::semi_transparent());
let shape = RectShape::filled(resp.rect, CornerRadius::ZERO, Colors::semi_transparent());
ui.painter().add(shape);
}
+15 -15
View File
@@ -13,7 +13,7 @@
// limitations under the License.
use std::time::Duration;
use egui::{Align, Id, Layout, Margin, RichText, Rounding, ScrollArea};
use egui::{Align, CornerRadius, Id, Layout, Margin, RichText, ScrollArea, StrokeKind};
use egui::scroll_area::ScrollBarVisibility;
use crate::AppConfig;
@@ -182,10 +182,10 @@ impl WalletsContent {
egui::TopBottomPanel::bottom("wallets_bottom_panel")
.frame(egui::Frame {
inner_margin: Margin {
left: View::far_left_inset_margin(ui) + View::TAB_ITEMS_PADDING,
right: View::far_right_inset_margin(ui) + View::TAB_ITEMS_PADDING,
top: View::TAB_ITEMS_PADDING,
bottom: View::get_bottom_inset() + View::TAB_ITEMS_PADDING,
left: (View::far_left_inset_margin(ui) + View::TAB_ITEMS_PADDING) as i8,
right: (View::far_right_inset_margin(ui) + View::TAB_ITEMS_PADDING) as i8,
top: View::TAB_ITEMS_PADDING as i8,
bottom: (View::get_bottom_inset() + View::TAB_ITEMS_PADDING) as i8,
},
fill: Colors::fill(),
..Default::default()
@@ -226,10 +226,10 @@ impl WalletsContent {
.resizable(false)
.frame(egui::Frame {
inner_margin: Margin {
left: View::far_left_inset_margin(ui) + 4.0,
right: View::far_right_inset_margin(ui) + 4.0,
top: 3.0,
bottom: 4.0,
left: (View::far_left_inset_margin(ui) + 4.0) as i8,
right: (View::far_right_inset_margin(ui) + 4.0) as i8,
top: 3.0 as i8,
bottom: 4.0 as i8,
},
fill: Colors::fill_deep(),
..Default::default()
@@ -536,12 +536,12 @@ impl WalletsContent {
let mut rect = ui.available_rect_before_wrap();
rect.set_height(78.0);
let rounding = View::item_rounding(0, 1, false);
let (bg, stroke) = if current {
(Colors::fill_deep(), View::item_stroke())
let bg = if current {
Colors::fill_deep()
} else {
(Colors::fill(), View::hover_stroke())
Colors::fill()
};
ui.painter().rect(rect, rounding, bg, stroke);
ui.painter().rect(rect, rounding, bg, View::item_stroke(), StrokeKind::Middle);
ui.allocate_ui_with_layout(rect.size(), Layout::right_to_left(Align::Center), |ui| {
if !wallet.is_open() {
@@ -551,7 +551,7 @@ impl WalletsContent {
});
if !wallet.syncing() {
let mut show_selection = false;
View::item_button(ui, Rounding::default(), GLOBE, None, || {
View::item_button(ui, CornerRadius::default(), GLOBE, None, || {
self.wallet_content = Some(WalletContent::new(wallet.clone(), None));
self.conn_selection_content = Some(
WalletConnectionModal::new(wallet.get_current_connection())
@@ -577,7 +577,7 @@ impl WalletsContent {
// Show button to close opened wallet.
if !wallet.is_closing() {
View::item_button(ui, if !current {
Rounding::default()
CornerRadius::default()
} else {
View::item_rounding(0, 1, true)
}, LOCK_KEY, None, || {
+8 -8
View File
@@ -115,10 +115,10 @@ impl WalletCreation {
egui::TopBottomPanel::bottom("wallet_creation_step_panel")
.frame(egui::Frame {
inner_margin: Margin {
left: View::far_left_inset_margin(ui) + View::TAB_ITEMS_PADDING,
right: View::get_right_inset() + View::TAB_ITEMS_PADDING,
top: View::TAB_ITEMS_PADDING,
bottom: View::get_bottom_inset() + View::TAB_ITEMS_PADDING,
left: (View::far_left_inset_margin(ui) + View::TAB_ITEMS_PADDING) as i8,
right: (View::get_right_inset() + View::TAB_ITEMS_PADDING) as i8,
top: View::TAB_ITEMS_PADDING as i8,
bottom: (View::get_bottom_inset() + View::TAB_ITEMS_PADDING) as i8,
},
fill: Colors::fill_deep(),
..Default::default()
@@ -143,10 +143,10 @@ impl WalletCreation {
egui::CentralPanel::default()
.frame(egui::Frame {
inner_margin: Margin {
left: View::far_left_inset_margin(ui) + 4.0,
right: View::get_right_inset() + 4.0,
top: 3.0,
bottom: 4.0,
left: (View::far_left_inset_margin(ui) + 4.0) as i8,
right: (View::get_right_inset() + 4.0) as i8,
top: 3.0 as i8,
bottom: 4.0 as i8,
},
..Default::default()
})
+6 -2
View File
@@ -13,7 +13,7 @@
// limitations under the License.
use egui::scroll_area::ScrollBarVisibility;
use egui::{Align, Layout, RichText, ScrollArea};
use egui::{Align, Layout, RichText, ScrollArea, StrokeKind};
use crate::gui::Colors;
use crate::gui::icons::{CHECK, CHECK_FAT, COMPUTER_TOWER, FOLDER_OPEN, GLOBE_SIMPLE, PLUGS_CONNECTED};
@@ -108,7 +108,11 @@ impl WalletsModal {
let mut rect = ui.available_rect_before_wrap();
rect.set_height(78.0);
let rounding = View::item_rounding(0, 1, false);
ui.painter().rect(rect, rounding, Colors::fill(), View::hover_stroke());
ui.painter().rect(rect,
rounding,
Colors::fill(),
View::hover_stroke(),
StrokeKind::Middle);
ui.allocate_ui_with_layout(rect.size(), Layout::right_to_left(Align::Center), |ui| {
if self.can_open {
+18 -14
View File
@@ -13,7 +13,7 @@
// limitations under the License.
use std::time::Duration;
use egui::{Align, Id, Layout, Margin, RichText, ScrollArea};
use egui::{Align, Id, Layout, Margin, RichText, ScrollArea, StrokeKind};
use egui::scroll_area::ScrollBarVisibility;
use grin_chain::SyncStatus;
use grin_core::core::amount_to_hr_string;
@@ -123,10 +123,10 @@ impl WalletContent {
egui::TopBottomPanel::top(Id::from("wallet_account").with(wallet.identifier()))
.frame(egui::Frame {
inner_margin: Margin {
left: View::far_left_inset_margin(ui) + 4.0,
right: View::get_right_inset() + 4.0,
top: 4.0,
bottom: 0.0,
left: (View::far_left_inset_margin(ui) + 4.0) as i8,
right: (View::get_right_inset() + 4.0) as i8,
top: 4.0 as i8,
bottom: 0.0 as i8,
},
fill: Colors::fill(),
..Default::default()
@@ -185,10 +185,10 @@ impl WalletContent {
egui::TopBottomPanel::bottom("wallet_tabs")
.frame(egui::Frame {
inner_margin: Margin {
left: View::far_left_inset_margin(ui) + View::TAB_ITEMS_PADDING,
right: View::get_right_inset() + View::TAB_ITEMS_PADDING,
top: View::TAB_ITEMS_PADDING,
bottom: View::get_bottom_inset() + View::TAB_ITEMS_PADDING,
left: (View::far_left_inset_margin(ui) + View::TAB_ITEMS_PADDING) as i8,
right: (View::get_right_inset() + View::TAB_ITEMS_PADDING) as i8,
top: View::TAB_ITEMS_PADDING as i8,
bottom: (View::get_bottom_inset() + View::TAB_ITEMS_PADDING) as i8,
},
fill: Colors::fill(),
..Default::default()
@@ -214,10 +214,10 @@ impl WalletContent {
egui::CentralPanel::default()
.frame(egui::Frame {
inner_margin: Margin {
left: View::far_left_inset_margin(ui) + 4.0,
right: View::get_right_inset() + 4.0,
top: 0.0,
bottom: 4.0,
left: (View::far_left_inset_margin(ui) + 4.0) as i8,
right: (View::get_right_inset() + 4.0) as i8,
top: 0.0 as i8,
bottom: 4.0 as i8,
},
..Default::default()
})
@@ -287,7 +287,11 @@ impl WalletContent {
rect.set_height(75.0);
// Draw round background.
let rounding = View::item_rounding(0, 2, false);
ui.painter().rect(rect, rounding, Colors::fill_lite(), View::item_stroke());
ui.painter().rect(rect,
rounding,
Colors::fill_lite(),
View::item_stroke(),
StrokeKind::Middle);
ui.allocate_ui_with_layout(rect.size(), Layout::right_to_left(Align::Center), |ui| {
// Draw button to show QR code scanner.
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use egui::{Align, Id, Layout, RichText, ScrollArea};
use egui::{Align, Id, Layout, RichText, ScrollArea, StrokeKind};
use egui::scroll_area::ScrollBarVisibility;
use grin_core::core::amount_to_hr_string;
@@ -187,7 +187,11 @@ fn account_item_ui(ui: &mut egui::Ui,
// Draw round background.
let bg_rect = rect.clone();
let item_rounding = View::item_rounding(index, size, false);
ui.painter().rect(bg_rect, item_rounding, Colors::fill(), View::item_stroke());
ui.painter().rect(bg_rect,
item_rounding,
Colors::fill(),
View::item_stroke(),
StrokeKind::Middle);
ui.vertical(|ui| {
ui.allocate_ui_with_layout(rect.size(), Layout::right_to_left(Align::Center), |ui| {
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use egui::{Align, Layout, RichText};
use egui::{Align, Layout, RichText, StrokeKind};
use crate::gui::Colors;
use crate::gui::icons::{CHECK, CHECK_CIRCLE, CHECK_FAT, DOTS_THREE_CIRCLE, GLOBE, GLOBE_SIMPLE, PLUS_CIRCLE, X_CIRCLE};
@@ -190,7 +190,11 @@ impl ConnectionSettings {
// Draw round background.
let bg_rect = rect.clone();
let item_rounding = View::item_rounding(index, len, false);
ui.painter().rect(bg_rect, item_rounding, Colors::fill(), View::item_stroke());
ui.painter().rect(bg_rect,
item_rounding,
Colors::fill(),
View::item_stroke(),
StrokeKind::Middle);
ui.vertical(|ui| {
ui.allocate_ui_with_layout(rect.size(), Layout::right_to_left(Align::Center), |ui| {
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use egui::{Align, Layout, RichText, Rounding};
use egui::{Align, CornerRadius, Layout, RichText, StrokeKind};
use crate::gui::Colors;
use crate::gui::icons::{CHECK_CIRCLE, COPY, DOTS_THREE_CIRCLE, EXPORT, GEAR_SIX, GLOBE_SIMPLE, POWER, QR_CODE, SHIELD_CHECKERED, SHIELD_SLASH, WARNING_CIRCLE, X_CIRCLE};
@@ -148,7 +148,11 @@ impl WalletTransport {
// Draw round background.
let bg_rect = rect.clone();
let item_rounding = View::item_rounding(0, 2, false);
ui.painter().rect(bg_rect, item_rounding, Colors::fill_lite(), View::item_stroke());
ui.painter().rect(bg_rect,
item_rounding,
Colors::fill_lite(),
View::item_stroke(),
StrokeKind::Middle);
ui.vertical(|ui| {
ui.allocate_ui_with_layout(rect.size(), Layout::right_to_left(Align::Center), |ui| {
@@ -168,14 +172,14 @@ impl WalletTransport {
let service_id = &wallet.identifier();
if !Tor::is_service_starting(service_id) && wallet.foreign_api_port().is_some() {
if !Tor::is_service_running(service_id) {
View::item_button(ui, Rounding::default(), POWER, Some(Colors::green()), || {
View::item_button(ui, CornerRadius::default(), POWER, Some(Colors::green()), || {
if let Ok(key) = wallet.secret_key() {
let api_port = wallet.foreign_api_port().unwrap();
Tor::start_service(api_port, key, service_id);
}
});
} else {
View::item_button(ui, Rounding::default(), POWER, Some(Colors::red()), || {
View::item_button(ui, CornerRadius::default(), POWER, Some(Colors::red()), || {
Tor::stop_service(service_id);
});
}
@@ -254,7 +258,11 @@ impl WalletTransport {
} else {
View::item_rounding(1, 2, false)
};
ui.painter().rect(bg_rect, item_rounding, Colors::fill_lite(), View::item_stroke());
ui.painter().rect(bg_rect,
item_rounding,
Colors::fill_lite(),
View::item_stroke(),
StrokeKind::Middle);
ui.vertical(|ui| {
ui.allocate_ui_with_layout(rect.size(), Layout::right_to_left(Align::Center), |ui| {
@@ -274,7 +282,7 @@ impl WalletTransport {
});
// Show button to enable/disable Tor listener for current wallet.
View::item_button(ui, Rounding::default(), COPY, None, || {
View::item_button(ui, CornerRadius::default(), COPY, None, || {
cb.copy_string_to_buffer(addr.clone());
});
@@ -338,7 +346,11 @@ impl WalletTransport {
// Draw round background.
let bg_rect = rect.clone();
let item_rounding = View::item_rounding(1, 2, false);
ui.painter().rect(bg_rect, item_rounding, Colors::fill(), View::item_stroke());
ui.painter().rect(bg_rect,
item_rounding,
Colors::fill(),
View::item_stroke(),
StrokeKind::Middle);
ui.vertical(|ui| {
ui.allocate_ui_with_layout(rect.size(), Layout::top_down(Align::Center), |ui| {
+13 -13
View File
@@ -14,7 +14,7 @@
use std::ops::Range;
use std::time::{SystemTime, UNIX_EPOCH};
use egui::{Align, Id, Layout, Rect, RichText, Rounding, ScrollArea};
use egui::{Align, Id, Layout, Rect, RichText, CornerRadius, ScrollArea, StrokeKind};
use egui::epaint::RectShape;
use egui::scroll_area::ScrollBarVisibility;
use grin_core::consensus::COINBASE_MATURITY;
@@ -155,15 +155,15 @@ impl WalletTransactions {
// Draw tx item background.
let mut r = View::item_rounding(index, txs.len(), false);
let p = ui.painter();
p.rect(rect, r, Colors::fill_lite(), View::item_stroke());
p.rect(rect, r, Colors::fill_lite(), View::item_stroke(), StrokeKind::Middle);
let tx = txs.get(index).unwrap();
let data = wallet.get_data().unwrap();
Self::tx_item_ui(ui, tx, rect, &data, |ui| {
// Draw button to show transaction info.
if tx.data.tx_slate_id.is_some() {
r.nw = 0.0;
r.sw = 0.0;
r.nw = 0.0 as u8;
r.sw = 0.0 as u8;
View::item_button(ui, r, FILE_TEXT, None, || {
self.show_tx_info_modal(wallet, tx, false);
});
@@ -174,7 +174,7 @@ impl WalletTransactions {
// Draw button to show transaction finalization.
if wallet_loaded && tx.can_finalize {
let (icon, color) = (CHECK, Some(Colors::green()));
View::item_button(ui, Rounding::default(), icon, color, || {
View::item_button(ui, CornerRadius::default(), icon, color, || {
self.show_tx_info_modal(wallet, tx, true);
});
}
@@ -182,7 +182,7 @@ impl WalletTransactions {
// Draw button to cancel transaction.
if wallet_loaded && tx.can_cancel() {
let (icon, color) = (PROHIBIT, Some(Colors::red()));
View::item_button(ui, Rounding::default(), icon, color, || {
View::item_button(ui, CornerRadius::default(), icon, color, || {
self.confirm_cancel_tx_id = Some(tx.data.id);
// Show transaction cancellation confirmation modal.
Modal::new(CANCEL_TX_CONFIRMATION_MODAL)
@@ -205,13 +205,13 @@ impl WalletTransactions {
}
let rect = ui.available_rect_before_wrap();
// Draw background.
let mut bg = RectShape::new(rect, Rounding {
nw: 0.0,
ne: 0.0,
sw: 8.0,
se: 8.0,
}, Colors::TRANSPARENT, View::item_stroke());
let bg_idx = ui.painter().add(bg);
let mut bg = RectShape::new(rect, CornerRadius {
nw: 0.0 as u8,
ne: 0.0 as u8,
sw: 8.0 as u8,
se: 8.0 as u8,
}, Colors::TRANSPARENT, View::item_stroke(), StrokeKind::Middle);
let bg_idx = ui.painter().add(bg.clone());
let resp = ui.allocate_ui(rect.size(), |ui| {
ui.vertical_centered_justified(|ui| {
// Correct vertical spacing between items.
+6 -6
View File
@@ -16,7 +16,7 @@ use std::thread;
use std::sync::Arc;
use parking_lot::RwLock;
use egui::scroll_area::ScrollBarVisibility;
use egui::{Align, Id, Layout, RichText, Rounding, ScrollArea};
use egui::{Align, Id, Layout, RichText, CornerRadius, ScrollArea, StrokeKind};
use grin_util::ToHex;
use grin_core::core::amount_to_hr_string;
use grin_wallet_libwallet::{Error, Slate, SlateState, TxLogEntryType};
@@ -230,7 +230,7 @@ impl WalletTransactionModal {
// Draw tx item background.
let p = ui.painter();
let r = View::item_rounding(0, 2, false);
p.rect(rect, r, Colors::TRANSPARENT, View::item_stroke());
p.rect(rect, r, Colors::TRANSPARENT, View::item_stroke(), StrokeKind::Middle);
// Show transaction amount status and time.
let data = wallet.get_data().unwrap();
@@ -274,7 +274,7 @@ impl WalletTransactionModal {
// Draw button to cancel transaction.
if wallet_loaded && tx.can_cancel() {
let r = if tx.can_finalize {
Rounding::default()
CornerRadius::default()
} else {
View::item_rounding(0, 2, true)
};
@@ -555,13 +555,13 @@ fn info_item_ui(ui: &mut egui::Ui,
let bg_rect = rect.clone();
let mut rounding = View::item_rounding(1, 3, false);
ui.painter().rect(bg_rect, rounding, Colors::fill(), View::item_stroke());
ui.painter().rect(bg_rect, rounding, Colors::fill(), View::item_stroke(), StrokeKind::Middle);
ui.allocate_ui_with_layout(rect.size(), Layout::right_to_left(Align::Center), |ui| {
// Draw button to copy transaction info value.
if copy {
rounding.nw = 0.0;
rounding.sw = 0.0;
rounding.nw = 0.0 as u8;
rounding.sw = 0.0 as u8;
View::item_button(ui, rounding, COPY, None, || {
cb.copy_string_to_buffer(value.clone());
});
+4 -4
View File
@@ -185,7 +185,7 @@ pub fn setup_fonts(ctx: &Context) {
fonts.font_data.insert(
"phosphor".to_owned(),
egui::FontData::from_static(include_bytes!(
Arc::new(egui::FontData::from_static(include_bytes!(
"../fonts/phosphor.ttf"
)).tweak(egui::FontTweak {
scale: 1.0,
@@ -193,7 +193,7 @@ pub fn setup_fonts(ctx: &Context) {
y_offset: 0.0,
baseline_offset_factor: 0.16,
}),
);
));
fonts
.families
.entry(Proportional)
@@ -202,7 +202,7 @@ pub fn setup_fonts(ctx: &Context) {
fonts.font_data.insert(
"noto".to_owned(),
egui::FontData::from_static(include_bytes!(
Arc::new(egui::FontData::from_static(include_bytes!(
"../fonts/noto_sc_reg.otf"
)).tweak(egui::FontTweak {
scale: 1.0,
@@ -210,7 +210,7 @@ pub fn setup_fonts(ctx: &Context) {
y_offset: 0.0,
baseline_offset_factor: 0.17,
}),
);
));
fonts
.families
.entry(Proportional)