Skip to content
This repository has been archived by the owner on Jun 7, 2019. It is now read-only.

Commit

Permalink
update: add settings
Browse files Browse the repository at this point in the history
  • Loading branch information
MWGuy committed Nov 16, 2018
1 parent f422dfd commit 00a1292
Show file tree
Hide file tree
Showing 11 changed files with 146 additions and 17 deletions.
5 changes: 4 additions & 1 deletion ide/misc/languages/en/messages.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1019,8 +1019,11 @@ wizard.x.gravity.ver=Gravity by Y (vertical)
wizard.x.position=X Position
wizard.y.position=Y Position
ide.settings.ide=IDE Settings
ide.settings.ide.themes=IDE Theme:
ide.settings.extensions=Extensions
ide.settings.save=Save
ide.settings.close=Close
ide.settings.default=To default
ide.settings.default.question=Make default settings ?
ide.settings.save.question=Save settings ?
ide.settings.save.question=Save settings ?
ide.settings.restart.question=Restart IDE ?
5 changes: 4 additions & 1 deletion ide/misc/languages/ru/messages.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1019,8 +1019,11 @@ wizard.x.gravity.ver=Гравитация по Y (вертикальная)
wizard.x.position=Позиция X
wizard.y.position=Позиция Y
ide.settings.ide=Настройки IDE
ide.settings.ide.themes=Тема IDE:
ide.settings.extensions=Разширения
ide.settings.save=Сохранить
ide.settings.close=Закрыть
ide.settings.default=По умолчанию
ide.settings.default.question=Сбросить настройки ?
ide.settings.save.question=Сохранить настройки ?
ide.settings.save.question=Сохранить настройки ?
ide.settings.restart.question=Перезапустить IDE ?
4 changes: 4 additions & 0 deletions ide/src/.theme/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -366,4 +366,8 @@ combo-box-base:editable:focused > .text-field,

.dn-console-list {
-fx-border-width: 0;
}

.dn-autocomplete {
-fx-text-fill: #fff;
}
9 changes: 3 additions & 6 deletions ide/src/.theme/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,8 @@
-fx-line-spacing: 30px;
}

.dn-autocomplete {
-fx-border-width: 0px;
-fx-border-color: #dddddd;
.dn-autocomplete .list-cell:selected {
-fx-background-color: #82adf220;
}

.dn-autocomplete-description {
Expand Down Expand Up @@ -405,6 +404,4 @@ combo-box-base:editable:focused > .text-field,

.styled-text-area {
-fx-font-size: 14;
}

.list-cell:selected { -fx-background-color: #82adf220;}
}
10 changes: 10 additions & 0 deletions ide/src/ide/Ide.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use ide\project\AbstractProjectTemplate;
use ide\project\control\AbstractProjectControlPane;
use ide\project\Project;
use ide\settings\ExtensionsSettings;
use ide\settings\IdeSettings;
use ide\settings\SettingsContainer;
use ide\systems\Cache;
Expand Down Expand Up @@ -183,6 +184,7 @@ public function __construct($configPath = null)

$this->settingsContainer = new SettingsContainer();
$this->settingsContainer->register(new IdeSettings());
$this->settingsContainer->register(new ExtensionsSettings());

$this->asyncThreadPool = ThreadPool::createCached();
}
Expand Down Expand Up @@ -1601,4 +1603,12 @@ public function getSettingsContainer(): SettingsContainer
{
return $this->settingsContainer;
}

/**
* @return AbstractExtension[]
*/
public function getExtensions(): array
{
return $this->extensions;
}
}
4 changes: 2 additions & 2 deletions ide/src/ide/IdeStandardExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function onIdeShutdown()

public function getName(): string
{
return Ide::get()->getName();
return "IDE Platform";
}

public function getAuthor(): string
Expand All @@ -74,7 +74,7 @@ public function getVersion(): string

public function getIcon32(): string
{
return null;
return "logo.png";
}

public function isSystem(): bool
Expand Down
3 changes: 0 additions & 3 deletions ide/src/ide/autocomplete/ui/AutoCompletePane.php
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,6 @@ private function makeUi()
$list->maxHeight = 9999;
$list->fixedCellSize = 20;
$list->classes->addAll(['hide-hor-scroll', 'dn-console-list', 'dn-autocomplete']);
$list->style = '-fx-background-insets: 0; -fx-focus-color: -fx-control-inner-background; -fx-faint-focus-color: -fx-control-inner-background;';
$list->width = 400;

