Skip to content

Commit e6e0f82

Browse files
committed
Mostly bugfixes
1 parent d8578a6 commit e6e0f82

File tree

10 files changed

+49
-13
lines changed

10 files changed

+49
-13
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "theframework"
3-
version = "0.1.15"
3+
version = "0.1.16"
44
edition = "2021"
55
description = "A cross platform application UI framework."
66
license = "MIT"

Readme.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Without any enabled options, TheFramework opens a window and provides a pixel bu
44

55
![UI Screenshot](images/screenshot_uidemo.png)
66

7-
![UI Screenshot](images/screenshot_ui.png)
7+
![UI Screenshot](images/screenshot_eldiron.png)
88

99
### Option: ui
1010

@@ -24,8 +24,6 @@ I use TheFramework with the UI option for my own apps and games, notably [Eldiro
2424

2525
A dedicated demo and documentation website will come soon.
2626

27-
![UI Screenshot](images/screenshot_codegrid.png)
28-
2927
### Option: code
3028

3129
The **code** option adds a unique and powerful visual scripting system to TheFramework.

images/screenshot_codegrid.png

-579 KB
Binary file not shown.

images/screenshot_eldiron.png

862 KB
Loading

images/screenshot_ui.png

-714 KB
Binary file not shown.

src/theui/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,14 @@ impl TheUI {
556556
None
557557
}
558558

559+
/// Gets a given group button by name
560+
pub fn get_group_button(&mut self, name: &str) -> Option<&mut dyn TheGroupButtonTrait> {
561+
if let Some(text) = self.canvas.get_widget(Some(&name.to_string()), None) {
562+
return text.as_group_button();
563+
}
564+
None
565+
}
566+
559567
/// Gets a given statusbar by name
560568
pub fn get_statusbar(&mut self, name: &str) -> Option<&mut dyn TheStatusbarTrait> {
561569
if let Some(text) = self.canvas.get_widget(Some(&name.to_string()), None) {

src/theui/thelayout/thergbalayout.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -374,24 +374,30 @@ impl TheRGBALayoutTrait for TheRGBALayout {
374374
}
375375

376376
fn scroll_to(&mut self, coord: Vec2i) {
377-
if let Some(scroll_bar) = self.vertical_scrollbar.as_vertical_scrollbar() {
378-
scroll_bar.scroll_to(coord.y);
379-
}
377+
if let Some(rgba) = self.rgba_view.as_rgba_view() {
378+
let zoom = rgba.zoom();
380379

381-
if let Some(scroll_bar) = self.horizontal_scrollbar.as_horizontal_scrollbar() {
382-
scroll_bar.scroll_to(coord.x);
380+
if let Some(scroll_bar) = self.vertical_scrollbar.as_vertical_scrollbar() {
381+
scroll_bar.scroll_to(((coord.y as f32) * zoom) as i32);
382+
}
383+
384+
if let Some(scroll_bar) = self.horizontal_scrollbar.as_horizontal_scrollbar() {
385+
scroll_bar.scroll_to(((coord.x as f32) * zoom) as i32);
386+
}
383387
}
384388
}
385389

386390
fn scroll_to_grid(&mut self, coord: Vec2i) {
387391
if let Some(rgba) = self.rgba_view.as_rgba_view() {
392+
let zoom = rgba.zoom();
393+
388394
if let Some(grid) = rgba.grid() {
389395
if let Some(scroll_bar) = self.vertical_scrollbar.as_vertical_scrollbar() {
390-
scroll_bar.scroll_to(coord.y * grid);
396+
scroll_bar.scroll_to(((coord.y * grid) as f32 * zoom) as i32);
391397
}
392398

393399
if let Some(scroll_bar) = self.horizontal_scrollbar.as_horizontal_scrollbar() {
394-
scroll_bar.scroll_to(coord.x * grid);
400+
scroll_bar.scroll_to(((coord.x * grid) as f32 * zoom) as i32);
395401
}
396402
}
397403
}

src/theui/thewidget/thecodeview.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ impl TheWidget for TheCodeView {
590590
);
591591
ctx.draw.text_rect_blend(
592592
self.buffer.pixels_mut(),
593-
&rect,
593+
&(rect.0 + 4, rect.1, rect.2 - 8, rect.3),
594594
stride,
595595
font,
596596
font_size,
@@ -600,10 +600,23 @@ impl TheWidget for TheCodeView {
600600
TheVerticalAlign::Center,
601601
);
602602
}
603+
TheCodeAtom::ExternalCall(_,_) => {
604+
ctx.draw.text_rect_blend(
605+
self.buffer.pixels_mut(),
606+
&(rect.0 + 2, rect.1, rect.2 - 4, rect.3),
607+
stride,
608+
font,
609+
font_size,
610+
&atom.describe(),
611+
&text_color,
612+
TheHorizontalAlign::Center,
613+
TheVerticalAlign::Center,
614+
);
615+
}
603616
_ => {
604617
ctx.draw.text_rect_blend(
605618
self.buffer.pixels_mut(),
606-
&rect,
619+
&(rect.0 + 4, rect.1, rect.2 - 8, rect.3),
607620
stride,
608621
font,
609622
font_size,

src/theui/thewidget/thegroupbutton.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,16 @@ impl TheWidget for TheGroupButton {
314314
}
315315

316316
pub trait TheGroupButtonTrait {
317+
/// Add a new text based item.
317318
fn add_text(&mut self, text: String);
319+
/// Add a new text based item with an associated status text.
318320
fn add_text_status(&mut self, text: String, status: String);
321+
/// Add a new text based item with an associated status text and an icon.
319322
fn add_text_status_icon(&mut self, text: String, status: String, icon: String);
323+
/// Set the width of each itme.
320324
fn set_item_width(&mut self, width: usize);
325+
/// Set the selected index.
326+
fn set_selected_index(&mut self, index: i32);
321327
}
322328

323329
impl TheGroupButtonTrait for TheGroupButton {
@@ -339,4 +345,8 @@ impl TheGroupButtonTrait for TheGroupButton {
339345
fn set_item_width(&mut self, width: usize) {
340346
self.item_width = width;
341347
}
348+
fn set_selected_index(&mut self, index: i32) {
349+
self.selected_index = Some(index as usize);
350+
self.is_dirty = true;
351+
}
342352
}

src/theui/thewidget/thergbaview.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ impl TheWidget for TheRGBAView {
172172
self.id.clone(),
173173
vec2i(loc.0, loc.1),
174174
));
175+
self.hover = Some((loc.0, loc.1));
175176
}
176177
}
177178
}

0 commit comments

Comments
 (0)