Skip to content

Commit

Permalink
Improved settings
Browse files Browse the repository at this point in the history
  • Loading branch information
pisaiah committed May 15, 2022
1 parent 3ec81c5 commit 3bba2c0
Show file tree
Hide file tree
Showing 21 changed files with 147 additions and 79 deletions.
1 change: 1 addition & 0 deletions .github/workflows/blank.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ jobs:
cd iui
cd vide
rm -rf *.v
rm -rf .git
cd ..
cd ..
cd ..
Expand Down
Binary file added assets/Agave-Regular.ttf
Binary file not shown.
Binary file added assets/Anomaly-Mono.ttf
Binary file not shown.
Binary file removed assets/JetBrainsMono-Regular.ttf
Binary file not shown.
Binary file added assets/KARISMA_.ttf
Binary file not shown.
7 changes: 6 additions & 1 deletion assets/credit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@
<a target="_blank" href="https://icons8.com/icon/qu5s1Ou3hLx3/themes">Themes</a> icon by <a target="_blank" href="https://icons8.com">Icons8</a>
<a href="https://icons8.com/icon/OWRPl8fxkRvG/edit">Edit icon by Icons8</a>

DroidSansMono.ttf - See Apache License.txt
DroidSansMono.ttf - See Apache License.txt

Anomaly Mono:
https://github.com/benbusby/anomaly-mono/
KARISMA_:
https://www.1001fonts.com/karisma-font.html
Binary file removed assets/ezgif.com-gif-maker(1).png
Binary file not shown.
Binary file added assets/ezgif.com-gif-maker(3).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 assets/icons8-help-48.png
Binary file not shown.
Binary file removed assets/logo.png
Binary file not shown.
Binary file removed assets/vide.png
Binary file not shown.
Binary file removed assets/vide_.png
Binary file not shown.
7 changes: 3 additions & 4 deletions code_suggest.v
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ fn codebox_text_change(win_ptr voidptr, box_ptr voidptr) {
mut saved := false
if box.ctrl_down {
if box.last_letter == 's' {
println('SAVE REQUEST!')
do_save(mut win)
saved = true
box.ctrl_down = false
Expand Down Expand Up @@ -72,8 +71,8 @@ pub mut:
}

fn (mut this Hovermess) draw(ctx &ui.GraphicsContext) {
mut mid := (this.x + (this.width / 2))
mut midy := (this.y + (this.height / 2))
mid := (this.x + (this.width / 2))
midy := (this.y + (this.height / 2))

mut num := this.num - this.box.scroll_i

Expand Down Expand Up @@ -304,7 +303,7 @@ fn find_all_fn_in_vlib(mut win ui.Window, mod string) []string {

fn get_v_exe(win &ui.Window) string {
mut conf := get_config(win)
mut saved := conf.get_or_default('v_exe').replace('{user_home}', '~')
mut saved := conf.get_value('v_exe').replace('{user_home}', '~')
saved = saved.replace('~', os.home_dir().replace('\\', '/'))

if saved.len <= 0 {
Expand Down
11 changes: 4 additions & 7 deletions config.v
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ const (
struct Config {
ui.Component_A
pub mut:
window &ui.Window
conf map[string]string
conf map[string]string
}

fn config(mut win ui.Window) &Config {
mut config := &Config{
window: win
}
mut config := &Config{}
config.set_id(mut win, 'vide-config')
win.add_child(config)
config.read()
Expand All @@ -44,7 +41,7 @@ fn (mut this Config) read() {
os.write_file(file, default_config) or {}
}

mut lines := os.read_lines(file) or { ['ERROR while reading file contents'] }
lines := os.read_lines(file) or { ['ERROR while reading file contents'] }
for line in lines {
if !line.contains('=') {
continue
Expand All @@ -55,7 +52,7 @@ fn (mut this Config) read() {
ui.debug('Vide: Loaded config.')
}

fn (mut this Config) get_or_default(key string) string {
fn (mut this Config) get_value(key string) string {
if key in this.conf {
return this.conf[key]
} else {
Expand Down
22 changes: 10 additions & 12 deletions draw_events.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@ import gg

// Size components
fn on_runebox_draw(mut win ui.Window, mut tb ui.Component) {
mut x_off := 0
mut y_off := 0

mut com := &ui.Tabbox(win.get_from_id('main-tabs'))

x_off = com.x
y_off = com.height - 28
x_off := com.x
y_off := com.height - 31

if tb.height != y_off {
tb.height = y_off
}
width := gg.window_size().width - x_off - 8
width := gg.window_size().width - x_off - 5

if tb.width != width {
tb.width = width
Expand All @@ -25,12 +22,13 @@ fn on_runebox_draw(mut win ui.Window, mut tb ui.Component) {

// Size components
fn on_draw(mut win ui.Window, mut tb ui.Component) {
mut tree := &ui.Tree(win.get_from_id('proj-tree'))
tree := &ui.Tree(win.get_from_id('proj-tree'))
x_off := tree.x + tree.width
y_off := gg.window_size().height - tree.y - 123

y_off := gg.window_size().height - 170

if tb.height != y_off {
tb.height = y_off - 4
tb.height = y_off
}
width := gg.window_size().width - x_off - 4

Expand All @@ -39,8 +37,8 @@ fn on_draw(mut win ui.Window, mut tb ui.Component) {
}

mut com := &ui.TextArea(win.get_from_id('consolebox'))
com.x = x_off + 1
com.y = y_off + 32
com.height = 110
com.x = x_off
com.y = tb.y + tb.height + 4
com.height = 130
com.width = width
}
64 changes: 50 additions & 14 deletions ide.v
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import os
import iui.hc

const (
version = '0.0.10-dev'
version = '0.0.11-dev'
)

[console]
Expand All @@ -15,12 +15,19 @@ fn main() {
hc.hide_console_win()

// Create Window
mut window := ui.window(ui.get_system_theme(), 'Vide', 850, 520)
mut window := ui.window_with_config(ui.get_system_theme(), 'Vide', 1000, 600, ui.WindowConfig{
ui_mode: true
})

// our custom config
mut conf := config(mut window)
get_v_exe(window)

fs := conf.get_value('font_size')
if fs.len > 0 {
window.font_size = fs.int()
}

// Set Saved Theme
set_theme_from_save(mut window)

Expand Down Expand Up @@ -115,7 +122,7 @@ fn main() {

window.bar.add_child(save_menu)

workd := conf.get_or_default('workspace_dir').replace('{user_home}', '~').replace('\\',
workd := conf.get_value('workspace_dir').replace('{user_home}', '~').replace('\\',
'/') // '
folder := os.expand_tilde_to_home(workd).replace('~', os.home_dir())

Expand Down Expand Up @@ -145,10 +152,21 @@ fn main() {
mut hbox := ui.hbox(window)
hbox.add_child(tree)
hbox.add_child(tb)

hbox.draw_event_fn = fn (mut win ui.Window, mut hbox ui.Component) {
size := win.gg.window_size()
hbox.width = size.width
hbox.height = size.height

if 'font_load' !in win.extra_map {
mut conf := get_config(win)
saved_font := conf.get_value('main_font')
if saved_font.len > 0 {
font := win.add_font('Saved Font', saved_font)
win.graphics_context.font = font
}
win.extra_map['font_load'] = 'true'
}
}
window.add_child(hbox)

Expand Down Expand Up @@ -178,27 +196,42 @@ fn welcome_tab(mut window ui.Window, mut tb ui.Tabbox, folder string) {
padding_left := 70
padding_top := 50

info_lbl.set_pos(padding_left + 12, padding_top + 105)
mut vbox := ui.vbox(window)
vbox.set_pos(padding_left, padding_top)

info_lbl.set_pos(12, 24)
info_lbl.pack()

logo := window.gg.create_image_from_byte_array(vide_png.to_bytes())
window.id_map['vide_logo'] = &logo

mut logo_im := ui.image(window, logo)
logo_im.set_bounds(padding_left, padding_top, 193, 76)
logo_im.set_bounds(0, 0, logo.width, logo.height)

mut gh := ui.hyperlink(window, 'Github', 'https://github.com/isaiahpatton/vide')
gh.set_pos(215 + padding_left, padding_top + 40)
gh.pack()

mut ad := ui.hyperlink(window, 'Addons', 'https://github.com/topics/vide-addon')
ad.set_pos(270 + padding_left, padding_top + 40)
mut di := ui.hyperlink(window, 'Discord', 'https://discord.gg/NruVtYBf5g')

ad.set_pos(12, 0)
di.set_pos(12, 0)
gh.pack()
di.pack()
ad.pack()

tb.add_child('Welcome', info_lbl)
tb.add_child('Welcome', logo_im)
tb.add_child('Welcome', gh)
tb.add_child('Welcome', ad)
vbox.add_child(logo_im)
vbox.add_child(info_lbl)

// Links
mut hbox := ui.hbox(window)
hbox.add_child(gh)
hbox.add_child(ad)
hbox.add_child(di)
hbox.set_bounds(12, 12, 600, 100)
hbox.pack()
vbox.add_child(hbox)
vbox.pack()

tb.add_child('Welcome', vbox)
}

fn new_tab(mut window ui.Window, file string) {
Expand All @@ -217,7 +250,10 @@ fn new_tab(mut window ui.Window, file string) {
code_box.text_change_event_fn = codebox_text_change
code_box.after_draw_event_fn = on_runebox_draw
code_box.line_draw_event_fn = draw_code_suggest
code_box.set_bounds(2, 2, 620, 250)
code_box.hide_border = true
code_box.padding_x = 8
code_box.padding_y = 8
code_box.set_bounds(0, 0, 620, 250)

tb.add_child(file, code_box)
tb.active_tab = file
Expand Down
6 changes: 3 additions & 3 deletions menus.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import os
import gg

const (
vide_png = $embed_file('assets/ezgif.com-gif-maker(2).png')
vide_png = $embed_file('assets/ezgif.com-gif-maker(3).png')
)

fn set_theme_from_save(mut win ui.Window) {
mut conf := get_config(win)
name := conf.get_or_default('theme')
name := conf.get_value('theme')
if name.len > 1 {
theme := ui.theme_by_name(name)
win.set_theme(theme)
Expand All @@ -30,7 +30,7 @@ fn about_click(mut win ui.Window, com ui.MenuItem) {

logo := &gg.Image(win.id_map['vide_logo'])
mut logo_im := ui.image(win, logo)
logo_im.set_bounds(150, 34, 193, 76)
logo_im.set_bounds(99, 24, 263, 93)

mut label := ui.label(win, 'Small IDE for the V Programming Language made in V.\n\nVersion: ' +
version + '\nUI Version: ' + ui.version)
Expand Down
4 changes: 2 additions & 2 deletions new_file.v
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn new_file_click(mut win ui.Window, com ui.MenuItem) {
fold_btn.set_click_fn(fn (a voidptr, b voidptr, c voidptr) {
mut win := &ui.Window(a)
mut conf := get_config(win)
dir := conf.get_or_default('workspace_dir').replace('{user_home}', os.real_path(os.home_dir()))
dir := conf.get_value('workspace_dir').replace('{user_home}', os.real_path(os.home_dir()))

path_change_fn := file_picker_path_change

Expand Down Expand Up @@ -67,7 +67,7 @@ fn new_file_click(mut win ui.Window, com ui.MenuItem) {
name := win.extra_map['nf-name']
pdir := win.extra_map['nf-dir']
mut conf := get_config(win)
dir := conf.get_or_default('workspace_dir').replace('{user_home}', os.real_path(os.home_dir()))
dir := conf.get_value('workspace_dir').replace('{user_home}', os.real_path(os.home_dir()))

os.write_file(pdir + '/' + name, '') or {}

Expand Down
14 changes: 9 additions & 5 deletions plugins.v
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ import time
type FNPlMain = fn (mut a ui.Window)

pub fn load_plugins(dir string, mut win ui.Window) ? {
println('Loading plugins...')
for file in os.ls(dir) or { [''] } {
println('Loading plugin "' + file + '"...')
list := os.ls(dir) or { [''] }
if list.len == 0 {
return
}

println('Loading plugins')
for file in list {
println('Loading plugin $file ...')
library_file_path := os.join_path(dir, file)
if os.is_dir(library_file_path) {
continue
}

if file.ends_with('.videaddon') {
// Uncompiled test
load_uncompiled(mut win, library_file_path) ?
continue
}
Expand All @@ -29,7 +33,7 @@ pub fn load_plugins(dir string, mut win ui.Window) ? {

f(mut win)
}
println('Loaded plugins.')
println('Loaded plugins')
}

// Load from source ZIP
Expand Down
Loading

0 comments on commit 3bba2c0

Please sign in to comment.