$ui->add($list);
Expand All @@ -820,8 +819,6 @@ private function makeUi()

$win = new UXPopupWindow();
$win->layout = $ui;
/*$win->style = 'TRANSPARENT';
$win->opacity = 0.7;*/

$v = function () {
$offsetY = 0;
Expand Down
2 changes: 2 additions & 0 deletions ide/src/ide/forms/IdeSettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use ide\Ide;
use ide\settings\AbstractSettings;
use ide\systems\DialogSystem;
use php\gui\UXAlert;
use php\gui\UXButton;
use php\gui\UXTab;
use php\gui\UXTabPane;
Expand Down
78 changes: 78 additions & 0 deletions ide/src/ide/settings/ExtensionsSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

namespace ide\settings;


use ide\AbstractExtension;
use ide\Ide;
use php\gui\layout\UXAnchorPane;
use php\gui\layout\UXHBox;
use php\gui\layout\UXVBox;
use php\gui\UXLabel;
use php\gui\UXListCell;
use php\gui\UXListView;
use php\gui\UXNode;

class ExtensionsSettings extends AbstractSettings
{
/**
* @return string
*/
public function getName(): string
{
return "ide.settings.extensions";
}

/**
* @return string
*/
public function getIcon16(): string
{
return "icons/plugin16.png";
}

/**
* @return UXNode
* @throws \Exception
*/
public function getNode(): UXNode
{
$list = new UXListView();
UXAnchorPane::setAnchor($list, 8);
$list->setCellFactory(function (UXListCell $cell, AbstractExtension $extension) {
if ($extension) {
$titleName = new UXLabel($extension->getName() . " " . $extension->getVersion());
$titleName->style = '-fx-font-weight: bold;';

if ($extension->isSystem())
$titleName->text .= " (system)";

$titleDescription = new UXLabel($extension->getAuthor());
$titleDescription->opacity = 0.7;

$title = new UXVBox([$titleName, $titleDescription]);
$title->spacing = 0;

$line = new UXHBox([Ide::getImage($extension->getIcon32(), [32, 32]), $title]);
$line->spacing = 7;
$line->padding = 5;
$cell->text = null;
$cell->graphic = $line;
}
});

foreach (Ide::get()->getExtensions() as $extension) $list->items->add($extension);

return $list;
}

public function save(): void
{
// noup
}

public function toDefault(): void
{
// noup
}
}
36 changes: 32 additions & 4 deletions ide/src/ide/settings/IdeSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@

namespace ide\settings;


use ide\Ide;
use ide\themes\LightTheme;
use php\gui\layout\UXHBox;
use php\gui\layout\UXVBox;
use php\gui\UXComboBox;
use php\gui\UXLabel;
use php\gui\UXNode;
use php\gui\UXSeparator;

class IdeSettings extends AbstractSettings
{
/**
* @var UXComboBox
*/
private $themesList;

/**
* @return string
*/
Expand All @@ -29,16 +39,34 @@ public function getIcon16(): string
*/
public function getNode(): UXNode
{
return new UXLabel("Soon ....");
$box = new UXVBox();
$box->add($hb = new UXHBox([
new UXLabel(_("ide.settings.ide.themes")), $this->themesList = new UXComboBox()
]));

$box->spacing = $box->padding = $hb->spacing = 8;
$hb->alignment = "CENTER_LEFT";
$hb->maxHeight = 150;
$box->add(new UXSeparator());

$this->themesList->value = Ide::get()->getThemeManager()->getDefault()->getName();
foreach (Ide::get()->getThemeManager()->getAll() as $theme) $this->themesList->items->add($theme->getName());

return $box;
}

public function save(): void
{
alert("save");
if ($this->themesList->value)
Ide::get()->setUserConfigValue("ide.theme", $this->themesList->value);

if (uiConfirm(_("ide.settings.restart.question"))) Ide::get()->restart();
}

public function toDefault(): void
{
alert("def");
Ide::get()->setUserConfigValue("ide.theme", (new LightTheme())->getName());

if (uiConfirm(_("ide.settings.restart.question"))) Ide::get()->restart();
}
}
7 changes: 7 additions & 0 deletions ide/src/ide/themes/ThemeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,11 @@ public function getDefault(): ?AbstractTheme
{
return $this->get($this->default);
}

/**
* @return AbstractTheme[]
*/
public function getAll() : array {
return $this->themes;
}
}

0 comments on commit 00a1292

Please sign in to comment.