Add status bar
This commit is contained in:
parent
393fe7aa40
commit
d0fcb041de
|
|
@ -1 +1 @@
|
|||
Subproject commit 08cad1b78f43492200f279c302aed6243fe9057b
|
||||
Subproject commit 0673473d16e19c24f7fbee96c268af22dd8302ed
|
||||
|
|
@ -207,4 +207,35 @@ hr
|
|||
{
|
||||
width: 100%%;
|
||||
height: 100%%;
|
||||
}
|
||||
|
||||
#StatusBar
|
||||
{
|
||||
background: #31363b;
|
||||
flow: horizontal;
|
||||
color: #eff0f1;
|
||||
padding: 0.2em 1em;
|
||||
border-top: 1px solid #434242;
|
||||
font-family: 'Segoe UI', Arial, sans-serif;
|
||||
font-size: 0.8em;
|
||||
font-weight: 100;
|
||||
}
|
||||
|
||||
#StatusBar #volume
|
||||
{
|
||||
border: 1px solid transparent;
|
||||
padding: 0.2em;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#StatusBar #volume:hover
|
||||
{
|
||||
border: 1px solid #76797c;
|
||||
}
|
||||
|
||||
#VolumePopup
|
||||
{
|
||||
background: #31363b;
|
||||
border: 1px solid #434242;
|
||||
padding: 1em;
|
||||
}
|
||||
|
|
@ -13,4 +13,10 @@
|
|||
</header>
|
||||
<mainmenu id="MainMenu" />
|
||||
<div id="MainContents" />
|
||||
</html>
|
||||
<div id="StatusBar" ><span id="volume" /></div>
|
||||
</html>
|
||||
<popup id="VolumePopup">
|
||||
<div>
|
||||
<input type="hslider" id="Volume" min="0" max="200" value="100" id="audioVolume" style="width: 19em" />
|
||||
</div>
|
||||
</popup>
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
</div>
|
||||
<div class="form-row slider-row">
|
||||
<div class="left"><label for="audioVolume">Volume:</label></div>
|
||||
<div class="right"><input type="hslider" id="Volume" min="0" max="200" value="100" id="audioVolume" style="width: 20em" /><span id="VolumeDisplay">100%</span></div>
|
||||
<div class="right"><input type="hslider" id="Volume" min="0" max="200" value="100" id="audioVolume" style="width: 19em" /><span id="VolumeDisplay">100%</span></div>
|
||||
</div>
|
||||
<div class="form-row checkbox-row">
|
||||
<div class="checkbox"><input type="checkbox" id="muteAudio"><label for="muteAudio">Mute audio</label></div>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <nxemu-core/settings/identifiers.h>
|
||||
#include <nxemu-core/settings/settings.h>
|
||||
#include <nxemu-core/version.h>
|
||||
#include <nxemu-os/os_settings_identifiers.h>
|
||||
#include <sciter_element.h>
|
||||
#include <widgets/menubar.h>
|
||||
#include <yuzu_common/settings_input.h>
|
||||
|
|
@ -17,13 +18,15 @@ SciterMainWindow::SciterMainWindow(ISciterUI & sciterUI, const char * windowTitl
|
|||
m_window(nullptr),
|
||||
m_renderWindow(nullptr),
|
||||
m_windowTitle(windowTitle),
|
||||
m_systemConfig(sciterUI)
|
||||
m_systemConfig(sciterUI),
|
||||
m_volumePopup(false)
|
||||
{
|
||||
SettingsStore & settings = SettingsStore::GetInstance();
|
||||
settings.RegisterCallback(NXCoreSetting::GameFile, SciterMainWindow::GameFileChanged, this);
|
||||
settings.RegisterCallback(NXCoreSetting::GameName, SciterMainWindow::GameNameChanged, this);
|
||||
settings.RegisterCallback(NXCoreSetting::RomLoading, SciterMainWindow::RomLoadingChanged, this);
|
||||
settings.RegisterCallback(NXCoreSetting::DisplayedFrames, SciterMainWindow::DisplayedFramesChanged, this);
|
||||
settings.RegisterCallback(NXOsSetting::AudioVolume, SciterMainWindow::SettingChanged, this);
|
||||
}
|
||||
|
||||
void SciterMainWindow::ResetMenu()
|
||||
|
|
@ -111,6 +114,10 @@ bool SciterMainWindow::Show(void)
|
|||
IVideo & video = system->Video();
|
||||
video.UpdateFramebufferLayout(rect.right - rect.left, rect.bottom - rect.top);
|
||||
}
|
||||
UpdateStatusbar();
|
||||
m_sciterUI.AttachHandler(rootElement, IID_IMOUSEUPDOWNSINK, (IMouseUpDownSink*)this);
|
||||
m_sciterUI.AttachHandler(rootElement.GetElementByID("volume"), IID_ICLICKSINK, (IClickSink*)this);
|
||||
m_sciterUI.AttachHandler(rootElement.GetElementByID("audioVolume"), IID_ISTATECHANGESINK, (IStateChangeSink*)this);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -284,6 +291,36 @@ int32_t SciterMainWindow::SciterKeyToVKCode(SciterKeys key)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void SciterMainWindow::UpdateStatusbar()
|
||||
{
|
||||
SettingsStore & settings = SettingsStore::GetInstance();
|
||||
SciterElement rootElement(m_window->GetRootElement());
|
||||
SciterElement volume(rootElement.GetElementByID("volume"));
|
||||
stdstr_f text("VOLUME: %d %%", settings.GetInt(NXOsSetting::AudioVolume));
|
||||
volume.SetHTML((const uint8_t *)text.c_str(), text.size());
|
||||
}
|
||||
|
||||
void SciterMainWindow::DismissvolumePopup(SCITER_ELEMENT source, int32_t x, int32_t y)
|
||||
{
|
||||
if (!m_volumePopup)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SciterElement rootElement(m_window->GetRootElement());
|
||||
if (source == rootElement.GetElementByID("volume"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
SciterElement volumePopup(rootElement.GetElementByID("VolumePopup"));
|
||||
SciterElement::RECT rc = volumePopup.GetLocation(SciterElement::ROOT_RELATIVE | SciterElement::BORDER_BOX);
|
||||
if (x >= rc.left && y >= rc.top && x <= rc.right && y <= rc.bottom)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_sciterUI.PopupHide(rootElement.GetElementByID("VolumePopup"));
|
||||
m_volumePopup = false;
|
||||
}
|
||||
|
||||
void SciterMainWindow::SetCaption(const std::string & caption)
|
||||
{
|
||||
SciterElement rootElement(m_window->GetRootElement());
|
||||
|
|
@ -478,3 +515,50 @@ bool SciterMainWindow::OnSizeChanged(SCITER_ELEMENT elem)
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SciterMainWindow::OnClick(SCITER_ELEMENT /*element*/, SCITER_ELEMENT source, uint32_t /*reason*/)
|
||||
{
|
||||
SciterElement rootElement(m_window->GetRootElement());
|
||||
if (source == rootElement.GetElementByID("volume"))
|
||||
{
|
||||
m_sciterUI.PopupShow(rootElement.GetElementByID("VolumePopup"), rootElement.GetElementByID("volume"), 8);
|
||||
m_volumePopup = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SciterMainWindow::OnMouseUp(SCITER_ELEMENT /*element*/, SCITER_ELEMENT source, uint32_t x, uint32_t y)
|
||||
{
|
||||
DismissvolumePopup(source, x, y);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SciterMainWindow::OnMouseDown(SCITER_ELEMENT /*element*/, SCITER_ELEMENT source, uint32_t x, uint32_t y)
|
||||
{
|
||||
DismissvolumePopup(source, x, y);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SciterMainWindow::OnStateChange(SCITER_ELEMENT elem, uint32_t /*eventReason*/, void * /*data*/)
|
||||
{
|
||||
SciterElement rootElement(m_window->GetRootElement());
|
||||
if (rootElement.GetElementByID("audioVolume") == elem)
|
||||
{
|
||||
SciterValue value = SciterElement(elem).GetValue();
|
||||
if (value.isInt())
|
||||
{
|
||||
SettingsStore& settings = SettingsStore::GetInstance();
|
||||
settings.SetInt(NXOsSetting::AudioVolume, value.GetValueInt());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SciterMainWindow::SettingChanged(const char * setting, void * userData)
|
||||
{
|
||||
SciterMainWindow * impl = (SciterMainWindow*)userData;
|
||||
if (strcmp(setting, NXOsSetting::AudioVolume) == 0)
|
||||
{
|
||||
impl->UpdateStatusbar();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,10 @@ class SciterMainWindow :
|
|||
public IMenuBarSink,
|
||||
public IRenderWindow,
|
||||
public IKeySink,
|
||||
public IResizeSink
|
||||
public IResizeSink,
|
||||
public IClickSink,
|
||||
public IMouseUpDownSink,
|
||||
public IStateChangeSink
|
||||
{
|
||||
enum MainMenuID
|
||||
{
|
||||
|
|
@ -47,7 +50,9 @@ private:
|
|||
void ShowLoadingScreen(void);
|
||||
int32_t SciterKeyToSwitchKey(SciterKeys key);
|
||||
int32_t SciterKeyToVKCode(SciterKeys vkcode);
|
||||
|
||||
void UpdateStatusbar();
|
||||
void DismissvolumePopup(SCITER_ELEMENT source, int32_t x, int32_t y);
|
||||
|
||||
void OnOpenFile(void);
|
||||
void OnFileExit(void);
|
||||
void OnSystemConfig(void);
|
||||
|
|
@ -70,7 +75,19 @@ private:
|
|||
bool OnKeyChar(SCITER_ELEMENT element, SCITER_ELEMENT item, SciterKeys keyCode, uint32_t keyboardState) override;
|
||||
|
||||
// IResizeSink
|
||||
bool OnSizeChanged(SCITER_ELEMENT elem);
|
||||
bool OnSizeChanged(SCITER_ELEMENT elem) override;
|
||||
|
||||
// IClickSink
|
||||
bool OnClick(SCITER_ELEMENT element, SCITER_ELEMENT source, uint32_t reason) override;
|
||||
|
||||
// IMouseUpDownSink
|
||||
bool OnMouseUp(SCITER_ELEMENT element, SCITER_ELEMENT source, uint32_t x, uint32_t y) override;
|
||||
bool OnMouseDown(SCITER_ELEMENT element, SCITER_ELEMENT source, uint32_t x, uint32_t y) override;
|
||||
|
||||
// IStateChangeSink
|
||||
bool OnStateChange(SCITER_ELEMENT elem, uint32_t eventReason, void* data) override;
|
||||
|
||||
static void SettingChanged(const char* setting, void* userData);
|
||||
|
||||
ISciterUI & m_sciterUI;
|
||||
ISciterWindow * m_window;
|
||||
|
|
@ -78,4 +95,5 @@ private:
|
|||
void * m_renderWindow;
|
||||
std::string m_windowTitle;
|
||||
SystemConfig m_systemConfig;
|
||||
bool m_volumePopup;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue