Skip to content

Commit

Permalink
Merge branch 'gamma-dev' of https://github.com/aspectron/kaspa-ng int…
Browse files Browse the repository at this point in the history
…o gamma-dev
  • Loading branch information
surinder83singh committed Sep 12, 2024
2 parents 5b54b54 + de6d2cb commit ff44953
Show file tree
Hide file tree
Showing 6 changed files with 374 additions and 174 deletions.
2 changes: 2 additions & 0 deletions core/resources/i18n/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -3364,6 +3364,7 @@
"Presets": "Presets",
"Price": "Price",
"Priority": "Priority",
"Priority Fee Estimator": "Priority Fee Estimator",
"Private Key Mnemonic": "Private Key Mnemonic",
"Processed Bodies": "Processed Bodies",
"Processed Dependencies": "Processed Dependencies",
Expand Down Expand Up @@ -3470,6 +3471,7 @@
"Total Tx": "Total Tx",
"Total Tx/s": "Total Tx/s",
"Track in the background": "Track in the background",
"Transaction Fee Estimator": "Transaction Fee Estimator",
"Transaction Fees": "Transaction Fees",
"Transactions": "Transactions",
"Transactions:": "Transactions:",
Expand Down
60 changes: 29 additions & 31 deletions core/src/egui/selection_panels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl UILayoutExt for Ui {
}

type UiBuilderFn = Box<dyn FnOnce(&'_ mut Ui)>;
type FooterUiBuilderFn<V> = Box<dyn FnOnce(&'_ mut Ui, &'_ mut V)>;
// type FooterUiBuilderFn<V> = Box<dyn FnOnce(&'_ mut Ui, &'_ mut V)>;

pub struct SelectionPanel<V> {
pub title: WidgetText,
Expand Down Expand Up @@ -168,11 +168,11 @@ impl<Value: PartialEq> SelectionPanel<Value> {
}

pub struct SelectionPanels<V> {
pub title: WidgetText,
// pub title: WidgetText,
pub panel_min_width: f32,
pub panel_max_width: f32,
pub panels: Vec<SelectionPanel<V>>,
pub build_footer: FooterUiBuilderFn<V>,
// pub build_footer: FooterUiBuilderFn<V>,
pub panel_min_height: f32,
pub vertical: bool,
pub sep_ratio: f32,
Expand All @@ -182,14 +182,14 @@ impl<Value: PartialEq> SelectionPanels<Value> {
pub fn new(
panel_min_width: f32,
panel_max_width: f32,
title: impl Into<WidgetText>,
build_footer: impl FnOnce(&mut Ui, &mut Value) + 'static,
// title: impl Into<WidgetText>,
// build_footer: impl FnOnce(&mut Ui, &mut Value) + 'static,
) -> Self {
Self {
title: title.into(),
// title: title.into(),
panel_min_width,
panel_max_width,
build_footer: Box::new(build_footer),
// build_footer: Box::new(build_footer),
panels: vec![],
panel_min_height: 0.,
vertical: false,
Expand Down Expand Up @@ -264,25 +264,23 @@ impl<Value: PartialEq> SelectionPanels<Value> {

let add_contents = |ui: &mut Ui| {
let mut responce = ui.label(" ");
//ui.visuals_mut().override_text_color = Some(Color32::WHITE);
{
let available_width = ui.available_width() - indent;
let title = self.title.into_galley(
ui,
Some(TextWrapMode::Wrap),
available_width,
TextStyle::Heading,
);
let text_indent = (available_width - title.size().x) / 2.0;
let rect = ui.cursor().translate(Vec2::new(text_indent, 10.0));
ui.allocate_exact_size(
title.size() + Vec2::new(text_indent, 10.0),
Sense::focusable_noninteractive(),
);
// TODO @28
ui.painter().galley(rect.min, title, visuals.text_color());
// title.paint_with_fallback_color(ui.painter(), rect.min, text_color);
}

// {
// let available_width = ui.available_width() - indent;
// let title = self.title.into_galley(
// ui,
// Some(TextWrapMode::Wrap),
// available_width,
// TextStyle::Heading,
// );
// let text_indent = (available_width - title.size().x) / 2.0;
// let rect = ui.cursor().translate(Vec2::new(text_indent, 10.0));
// ui.allocate_exact_size(
// title.size() + Vec2::new(text_indent, 10.0),
// Sense::focusable_noninteractive(),
// );
// ui.painter().galley(rect.min, title, visuals.text_color());
// }

// ui.label(format!("before_wrap_width: {before_wrap_width}"));
// ui.label(format!("panel_width: {panel_width}"));
Expand Down Expand Up @@ -341,13 +339,13 @@ impl<Value: PartialEq> SelectionPanels<Value> {
responce
};

let mut response = ui
let response = ui
.indent_with_size("selection-panels", indent, Box::new(add_contents))
.response;
response |= ui
.vertical_centered(|ui| (self.build_footer)(ui, current_value))
.response;
ui.label(" ");
// response |= ui
// .vertical_centered(|ui| (self.build_footer)(ui, current_value))
// .response;
// ui.label(" ");
// ui.label(format!(" vertical: {vertical}"));
// ui.label(format!("panels_width {}", panels_width));
response
Expand Down
Loading

0 comments on commit ff44953

Please sign in to comment.