Skip to content

Commit

Permalink
Custom Icons for Tools (#22)
Browse files Browse the repository at this point in the history
* WIP custom 'add chamber' icon button

* full icon set

* adjust icons to color scheme. Replace icons in docs
  • Loading branch information
H4kor authored Jul 17, 2024
1 parent 28f191a commit 5a7144d
Show file tree
Hide file tree
Showing 41 changed files with 42 additions and 29 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@ jobs:
- name: Build mkDocs
run: |
pip install mkdocs
cd docs
mkdocs build
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: 'docs/site'
path: 'site'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
*.pdf
callgrind.*
venv/
docs/site
site/
Binary file added assets/icons/add_chamber.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/add_door.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/add_object.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/append_chamber.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/buttons.xcf
Binary file not shown.
Binary file added assets/icons/remove_corner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/select.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/split_wall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added docs/assets/tools.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/tools/add_chamber.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/tools/add_door.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/tools/add_object.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/tools/append_chamber.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/tools/button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/tools/remove_corner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/tools/select.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/tools/split_wall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/docs/assets/tools.png
Binary file not shown.
Binary file removed docs/docs/assets/tools/add_door.png
Binary file not shown.
Binary file removed docs/docs/assets/tools/add_object.png
Binary file not shown.
Binary file removed docs/docs/assets/tools/edit_chamber.png
Binary file not shown.
Binary file removed docs/docs/assets/tools/new_chamber.png
Diff not rendered.
Binary file removed docs/docs/assets/tools/remove_corner.png
Diff not rendered.
Binary file removed docs/docs/assets/tools/selection.png
Diff not rendered.
Binary file removed docs/docs/assets/tools/split_wall.png
Diff not rendered.
File renamed without changes.
6 changes: 3 additions & 3 deletions docs/docs/quickstart.md → docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ The dungeon editor where you can edit and see the layout of your dungeon is on t

The dungeon can be modified using these tools:

### ![New Chamber](assets/tools/new_chamber.png) **New Chamber** (`Alt+C`)
### ![New Chamber](assets/tools/add_chamber.png) **New Chamber** (`Alt+C`)

Adds a new chamber (or room) to the dungeon.
The editor mode is changed to "append".
Clicking in the dungeon editor will add a new edge to the dungeon.

### ![Selection](assets/tools/selection.png) **Selection** (`Alt+S`)
### ![Selection](assets/tools/select.png) **Selection** (`Alt+S`)

Allows you to select chambers, doors and objects using the dungeon editor.
The navigation will jump to the selected entity.

### ![Append Chamber](assets/tools/edit_chamber.png) **Append Chamber** (`Alt+A`)
### ![Append Chamber](assets/tools/append_chamber.png) **Append Chamber** (`Alt+A`)

*Requires a selected chamber.*

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ Rooms, corridors and (any type other enclosed space) are called *chambers* in Du
Chambers are the fundemental building blocks of any dungeon.
A chamber might have doors and objected related to them, but these are added in later steps.

## Creating a new chamber ![New Chamber](../assets/tools/new_chamber.png)
## Creating a new chamber ![New Chamber](../assets/tools/add_chamber.png)

To create a new chamber use the "New Chamber" tool. Alternatively you can use the shortcut `Alt+C`.
This will add a new chamber to the chamber list in the navigation on the left side.
The editor will change to the "append" mode for the newly created chamber.



## Drawing a chamber ![Append Chamber](../assets/tools/edit_chamber.png)
## Drawing a chamber ![Append Chamber](../assets/tools/append_chamber.png)

After creating a new chamber you can add corners to it by simply clicking in the edior.
If you somehow exited the "append" mode, select the chamber in the list on the left and use the "Append Chamber" tool.
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/mkdocs.yml → mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ nav:

markdown_extensions:
- attr_list
- md_in_html
- md_in_html
14 changes: 7 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,39 +108,39 @@ fn build_ui(app: &adw::Application) {
let select_chamber_button = EditModeButton::new(
control.clone(),
state::EditMode::Select,
"edit-find",
"Select Chamber/Door",
include_bytes!("../assets/icons/select.png").to_vec(),
"Select",
);
let split_edge_button = EditModeButton::new(
control.clone(),
state::EditMode::SplitEdge,
"edit-cut",
include_bytes!("../assets/icons/split_wall.png").to_vec(),
"Split Wall",
);
let append_verts_button = EditModeButton::new(
control.clone(),
state::EditMode::AppendChamber,
"document-edit",
include_bytes!("../assets/icons/append_chamber.png").to_vec(),
"Draw Chamber",
);
let delete_corner_button = EditModeButton::new(
control.clone(),
state::EditMode::RemoveVertex,
"list-remove",
include_bytes!("../assets/icons/remove_corner.png").to_vec(),
"Remove Corner",
);

let add_door_button = EditModeButton::new(
control.clone(),
state::EditMode::AddDoor,
"insert-link",
include_bytes!("../assets/icons/add_door.png").to_vec(),
"Insert Door",
);

let add_object_button = EditModeButton::new(
control.clone(),
state::EditMode::AddObject,
"insert-object",
include_bytes!("../assets/icons/add_object.png").to_vec(),
"Insert Object",
);

Expand Down
40 changes: 27 additions & 13 deletions src/view/buttons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ use crate::state::StateCommand;
use crate::state::StateController;
use crate::state::StateEventSubscriber;
use cairo::glib::clone;
use gtk::gdk::Texture;
use gtk::gdk_pixbuf::Pixbuf;
use gtk::gio::Cancellable;
use gtk::gio::MemoryInputStream;
use gtk::glib;
use gtk::prelude::*;
use gtk::Image;
use gtk::{Button, ToggleButton};
pub struct AddChamberButton {
pub widget: Button,
Expand All @@ -19,12 +24,17 @@ pub struct EditModeButton {

impl AddChamberButton {
pub fn new(control: Rc<RefCell<StateController>>) -> Self {
let button = Button::builder()
.icon_name("document-new")
.tooltip_text("Create new Chamber")
.has_tooltip(true)
.build();
button.set_size_request(48, 48);
let button = Button::new();
let bytes = include_bytes!("../../assets/icons/add_chamber.png");
let bytes = glib::Bytes::from(&bytes.to_vec());
let stream = MemoryInputStream::from_bytes(&bytes);
let pixbuf = Pixbuf::from_stream(&stream, Cancellable::NONE).unwrap();
let texture = Texture::for_pixbuf(&pixbuf);
let image = Image::from_paintable(Some(&texture));
button.set_child(Some(&image));
button.set_tooltip_text(Some("Create new Chamber"));
button.set_has_tooltip(true);
button.set_size_request(64, 64);

button.connect_clicked(move |_button| {
let control = &mut *control.borrow_mut();
Expand All @@ -39,15 +49,19 @@ impl EditModeButton {
pub fn new(
control: Rc<RefCell<StateController>>,
mode: EditMode,
icon_name: &str,
icon_bytes: Vec<u8>,
tooltip: &str,
) -> Rc<RefCell<Self>> {
let button = ToggleButton::builder()
.icon_name(icon_name)
.tooltip_text(tooltip)
.has_tooltip(true)
.build();
button.set_size_request(48, 48);
let button = ToggleButton::new();
let bytes = glib::Bytes::from(&icon_bytes);
let stream = MemoryInputStream::from_bytes(&bytes);
let pixbuf = Pixbuf::from_stream(&stream, Cancellable::NONE).unwrap();
let texture = Texture::for_pixbuf(&pixbuf);
let image = Image::from_paintable(Some(&texture));
button.set_child(Some(&image));
button.set_tooltip_text(Some(tooltip));
button.set_has_tooltip(true);
button.set_size_request(64, 64);

button.connect_clicked(clone!( @weak control => move |_button| {
let control = &mut *control.borrow_mut();
Expand Down

0 comments on commit 5a7144d

Please sign in to comment.