Skip to content

Commit

Permalink
Some styling
Browse files Browse the repository at this point in the history
  • Loading branch information
d0rianb committed Feb 14, 2022
1 parent 6c1c7e1 commit 47f5587
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/contextual_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,10 @@ impl ContextualMenu {
for (i, item) in self.items.iter().enumerate() {
let y = menu_origin.y + self.get_item_offset_y(i);
if item.action == MenuAction::Separator {
// Handle separators
// draw separators
const SEPARATOR_HEIGHT: f32 = 1.;
draw_rectangle(menu_origin.x + ITEM_PADDING * 3., y + item_height * SEPARATOR_HEIGHT_RATIO / 2. - SEPARATOR_HEIGHT / 2. + ITEM_PADDING / 2., width - ITEM_PADDING * 6., SEPARATOR_HEIGHT, *SEPARATOR_COLOR, graphics);
const SEPARATOR_PADDING_X: f32 = ITEM_PADDING * 1.5;
draw_rectangle(menu_origin.x + SEPARATOR_PADDING_X, y + item_height * SEPARATOR_HEIGHT_RATIO / 2. - SEPARATOR_HEIGHT / 2. + ITEM_PADDING / 2., width - SEPARATOR_PADDING_X*2., SEPARATOR_HEIGHT, *SEPARATOR_COLOR, graphics);
continue;
}
// draw highlight
Expand Down
5 changes: 4 additions & 1 deletion src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,10 @@ impl Editor {
path_items.push(MenuItem::new(&name, MenuAction::OpenWithInput(path)));
}
let path_submenu = ContextualMenu::new_with_items(self.system_font.clone(), self.event_sender.clone().unwrap(), path_items);
let mut menu_items = vec![MenuItem::new_with_submenu("Open ...", path_submenu), MenuItem::separator()];
let mut menu_items = vec![
MenuItem::new_with_submenu("Open ...", path_submenu),
MenuItem::separator()
];
for (name, path) in self.get_recent_files() {
menu_items.push(MenuItem::new(&name, MenuAction::Open(path)));
}
Expand Down
10 changes: 5 additions & 5 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use crate::animation::EasingFunction;
use crate::camera::Camera;
use crate::render_helper::draw_rounded_rectangle_with_border;

pub const MIN_INPUT_WIDTH: f32 = 200.;
pub const MAX_INPUT_WIDTH: f32 = 500.;
pub const MIN_INPUT_WIDTH: f32 = 250.;
pub const MAX_INPUT_WIDTH: f32 = 600.;

const ANIMATION_DURATION: f32 = 100.;

Expand Down Expand Up @@ -122,12 +122,12 @@ impl Editable for Input {

impl Input {
pub fn new(menu_id: MenuId, action_fn: MenuActionFn, es: UserEventSender<EditorEvent>) -> Self {
let mut editor = Editor::new(MIN_INPUT_WIDTH, 50., Vector2::ZERO, 10.); // arbitrary
let mut editor = Editor::new(MIN_INPUT_WIDTH, 55., Vector2::ZERO, 15.); // arbitrary height
editor.font.borrow_mut().change_font_size(-6); // Set font size to 10
let offset = Vector2::new(0., (50. - editor.font.borrow().char_height) / 2. - 10.);
let offset = Vector2::new(0., (50. - editor.font.borrow().char_height) / 2. - 15.);
editor.set_offset(offset);
editor.set_event_sender(Some(es));
editor.camera.safe_zone_size = 0.;
editor.camera.safe_zone_size = 30.;
let blank_text_layout = editor.lines[0].formatted_text_block.clone();
Self {
editor,
Expand Down

0 comments on commit 47f5587

Please sign in to comment.