From 213879771e05ae3e963c19f6951d94361ddd660f Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Fri, 21 Aug 2015 20:56:39 +1000 Subject: [PATCH] Update to v094r41 release (open beta). byuu says: Changelog (since the last open beta): - icarus is now included. icarus is used to import game files/archives into game paks (folders) - SNES: mid-scanline BGMODE changes now emulated correctly (used only by atx2.smc Anthrox Demo) - GBA: fixed a CPU bug that was causing dozens of games to have distorted audio - GBA: fixed default FlashROM ID; should allow much higher compatibility - GBA: now using Cydrak's new, much improved, GBA color emulation filter (still a work-in-progress) - re-added command-line loading support for game paks (not for game files/archives, sorry!) - Qt port now compiles and runs again (may be a little buggy; Windows/GTK+ ports preferred) - SNES performance profile now compiles and runs again - much more --- emulator/emulator.hpp | 2 +- gba/video/video.cpp | 11 +++ hiro/components.hpp | 4 +- hiro/core/core.cpp | 4 +- hiro/core/core.hpp | 42 ++++++++-- hiro/core/font.cpp | 58 +++++++++++++ hiro/core/shared.hpp | 12 +-- hiro/core/widget/combo-button.cpp | 1 + hiro/core/widget/horizontal-scroll-bar.cpp | 38 +++++++++ hiro/core/widget/horizontal-scroller.cpp | 38 --------- hiro/core/widget/list-view.cpp | 7 +- hiro/core/widget/vertical-scroll-bar.cpp | 38 +++++++++ hiro/core/widget/vertical-scroller.cpp | 38 --------- hiro/gtk/platform.cpp | 4 +- hiro/gtk/platform.hpp | 4 +- ...scroller.cpp => horizontal-scroll-bar.cpp} | 16 ++-- ...scroller.hpp => horizontal-scroll-bar.hpp} | 6 +- hiro/gtk/widget/list-view.cpp | 14 +--- hiro/gtk/widget/list-view.hpp | 1 - ...l-scroller.cpp => vertical-scroll-bar.cpp} | 16 ++-- ...l-scroller.hpp => vertical-scroll-bar.hpp} | 6 +- hiro/qt/action/action.cpp | 44 +--------- hiro/qt/action/menu.cpp | 6 +- hiro/qt/action/menu.hpp | 1 - hiro/qt/font.cpp | 2 +- hiro/qt/platform.cpp | 4 +- hiro/qt/platform.hpp | 4 +- hiro/qt/qt.hpp | 20 ++--- hiro/qt/qt.moc | 80 +++++++++--------- hiro/qt/widget/combo-button-item.cpp | 2 + hiro/qt/widget/combo-button.cpp | 10 ++- hiro/qt/widget/horizontal-scroll-bar.cpp | 46 ++++++++++ ...scroller.hpp => horizontal-scroll-bar.hpp} | 8 +- hiro/qt/widget/horizontal-scroller.cpp | 46 ---------- hiro/qt/widget/list-view-cell.cpp | 26 +++--- hiro/qt/widget/list-view-item.cpp | 2 + hiro/qt/widget/list-view.cpp | 41 ++++----- hiro/qt/widget/list-view.hpp | 1 - hiro/qt/widget/tab-frame-item.cpp | 4 + hiro/qt/widget/tab-frame.cpp | 84 ++----------------- hiro/qt/widget/vertical-scroll-bar.cpp | 46 ++++++++++ ...l-scroller.hpp => vertical-scroll-bar.hpp} | 8 +- hiro/qt/widget/vertical-scroller.cpp | 46 ---------- hiro/windows/platform.cpp | 4 +- hiro/windows/platform.hpp | 4 +- hiro/windows/utility.cpp | 14 ++-- hiro/windows/widget/check-button.cpp | 2 +- hiro/windows/widget/check-button.hpp | 2 +- ...scroller.cpp => horizontal-scroll-bar.cpp} | 14 ++-- ...scroller.hpp => horizontal-scroll-bar.hpp} | 6 +- hiro/windows/widget/list-view.cpp | 32 +++---- hiro/windows/widget/list-view.hpp | 1 - hiro/windows/widget/radio-button.cpp | 2 +- hiro/windows/widget/radio-button.hpp | 2 +- ...l-scroller.cpp => vertical-scroll-bar.cpp} | 14 ++-- ...l-scroller.hpp => vertical-scroll-bar.hpp} | 6 +- hiro/windows/widget/vertical-slider.cpp | 2 +- nall/image/scale.hpp | 1 + nall/range.hpp | 7 +- target-tomoko/program/program.cpp | 6 +- target-tomoko/program/program.hpp | 2 +- target-tomoko/tomoko.cpp | 2 +- 62 files changed, 499 insertions(+), 515 deletions(-) create mode 100644 hiro/core/widget/horizontal-scroll-bar.cpp delete mode 100644 hiro/core/widget/horizontal-scroller.cpp create mode 100644 hiro/core/widget/vertical-scroll-bar.cpp delete mode 100644 hiro/core/widget/vertical-scroller.cpp rename hiro/gtk/widget/{horizontal-scroller.cpp => horizontal-scroll-bar.cpp} (60%) rename hiro/gtk/widget/{horizontal-scroller.hpp => horizontal-scroll-bar.hpp} (57%) rename hiro/gtk/widget/{vertical-scroller.cpp => vertical-scroll-bar.cpp} (61%) rename hiro/gtk/widget/{vertical-scroller.hpp => vertical-scroll-bar.hpp} (59%) create mode 100644 hiro/qt/widget/horizontal-scroll-bar.cpp rename hiro/qt/widget/{horizontal-scroller.hpp => horizontal-scroll-bar.hpp} (53%) delete mode 100644 hiro/qt/widget/horizontal-scroller.cpp create mode 100644 hiro/qt/widget/vertical-scroll-bar.cpp rename hiro/qt/widget/{vertical-scroller.hpp => vertical-scroll-bar.hpp} (54%) delete mode 100644 hiro/qt/widget/vertical-scroller.cpp rename hiro/windows/widget/{horizontal-scroller.cpp => horizontal-scroll-bar.cpp} (63%) rename hiro/windows/widget/{horizontal-scroller.hpp => horizontal-scroll-bar.hpp} (64%) rename hiro/windows/widget/{vertical-scroller.cpp => vertical-scroll-bar.cpp} (63%) rename hiro/windows/widget/{vertical-scroller.hpp => vertical-scroll-bar.hpp} (65%) diff --git a/emulator/emulator.hpp b/emulator/emulator.hpp index bfea967b..bab451f2 100644 --- a/emulator/emulator.hpp +++ b/emulator/emulator.hpp @@ -8,7 +8,7 @@ using namespace nall; namespace Emulator { static const string Name = "higan"; - static const string Version = "094.40"; + static const string Version = "094.41"; static const string Author = "byuu"; static const string License = "GPLv3"; static const string Website = "http://byuu.org/"; diff --git a/gba/video/video.cpp b/gba/video/video.cpp index 3b6afa97..55b83ceb 100644 --- a/gba/video/video.cpp +++ b/gba/video/video.cpp @@ -32,6 +32,7 @@ void Video::generate_palette(Emulator::Interface::PaletteMode mode) { } if(mode == Emulator::Interface::PaletteMode::Emulation) { +#if 0 R = curve[R]; G = curve[G]; B = curve[B]; @@ -67,6 +68,16 @@ void Video::generate_palette(Emulator::Interface::PaletteMode mode) { R = image::normalize(R, 8, 16); G = image::normalize(G, 8, 16); B = image::normalize(B, 8, 16); +#else + double lcdGamma = 4.0, outGamma = 2.2; + double lb = pow(B / 31.0, lcdGamma); + double lg = pow(G / 31.0, lcdGamma); + double lr = pow(R / 31.0, lcdGamma); + B = pow((220 * lb + 10 * lg + 50 * lr) / 255, 1 / outGamma) * (0xffff * 255 / 280); + G = pow(( 30 * lb + 230 * lg + 10 * lr) / 255, 1 / outGamma) * (0xffff * 255 / 280); + R = pow(( 0 * lb + 50 * lg + 255 * lr) / 255, 1 / outGamma) * (0xffff * 255 / 280); +#endif + palette[color] = interface->videoColor(color, 0, R, G, B); continue; } diff --git a/hiro/components.hpp b/hiro/components.hpp index eb85db7d..be188659 100644 --- a/hiro/components.hpp +++ b/hiro/components.hpp @@ -54,7 +54,7 @@ #define Hiro_Console #define Hiro_Frame #define Hiro_HexEdit -#define Hiro_HorizontalScroller +#define Hiro_HorizontalScrollBar #define Hiro_HorizontalSlider #define Hiro_IconView #define Hiro_Label @@ -67,7 +67,7 @@ #define Hiro_TabFrame #define Hiro_TextEdit #define Hiro_TreeView -#define Hiro_VerticalScroller +#define Hiro_VerticalScrollBar #define Hiro_VerticalSlider #define Hiro_Viewport diff --git a/hiro/core/core.cpp b/hiro/core/core.cpp index db203bb6..d25f6c6a 100644 --- a/hiro/core/core.cpp +++ b/hiro/core/core.cpp @@ -75,7 +75,7 @@ namespace hiro { #include "widget/console.cpp" #include "widget/frame.cpp" #include "widget/hex-edit.cpp" - #include "widget/horizontal-scroller.cpp" + #include "widget/horizontal-scroll-bar.cpp" #include "widget/horizontal-slider.cpp" #include "widget/icon-view.cpp" #include "widget/icon-view-item.cpp" @@ -95,7 +95,7 @@ namespace hiro { #include "widget/text-edit.cpp" #include "widget/tree-view.cpp" #include "widget/tree-view-item.cpp" - #include "widget/vertical-scroller.cpp" + #include "widget/vertical-scroll-bar.cpp" #include "widget/vertical-slider.cpp" #include "widget/viewport.cpp" } diff --git a/hiro/core/core.hpp b/hiro/core/core.hpp index 0557834f..ebee01fd 100644 --- a/hiro/core/core.hpp +++ b/hiro/core/core.hpp @@ -57,7 +57,7 @@ Declare(ComboButtonItem) Declare(Console) Declare(Frame) Declare(HexEdit) -Declare(HorizontalScroller) +Declare(HorizontalScrollBar) Declare(HorizontalSlider) Declare(IconView) Declare(IconViewItem) @@ -77,7 +77,7 @@ Declare(TabFrameItem) Declare(TextEdit) Declare(TreeView) Declare(TreeViewItem) -Declare(VerticalScroller) +Declare(VerticalScrollBar) Declare(VerticalSlider) Declare(Viewport) @@ -297,12 +297,36 @@ struct Geometry { #if defined(Hiro_Font) struct Font { - Font() = delete; + using type = Font; + + Font(); + Font(const string& family, unsigned size = 0); + + explicit operator bool() const; + auto operator==(const Font& source) const -> bool; + auto operator!=(const Font& source) const -> bool; + + auto bold() const -> bool; + auto family() const -> string; + auto italic() const -> bool; + auto setBold(bool bold = true) -> type&; + auto setFamily(const string& family = "") -> type&; + auto setItalic(bool italic = true) -> type&; + auto setSize(unsigned size = 0) -> type&; + auto size() const -> unsigned; static auto serif(unsigned size = 0, const string& style = "") -> string; static auto sans(unsigned size = 0, const string& style = "") -> string; static auto monospace(unsigned size = 0, const string& style = "") -> string; static auto size(const string& font, const string& text = " ") -> Size; + +//private: + struct State { + string family; + unsigned size = 0; + bool bold = false; + bool italic = false; + } state; }; #endif @@ -1099,9 +1123,9 @@ struct mHexEdit : mWidget { }; #endif -#if defined(Hiro_HorizontalScroller) -struct mHorizontalScroller : mWidget { - Declare(HorizontalScroller) +#if defined(Hiro_HorizontalScrollBar) +struct mHorizontalScrollBar : mWidget { + Declare(HorizontalScrollBar) auto doChange() const -> void; auto length() const -> unsigned; @@ -1736,9 +1760,9 @@ struct mTreeViewItem : mObject { }; #endif -#if defined(Hiro_VerticalScroller) -struct mVerticalScroller : mWidget { - Declare(VerticalScroller) +#if defined(Hiro_VerticalScrollBar) +struct mVerticalScrollBar : mWidget { + Declare(VerticalScrollBar) auto doChange() const -> void; auto length() const -> unsigned; diff --git a/hiro/core/font.cpp b/hiro/core/font.cpp index d4274653..ec32f614 100644 --- a/hiro/core/font.cpp +++ b/hiro/core/font.cpp @@ -1,5 +1,63 @@ #if defined(Hiro_Font) +Font::Font() { +} + +Font::Font(const string& family, unsigned size) { + state.family = family; + state.size = size; +} + +Font::operator bool() const { + return state.family || state.size || state.bold || state.italic; +} + +auto Font::operator==(const Font& source) const -> bool { + return family() == source.family() || size() == source.size() && bold() == source.bold() && italic() == source.italic(); +}; + +auto Font::operator!=(const Font& source) const -> bool { + return !operator==(source); +} + +auto Font::bold() const -> bool { + return state.bold; +} + +auto Font::family() const -> string { + return state.family; +} + +auto Font::italic() const -> bool { + return state.italic; +} + +auto Font::setBold(bool bold) -> type& { + state.bold = bold; + return *this; +} + +auto Font::setFamily(const string& family) -> type& { + state.family = family; + return *this; +} + +auto Font::setItalic(bool italic) -> type& { + state.italic = italic; + return *this; +} + +auto Font::setSize(unsigned size) -> type& { + state.size = size; + return *this; +} + +auto Font::size() const -> unsigned { + return state.size; +} + +// + auto Font::serif(unsigned size, const string& style) -> string { return pFont::serif(size, style); } diff --git a/hiro/core/shared.hpp b/hiro/core/shared.hpp index 910d6dc9..efbf7c65 100644 --- a/hiro/core/shared.hpp +++ b/hiro/core/shared.hpp @@ -358,9 +358,9 @@ struct HexEdit : sHexEdit { }; #endif -#if defined(Hiro_HorizontalScroller) -struct HorizontalScroller : sHorizontalScroller { - DeclareSharedWidget(HorizontalScroller) +#if defined(Hiro_HorizontalScrollBar) +struct HorizontalScrollBar : sHorizontalScrollBar { + DeclareSharedWidget(HorizontalScrollBar) auto doChange() const { return self().doChange(); } auto length() const { return self().length(); } @@ -762,9 +762,9 @@ struct TreeView : sTreeView { }; #endif -#if defined(Hiro_VerticalScroller) -struct VerticalScroller : sVerticalScroller { - DeclareSharedWidget(VerticalScroller) +#if defined(Hiro_VerticalScrollBar) +struct VerticalScrollBar : sVerticalScrollBar { + DeclareSharedWidget(VerticalScrollBar) auto doChange() const { return self().doChange(); } auto length() const { return self().length(); } diff --git a/hiro/core/widget/combo-button.cpp b/hiro/core/widget/combo-button.cpp index cc5b101e..8291a742 100644 --- a/hiro/core/widget/combo-button.cpp +++ b/hiro/core/widget/combo-button.cpp @@ -12,6 +12,7 @@ auto mComboButton::destruct() -> void { // auto mComboButton::append(sComboButtonItem item) -> type& { + if(!state.items) item->state.selected = true; state.items.append(item); item->setParent(this, itemCount() - 1); signal(append, item); diff --git a/hiro/core/widget/horizontal-scroll-bar.cpp b/hiro/core/widget/horizontal-scroll-bar.cpp new file mode 100644 index 00000000..226b1bc6 --- /dev/null +++ b/hiro/core/widget/horizontal-scroll-bar.cpp @@ -0,0 +1,38 @@ +#if defined(Hiro_HorizontalScrollBar) + +auto mHorizontalScrollBar::allocate() -> pObject* { + return new pHorizontalScrollBar(*this); +} + +// + +auto mHorizontalScrollBar::doChange() const -> void { + if(state.onChange) return state.onChange(); +} + +auto mHorizontalScrollBar::length() const -> unsigned { + return state.length; +} + +auto mHorizontalScrollBar::onChange(const function& callback) -> type& { + state.onChange = callback; + return *this; +} + +auto mHorizontalScrollBar::position() const -> unsigned { + return state.position; +} + +auto mHorizontalScrollBar::setLength(unsigned length) -> type& { + state.length = length; + signal(setLength, length); + return *this; +} + +auto mHorizontalScrollBar::setPosition(unsigned position) -> type& { + state.position = position; + signal(setPosition, position); + return *this; +} + +#endif diff --git a/hiro/core/widget/horizontal-scroller.cpp b/hiro/core/widget/horizontal-scroller.cpp deleted file mode 100644 index 038e8041..00000000 --- a/hiro/core/widget/horizontal-scroller.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#if defined(Hiro_HorizontalScroller) - -auto mHorizontalScroller::allocate() -> pObject* { - return new pHorizontalScroller(*this); -} - -// - -auto mHorizontalScroller::doChange() const -> void { - if(state.onChange) return state.onChange(); -} - -auto mHorizontalScroller::length() const -> unsigned { - return state.length; -} - -auto mHorizontalScroller::onChange(const function& callback) -> type& { - state.onChange = callback; - return *this; -} - -auto mHorizontalScroller::position() const -> unsigned { - return state.position; -} - -auto mHorizontalScroller::setLength(unsigned length) -> type& { - state.length = length; - signal(setLength, length); - return *this; -} - -auto mHorizontalScroller::setPosition(unsigned position) -> type& { - state.position = position; - signal(setPosition, position); - return *this; -} - -#endif diff --git a/hiro/core/widget/list-view.cpp b/hiro/core/widget/list-view.cpp index fe072c48..2307449c 100644 --- a/hiro/core/widget/list-view.cpp +++ b/hiro/core/widget/list-view.cpp @@ -146,11 +146,8 @@ auto mListView::remove(sListViewItem item) -> type& { } auto mListView::reset() -> type& { - signal(reset); - for(auto& item : state.items) item->setParent(); - state.items.reset(); - if(auto& header = state.header) header->setParent(); - state.header.reset(); + for(auto n : rrange(state.items)) remove(state.items[n]); + if(auto& header = state.header) remove(header); return *this; } diff --git a/hiro/core/widget/vertical-scroll-bar.cpp b/hiro/core/widget/vertical-scroll-bar.cpp new file mode 100644 index 00000000..d32409bb --- /dev/null +++ b/hiro/core/widget/vertical-scroll-bar.cpp @@ -0,0 +1,38 @@ +#if defined(Hiro_VerticalScrollBar) + +auto mVerticalScrollBar::allocate() -> pObject* { + return new pVerticalScrollBar(*this); +} + +// + +auto mVerticalScrollBar::doChange() const -> void { + if(state.onChange) return state.onChange(); +} + +auto mVerticalScrollBar::length() const -> unsigned { + return state.length; +} + +auto mVerticalScrollBar::onChange(const function& callback) -> type& { + state.onChange = callback; + return *this; +} + +auto mVerticalScrollBar::position() const -> unsigned { + return state.position; +} + +auto mVerticalScrollBar::setLength(unsigned length) -> type& { + state.length = length; + signal(setLength, length); + return *this; +} + +auto mVerticalScrollBar::setPosition(unsigned position) -> type& { + state.position = position; + signal(setPosition, position); + return *this; +} + +#endif diff --git a/hiro/core/widget/vertical-scroller.cpp b/hiro/core/widget/vertical-scroller.cpp deleted file mode 100644 index 7212c00f..00000000 --- a/hiro/core/widget/vertical-scroller.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#if defined(Hiro_VerticalScroller) - -auto mVerticalScroller::allocate() -> pObject* { - return new pVerticalScroller(*this); -} - -// - -auto mVerticalScroller::doChange() const -> void { - if(state.onChange) return state.onChange(); -} - -auto mVerticalScroller::length() const -> unsigned { - return state.length; -} - -auto mVerticalScroller::onChange(const function& callback) -> type& { - state.onChange = callback; - return *this; -} - -auto mVerticalScroller::position() const -> unsigned { - return state.position; -} - -auto mVerticalScroller::setLength(unsigned length) -> type& { - state.length = length; - signal(setLength, length); - return *this; -} - -auto mVerticalScroller::setPosition(unsigned position) -> type& { - state.position = position; - signal(setPosition, position); - return *this; -} - -#endif diff --git a/hiro/gtk/platform.cpp b/hiro/gtk/platform.cpp index cec3032f..3253c49d 100644 --- a/hiro/gtk/platform.cpp +++ b/hiro/gtk/platform.cpp @@ -39,7 +39,7 @@ #include "widget/console.cpp" #include "widget/frame.cpp" #include "widget/hex-edit.cpp" -#include "widget/horizontal-scroller.cpp" +#include "widget/horizontal-scroll-bar.cpp" #include "widget/horizontal-slider.cpp" #include "widget/icon-view.cpp" #include "widget/icon-view-item.cpp" @@ -59,7 +59,7 @@ #include "widget/text-edit.cpp" #include "widget/tree-view.cpp" #include "widget/tree-view-item.cpp" -#include "widget/vertical-scroller.cpp" +#include "widget/vertical-scroll-bar.cpp" #include "widget/vertical-slider.cpp" #include "widget/viewport.cpp" diff --git a/hiro/gtk/platform.hpp b/hiro/gtk/platform.hpp index d99086b7..c572eab1 100644 --- a/hiro/gtk/platform.hpp +++ b/hiro/gtk/platform.hpp @@ -50,7 +50,7 @@ namespace hiro { #include "widget/console.hpp" #include "widget/frame.hpp" #include "widget/hex-edit.hpp" -#include "widget/horizontal-scroller.hpp" +#include "widget/horizontal-scroll-bar.hpp" #include "widget/horizontal-slider.hpp" #include "widget/icon-view.hpp" #include "widget/icon-view-item.hpp" @@ -70,7 +70,7 @@ namespace hiro { #include "widget/text-edit.hpp" #include "widget/tree-view.hpp" #include "widget/tree-view-item.hpp" -#include "widget/vertical-scroller.hpp" +#include "widget/vertical-scroll-bar.hpp" #include "widget/vertical-slider.hpp" #include "widget/viewport.hpp" diff --git a/hiro/gtk/widget/horizontal-scroller.cpp b/hiro/gtk/widget/horizontal-scroll-bar.cpp similarity index 60% rename from hiro/gtk/widget/horizontal-scroller.cpp rename to hiro/gtk/widget/horizontal-scroll-bar.cpp index fff85179..30521b58 100644 --- a/hiro/gtk/widget/horizontal-scroller.cpp +++ b/hiro/gtk/widget/horizontal-scroll-bar.cpp @@ -1,34 +1,34 @@ -#if defined(Hiro_HorizontalScroller) +#if defined(Hiro_HorizontalScrollBar) namespace hiro { -static auto HorizontalScroller_change(GtkRange* gtkRange, pHorizontalScroller* p) -> void { +static auto HorizontalScrollBar_change(GtkRange* gtkRange, pHorizontalScrollBar* p) -> void { auto position = (unsigned)gtk_range_get_value(gtkRange); if(p->state().position == position) return; p->state().position = position; if(!p->locked()) p->self().doChange(); } -auto pHorizontalScroller::construct() -> void { +auto pHorizontalScrollBar::construct() -> void { gtkWidget = gtk_hscrollbar_new(0); setLength(state().length); setPosition(state().position); - g_signal_connect(G_OBJECT(gtkWidget), "value-changed", G_CALLBACK(HorizontalScroller_change), (gpointer)this); + g_signal_connect(G_OBJECT(gtkWidget), "value-changed", G_CALLBACK(HorizontalScrollBar_change), (gpointer)this); pWidget::construct(); } -auto pHorizontalScroller::destruct() -> void { +auto pHorizontalScrollBar::destruct() -> void { gtk_widget_destroy(gtkWidget); } -auto pHorizontalScroller::minimumSize() const -> Size { +auto pHorizontalScrollBar::minimumSize() const -> Size { return {0, 20}; } -auto pHorizontalScroller::setLength(unsigned length) -> void { +auto pHorizontalScrollBar::setLength(unsigned length) -> void { lock(); length += length == 0; gtk_range_set_range(GTK_RANGE(gtkWidget), 0, max(1u, length - 1)); @@ -36,7 +36,7 @@ auto pHorizontalScroller::setLength(unsigned length) -> void { unlock(); } -auto pHorizontalScroller::setPosition(unsigned position) -> void { +auto pHorizontalScrollBar::setPosition(unsigned position) -> void { gtk_range_set_value(GTK_RANGE(gtkWidget), position); } diff --git a/hiro/gtk/widget/horizontal-scroller.hpp b/hiro/gtk/widget/horizontal-scroll-bar.hpp similarity index 57% rename from hiro/gtk/widget/horizontal-scroller.hpp rename to hiro/gtk/widget/horizontal-scroll-bar.hpp index 368bef93..2cb63920 100644 --- a/hiro/gtk/widget/horizontal-scroller.hpp +++ b/hiro/gtk/widget/horizontal-scroll-bar.hpp @@ -1,9 +1,9 @@ -#if defined(Hiro_HorizontalScroller) +#if defined(Hiro_HorizontalScrollBar) namespace hiro { -struct pHorizontalScroller : pWidget { - Declare(HorizontalScroller, Widget) +struct pHorizontalScrollBar : pWidget { + Declare(HorizontalScrollBar, Widget) auto minimumSize() const -> Size; auto setLength(unsigned length) -> void; diff --git a/hiro/gtk/widget/list-view.cpp b/hiro/gtk/widget/list-view.cpp index 7f4ccd65..f2bd8ec3 100644 --- a/hiro/gtk/widget/list-view.cpp +++ b/hiro/gtk/widget/list-view.cpp @@ -66,18 +66,6 @@ auto pListView::remove(sListViewHeader header) -> void { auto pListView::remove(sListViewItem item) -> void { } -auto pListView::reset() -> void { - GList* list = gtk_tree_view_get_columns(gtkTreeView); - GList* p = list; - while(p && p->data) { - gtk_tree_view_remove_column(gtkTreeView, (GtkTreeViewColumn*)p->data); - p = p->next; - } - g_list_free(list); - _createModel(); - gtk_tree_view_set_rules_hint(gtkTreeView, false); -} - auto pListView::resizeColumns() -> void { lock(); @@ -159,7 +147,7 @@ auto pListView::_cellWidth(unsigned _row, unsigned _column) -> unsigned { if(auto item = self().item(_row)) { if(auto cell = item->cell(_column)) { if(cell->state.checkable) { - width += 32; + width += 24; } if(auto& icon = cell->state.icon) { width += icon.width() + 2; diff --git a/hiro/gtk/widget/list-view.hpp b/hiro/gtk/widget/list-view.hpp index b59f9386..d87cc3bd 100644 --- a/hiro/gtk/widget/list-view.hpp +++ b/hiro/gtk/widget/list-view.hpp @@ -10,7 +10,6 @@ struct pListView : pWidget { auto focused() const -> bool override; auto remove(sListViewHeader column) -> void; auto remove(sListViewItem item) -> void; - auto reset() -> void; auto resizeColumns() -> void; auto setAlignment(Alignment alignment) -> void; auto setBackgroundColor(Color color) -> void; diff --git a/hiro/gtk/widget/vertical-scroller.cpp b/hiro/gtk/widget/vertical-scroll-bar.cpp similarity index 61% rename from hiro/gtk/widget/vertical-scroller.cpp rename to hiro/gtk/widget/vertical-scroll-bar.cpp index becb1138..45848dfc 100644 --- a/hiro/gtk/widget/vertical-scroller.cpp +++ b/hiro/gtk/widget/vertical-scroll-bar.cpp @@ -1,34 +1,34 @@ -#if defined(Hiro_VerticalScroller) +#if defined(Hiro_VerticalScrollBar) namespace hiro { -static auto VerticalScroller_change(GtkRange* gtkRange, pVerticalScroller* p) -> void { +static auto VerticalScrollBar_change(GtkRange* gtkRange, pVerticalScrollBar* p) -> void { auto position = (unsigned)gtk_range_get_value(gtkRange); if(p->state().position == position) return; p->state().position = position; if(!p->locked()) p->self().doChange(); } -auto pVerticalScroller::construct() -> void { +auto pVerticalScrollBar::construct() -> void { gtkWidget = gtk_vscrollbar_new(0); setLength(state().length); setPosition(state().position); - g_signal_connect(G_OBJECT(gtkWidget), "value-changed", G_CALLBACK(VerticalScroller_change), (gpointer)this); + g_signal_connect(G_OBJECT(gtkWidget), "value-changed", G_CALLBACK(VerticalScrollBar_change), (gpointer)this); pWidget::construct(); } -auto pVerticalScroller::destruct() -> void { +auto pVerticalScrollBar::destruct() -> void { gtk_widget_destroy(gtkWidget); } -auto pVerticalScroller::minimumSize() const -> Size { +auto pVerticalScrollBar::minimumSize() const -> Size { return {20, 0}; } -auto pVerticalScroller::setLength(unsigned length) -> void { +auto pVerticalScrollBar::setLength(unsigned length) -> void { lock(); length += length == 0; gtk_range_set_range(GTK_RANGE(gtkWidget), 0, max(1u, length - 1)); @@ -36,7 +36,7 @@ auto pVerticalScroller::setLength(unsigned length) -> void { unlock(); } -auto pVerticalScroller::setPosition(unsigned position) -> void { +auto pVerticalScrollBar::setPosition(unsigned position) -> void { gtk_range_set_value(GTK_RANGE(gtkWidget), position); } diff --git a/hiro/gtk/widget/vertical-scroller.hpp b/hiro/gtk/widget/vertical-scroll-bar.hpp similarity index 59% rename from hiro/gtk/widget/vertical-scroller.hpp rename to hiro/gtk/widget/vertical-scroll-bar.hpp index 5de257e4..37db9532 100644 --- a/hiro/gtk/widget/vertical-scroller.hpp +++ b/hiro/gtk/widget/vertical-scroll-bar.hpp @@ -1,9 +1,9 @@ -#if defined(Hiro_VerticalScroller) +#if defined(Hiro_VerticalScrollBar) namespace hiro { -struct pVerticalScroller : pWidget { - Declare(VerticalScroller, Widget) +struct pVerticalScrollBar : pWidget { + Declare(VerticalScrollBar, Widget) auto minimumSize() const -> Size; auto setLength(unsigned length) -> void; diff --git a/hiro/qt/action/action.cpp b/hiro/qt/action/action.cpp index 945679ee..cf4541b8 100644 --- a/hiro/qt/action/action.cpp +++ b/hiro/qt/action/action.cpp @@ -9,53 +9,15 @@ auto pAction::destruct() -> void { } auto pAction::setEnabled(bool enabled) -> void { -/* - if(dynamic_cast(&action)) { - ((Menu&)action).p.qtMenu->setEnabled(enabled); - } else if(dynamic_cast(&action)) { - ((Separator&)action).p.qtAction->setEnabled(enabled); - } else if(dynamic_cast(&action)) { - ((Item&)action).p.qtAction->setEnabled(enabled); - } else if(dynamic_cast(&action)) { - ((CheckItem&)action).p.qtAction->setEnabled(enabled); - } else if(dynamic_cast(&action)) { - ((RadioItem&)action).p.qtAction->setEnabled(enabled); - } -*/ + _setState(); } auto pAction::setFont(const string& font) -> void { -/* - QFont qtFont = pFont::create(font); - - if(dynamic_cast(&action)) { - ((Menu&)action).p.setFont(font); - } else if(dynamic_cast(&action)) { - ((Separator&)action).p.qtAction->setFont(qtFont); - } else if(dynamic_cast(&action)) { - ((Item&)action).p.qtAction->setFont(qtFont); - } else if(dynamic_cast(&action)) { - ((CheckItem&)action).p.qtAction->setFont(qtFont); - } else if(dynamic_cast(&action)) { - ((RadioItem&)action).p.qtAction->setFont(qtFont); - } -*/ + _setState(); } auto pAction::setVisible(bool visible) -> void { -/* - if(dynamic_cast(&action)) { - ((Menu&)action).p.qtMenu->menuAction()->setVisible(visible); - } else if(dynamic_cast(&action)) { - ((Separator&)action).p.qtAction->setVisible(visible); - } else if(dynamic_cast(&action)) { - ((Item&)action).p.qtAction->setVisible(visible); - } else if(dynamic_cast(&action)) { - ((CheckItem&)action).p.qtAction->setVisible(visible); - } else if(dynamic_cast(&action)) { - ((RadioItem&)action).p.qtAction->setVisible(visible); - } -*/ + _setState(); } auto pAction::_parentMenu() -> maybe { diff --git a/hiro/qt/action/menu.cpp b/hiro/qt/action/menu.cpp index 17f0b345..001444bd 100644 --- a/hiro/qt/action/menu.cpp +++ b/hiro/qt/action/menu.cpp @@ -33,10 +33,6 @@ auto pMenu::append(sAction action) -> void { auto pMenu::remove(sAction action) -> void { } -auto pMenu::setFont(const string& font) -> void { - _setState(); -} - auto pMenu::setIcon(const image& icon) -> void { _setState(); } @@ -46,9 +42,11 @@ auto pMenu::setText(const string& text) -> void { } auto pMenu::_setState() -> void { + qtMenu->setEnabled(self().enabled()); qtMenu->setFont(pFont::create(self().font(true))); qtMenu->setIcon(CreateIcon(state().icon)); qtMenu->setTitle(QString::fromUtf8(state().text)); + qtMenu->menuAction()->setVisible(self().visible()); for(auto& action : state().actions) { if(auto self = action->self()) self->setFont(action->font(true)); diff --git a/hiro/qt/action/menu.hpp b/hiro/qt/action/menu.hpp index 79efa66c..f09ca43d 100644 --- a/hiro/qt/action/menu.hpp +++ b/hiro/qt/action/menu.hpp @@ -7,7 +7,6 @@ struct pMenu : public pAction { auto append(sAction action) -> void; auto remove(sAction action) -> void; - auto setFont(const string& font) -> void override; auto setIcon(const image& icon) -> void; auto setText(const string& text) -> void; diff --git a/hiro/qt/font.cpp b/hiro/qt/font.cpp index fcdf26e5..b839328a 100644 --- a/hiro/qt/font.cpp +++ b/hiro/qt/font.cpp @@ -49,7 +49,7 @@ auto pFont::size(const QFont& qtFont, const string& text) -> Size { QFontMetrics metrics(qtFont); lstring lines; - lines.split("\n", text ? text : " "); + lines.split(text ? text : " ", "\n"); unsigned maxWidth = 0; for(auto& line : lines) { diff --git a/hiro/qt/platform.cpp b/hiro/qt/platform.cpp index aac1de03..91b09819 100644 --- a/hiro/qt/platform.cpp +++ b/hiro/qt/platform.cpp @@ -43,7 +43,7 @@ #include "widget/console.cpp" #include "widget/frame.cpp" #include "widget/hex-edit.cpp" -#include "widget/horizontal-scroller.cpp" +#include "widget/horizontal-scroll-bar.cpp" #include "widget/horizontal-slider.cpp" #include "widget/icon-view.cpp" #include "widget/label.cpp" @@ -59,7 +59,7 @@ #include "widget/tab-frame.cpp" #include "widget/tab-frame-item.cpp" #include "widget/text-edit.cpp" -#include "widget/vertical-scroller.cpp" +#include "widget/vertical-scroll-bar.cpp" #include "widget/vertical-slider.cpp" #include "widget/viewport.cpp" diff --git a/hiro/qt/platform.hpp b/hiro/qt/platform.hpp index 82c0226a..d4454121 100644 --- a/hiro/qt/platform.hpp +++ b/hiro/qt/platform.hpp @@ -45,7 +45,7 @@ #include "widget/combo-button-item.hpp" #include "widget/frame.hpp" #include "widget/hex-edit.hpp" -#include "widget/horizontal-scroller.hpp" +#include "widget/horizontal-scroll-bar.hpp" #include "widget/horizontal-slider.hpp" #include "widget/label.hpp" #include "widget/line-edit.hpp" @@ -60,7 +60,7 @@ #include "widget/tab-frame.hpp" #include "widget/tab-frame-item.hpp" #include "widget/text-edit.hpp" -#include "widget/vertical-scroller.hpp" +#include "widget/vertical-scroll-bar.hpp" #include "widget/vertical-slider.hpp" #include "widget/viewport.hpp" diff --git a/hiro/qt/qt.hpp b/hiro/qt/qt.hpp index b5263547..df41bdab 100644 --- a/hiro/qt/qt.hpp +++ b/hiro/qt/qt.hpp @@ -134,7 +134,7 @@ public: QtComboButton(pComboButton& p) : p(p) {} pComboButton& p; public slots: - void onChange(); + void onChange(int offset); }; #endif @@ -160,12 +160,12 @@ public slots: }; #endif -#if defined(Hiro_HorizontalScroller) -struct QtHorizontalScroller : public QScrollBar { +#if defined(Hiro_HorizontalScrollBar) +struct QtHorizontalScrollBar : public QScrollBar { Q_OBJECT public: - QtHorizontalScroller(pHorizontalScroller& p) : QScrollBar(Qt::Horizontal), p(p) {} - pHorizontalScroller& p; + QtHorizontalScrollBar(pHorizontalScrollBar& p) : QScrollBar(Qt::Horizontal), p(p) {} + pHorizontalScrollBar& p; public slots: void onChange(); }; @@ -208,7 +208,7 @@ public slots: void onChange(); void onContext(); void onSort(int column); - void onToggle(QTreeWidgetItem* item); + void onToggle(QTreeWidgetItem* item, int column); }; struct QtListViewDelegate : public QStyledItemDelegate { @@ -263,12 +263,12 @@ public slots: }; #endif -#if defined(Hiro_VerticalScroller) -struct QtVerticalScroller : public QScrollBar { +#if defined(Hiro_VerticalScrollBar) +struct QtVerticalScrollBar : public QScrollBar { Q_OBJECT public: - QtVerticalScroller(pVerticalScroller& p) : QScrollBar(Qt::Vertical), p(p) {} - pVerticalScroller& p; + QtVerticalScrollBar(pVerticalScrollBar& p) : QScrollBar(Qt::Vertical), p(p) {} + pVerticalScrollBar& p; public slots: void onChange(); }; diff --git a/hiro/qt/qt.moc b/hiro/qt/qt.moc index c0b4ce98..c3014c88 100644 --- a/hiro/qt/qt.moc +++ b/hiro/qt/qt.moc @@ -608,13 +608,14 @@ static const uint qt_meta_data_hiro__QtComboButton[] = { 0, // signalCount // slots: signature, parameters, type, tag, flags - 20, 31, 31, 31, 0x0a, + 20, 34, 41, 41, 0x0a, 0 // eod }; static const char qt_meta_stringdata_hiro__QtComboButton[] = { - "hiro::QtComboButton\0onChange()\0\0" + "hiro::QtComboButton\0onChange(int)\0" + "offset\0\0" }; void hiro::QtComboButton::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) @@ -623,11 +624,10 @@ void hiro::QtComboButton::qt_static_metacall(QObject *_o, QMetaObject::Call _c, Q_ASSERT(staticMetaObject.cast(_o)); QtComboButton *_t = static_cast(_o); switch (_id) { - case 0: _t->onChange(); break; + case 0: _t->onChange((*reinterpret_cast< int(*)>(_a[1]))); break; default: ; } } - Q_UNUSED(_a); } const QMetaObjectExtraData hiro::QtComboButton::staticMetaObjectExtraData = { @@ -804,7 +804,7 @@ int hiro::QtHexEditScrollBar::qt_metacall(QMetaObject::Call _c, int _id, void ** } return _id; } -static const uint qt_meta_data_hiro__QtHorizontalScroller[] = { +static const uint qt_meta_data_hiro__QtHorizontalScrollBar[] = { // content: 6, // revision @@ -818,21 +818,21 @@ static const uint qt_meta_data_hiro__QtHorizontalScroller[] = { 0, // signalCount // slots: signature, parameters, type, tag, flags - 27, 38, 38, 38, 0x0a, + 28, 39, 39, 39, 0x0a, 0 // eod }; -static const char qt_meta_stringdata_hiro__QtHorizontalScroller[] = { - "hiro::QtHorizontalScroller\0onChange()\0" +static const char qt_meta_stringdata_hiro__QtHorizontalScrollBar[] = { + "hiro::QtHorizontalScrollBar\0onChange()\0" "\0" }; -void hiro::QtHorizontalScroller::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) +void hiro::QtHorizontalScrollBar::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { Q_ASSERT(staticMetaObject.cast(_o)); - QtHorizontalScroller *_t = static_cast(_o); + QtHorizontalScrollBar *_t = static_cast(_o); switch (_id) { case 0: _t->onChange(); break; default: ; @@ -841,33 +841,33 @@ void hiro::QtHorizontalScroller::qt_static_metacall(QObject *_o, QMetaObject::Ca Q_UNUSED(_a); } -const QMetaObjectExtraData hiro::QtHorizontalScroller::staticMetaObjectExtraData = { +const QMetaObjectExtraData hiro::QtHorizontalScrollBar::staticMetaObjectExtraData = { 0, qt_static_metacall }; -const QMetaObject hiro::QtHorizontalScroller::staticMetaObject = { - { &QScrollBar::staticMetaObject, qt_meta_stringdata_hiro__QtHorizontalScroller, - qt_meta_data_hiro__QtHorizontalScroller, &staticMetaObjectExtraData } +const QMetaObject hiro::QtHorizontalScrollBar::staticMetaObject = { + { &QScrollBar::staticMetaObject, qt_meta_stringdata_hiro__QtHorizontalScrollBar, + qt_meta_data_hiro__QtHorizontalScrollBar, &staticMetaObjectExtraData } }; #ifdef Q_NO_DATA_RELOCATION -const QMetaObject &hiro::QtHorizontalScroller::getStaticMetaObject() { return staticMetaObject; } +const QMetaObject &hiro::QtHorizontalScrollBar::getStaticMetaObject() { return staticMetaObject; } #endif //Q_NO_DATA_RELOCATION -const QMetaObject *hiro::QtHorizontalScroller::metaObject() const +const QMetaObject *hiro::QtHorizontalScrollBar::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; } -void *hiro::QtHorizontalScroller::qt_metacast(const char *_clname) +void *hiro::QtHorizontalScrollBar::qt_metacast(const char *_clname) { if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_hiro__QtHorizontalScroller)) - return static_cast(const_cast< QtHorizontalScroller*>(this)); + if (!strcmp(_clname, qt_meta_stringdata_hiro__QtHorizontalScrollBar)) + return static_cast(const_cast< QtHorizontalScrollBar*>(this)); return QScrollBar::qt_metacast(_clname); } -int hiro::QtHorizontalScroller::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +int hiro::QtHorizontalScrollBar::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QScrollBar::qt_metacall(_c, _id, _a); if (_id < 0) @@ -1049,7 +1049,7 @@ static const uint qt_meta_data_hiro__QtListView[] = { 31, 30, 30, 30, 0x0a, 42, 30, 30, 30, 0x0a, 54, 66, 30, 30, 0x0a, - 73, 100, 30, 30, 0x0a, + 73, 104, 30, 30, 0x0a, 0 // eod }; @@ -1057,8 +1057,8 @@ static const uint qt_meta_data_hiro__QtListView[] = { static const char qt_meta_stringdata_hiro__QtListView[] = { "hiro::QtListView\0onActivate()\0\0" "onChange()\0onContext()\0onSort(int)\0" - "column\0onToggle(QTreeWidgetItem*)\0" - "item\0" + "column\0onToggle(QTreeWidgetItem*,int)\0" + "item,column\0" }; void hiro::QtListView::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) @@ -1071,7 +1071,7 @@ void hiro::QtListView::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int case 1: _t->onChange(); break; case 2: _t->onContext(); break; case 3: _t->onSort((*reinterpret_cast< int(*)>(_a[1]))); break; - case 4: _t->onToggle((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1]))); break; + case 4: _t->onToggle((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; default: ; } } @@ -1411,7 +1411,7 @@ int hiro::QtTextEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a) } return _id; } -static const uint qt_meta_data_hiro__QtVerticalScroller[] = { +static const uint qt_meta_data_hiro__QtVerticalScrollBar[] = { // content: 6, // revision @@ -1425,21 +1425,21 @@ static const uint qt_meta_data_hiro__QtVerticalScroller[] = { 0, // signalCount // slots: signature, parameters, type, tag, flags - 25, 36, 36, 36, 0x0a, + 26, 37, 37, 37, 0x0a, 0 // eod }; -static const char qt_meta_stringdata_hiro__QtVerticalScroller[] = { - "hiro::QtVerticalScroller\0onChange()\0" +static const char qt_meta_stringdata_hiro__QtVerticalScrollBar[] = { + "hiro::QtVerticalScrollBar\0onChange()\0" "\0" }; -void hiro::QtVerticalScroller::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) +void hiro::QtVerticalScrollBar::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { Q_ASSERT(staticMetaObject.cast(_o)); - QtVerticalScroller *_t = static_cast(_o); + QtVerticalScrollBar *_t = static_cast(_o); switch (_id) { case 0: _t->onChange(); break; default: ; @@ -1448,33 +1448,33 @@ void hiro::QtVerticalScroller::qt_static_metacall(QObject *_o, QMetaObject::Call Q_UNUSED(_a); } -const QMetaObjectExtraData hiro::QtVerticalScroller::staticMetaObjectExtraData = { +const QMetaObjectExtraData hiro::QtVerticalScrollBar::staticMetaObjectExtraData = { 0, qt_static_metacall }; -const QMetaObject hiro::QtVerticalScroller::staticMetaObject = { - { &QScrollBar::staticMetaObject, qt_meta_stringdata_hiro__QtVerticalScroller, - qt_meta_data_hiro__QtVerticalScroller, &staticMetaObjectExtraData } +const QMetaObject hiro::QtVerticalScrollBar::staticMetaObject = { + { &QScrollBar::staticMetaObject, qt_meta_stringdata_hiro__QtVerticalScrollBar, + qt_meta_data_hiro__QtVerticalScrollBar, &staticMetaObjectExtraData } }; #ifdef Q_NO_DATA_RELOCATION -const QMetaObject &hiro::QtVerticalScroller::getStaticMetaObject() { return staticMetaObject; } +const QMetaObject &hiro::QtVerticalScrollBar::getStaticMetaObject() { return staticMetaObject; } #endif //Q_NO_DATA_RELOCATION -const QMetaObject *hiro::QtVerticalScroller::metaObject() const +const QMetaObject *hiro::QtVerticalScrollBar::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; } -void *hiro::QtVerticalScroller::qt_metacast(const char *_clname) +void *hiro::QtVerticalScrollBar::qt_metacast(const char *_clname) { if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_hiro__QtVerticalScroller)) - return static_cast(const_cast< QtVerticalScroller*>(this)); + if (!strcmp(_clname, qt_meta_stringdata_hiro__QtVerticalScrollBar)) + return static_cast(const_cast< QtVerticalScrollBar*>(this)); return QScrollBar::qt_metacast(_clname); } -int hiro::QtVerticalScroller::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +int hiro::QtVerticalScrollBar::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QScrollBar::qt_metacall(_c, _id, _a); if (_id < 0) diff --git a/hiro/qt/widget/combo-button-item.cpp b/hiro/qt/widget/combo-button-item.cpp index 6bc1d067..a38266a4 100644 --- a/hiro/qt/widget/combo-button-item.cpp +++ b/hiro/qt/widget/combo-button-item.cpp @@ -4,8 +4,10 @@ namespace hiro { auto pComboButtonItem::construct() -> void { if(auto parent = _parent()) { + parent->lock(); parent->qtComboButton->addItem(""); _setState(); + parent->unlock(); } } diff --git a/hiro/qt/widget/combo-button.cpp b/hiro/qt/widget/combo-button.cpp index 02a2b89e..88b75f3b 100644 --- a/hiro/qt/widget/combo-button.cpp +++ b/hiro/qt/widget/combo-button.cpp @@ -4,7 +4,7 @@ namespace hiro { auto pComboButton::construct() -> void { qtWidget = qtComboButton = new QtComboButton(*this); - qtComboButton->connect(qtComboButton, SIGNAL(currentIndexChanged(int)), SLOT(onChange())); + qtComboButton->connect(qtComboButton, SIGNAL(currentIndexChanged(int)), SLOT(onChange(int))); pWidget::construct(); } @@ -35,7 +35,13 @@ auto pComboButton::reset() -> void { unlock(); } -auto QtComboButton::onChange() -> void { +auto QtComboButton::onChange(int offset) -> void { + for(auto& item : p.state().items) { + item->state.selected = false; + } + if(auto item = p.self().item(offset)) { + item->state.selected = true; + } if(!p.locked()) p.self().doChange(); } diff --git a/hiro/qt/widget/horizontal-scroll-bar.cpp b/hiro/qt/widget/horizontal-scroll-bar.cpp new file mode 100644 index 00000000..284e79eb --- /dev/null +++ b/hiro/qt/widget/horizontal-scroll-bar.cpp @@ -0,0 +1,46 @@ +#if defined(Hiro_HorizontalScrollBar) + +namespace hiro { + +auto pHorizontalScrollBar::construct() -> void { + qtWidget = qtHorizontalScrollBar = new QtHorizontalScrollBar(*this); + qtHorizontalScrollBar->setRange(0, 100); + qtHorizontalScrollBar->setPageStep(101 >> 3); + qtHorizontalScrollBar->connect(qtHorizontalScrollBar, SIGNAL(valueChanged(int)), SLOT(onChange())); + + pWidget::construct(); + _setState(); +} + +auto pHorizontalScrollBar::destruct() -> void { + delete qtHorizontalScrollBar; + qtWidget = qtHorizontalScrollBar = nullptr; +} + +auto pHorizontalScrollBar::minimumSize() const -> Size { + return {0, 15}; +} + +auto pHorizontalScrollBar::setLength(unsigned length) -> void { + _setState(); +} + +auto pHorizontalScrollBar::setPosition(unsigned position) -> void { + _setState(); +} + +auto pHorizontalScrollBar::_setState() -> void { + signed length = state().length + (state().length == 0); + qtHorizontalScrollBar->setRange(0, length - 1); + qtHorizontalScrollBar->setPageStep(length >> 3); + qtHorizontalScrollBar->setValue(state().position); +} + +auto QtHorizontalScrollBar::onChange() -> void { + p.state().position = value(); + p.self().doChange(); +} + +} + +#endif diff --git a/hiro/qt/widget/horizontal-scroller.hpp b/hiro/qt/widget/horizontal-scroll-bar.hpp similarity index 53% rename from hiro/qt/widget/horizontal-scroller.hpp rename to hiro/qt/widget/horizontal-scroll-bar.hpp index e0eed4f8..f8766f04 100644 --- a/hiro/qt/widget/horizontal-scroller.hpp +++ b/hiro/qt/widget/horizontal-scroll-bar.hpp @@ -1,9 +1,9 @@ -#if defined(Hiro_HorizontalScroller) +#if defined(Hiro_HorizontalScrollBar) namespace hiro { -struct pHorizontalScroller : pWidget { - Declare(HorizontalScroller, Widget) +struct pHorizontalScrollBar : pWidget { + Declare(HorizontalScrollBar, Widget) auto minimumSize() const -> Size override; auto setLength(unsigned length) -> void; @@ -11,7 +11,7 @@ struct pHorizontalScroller : pWidget { auto _setState() -> void; - QtHorizontalScroller* qtHorizontalScroller = nullptr; + QtHorizontalScrollBar* qtHorizontalScrollBar = nullptr; }; } diff --git a/hiro/qt/widget/horizontal-scroller.cpp b/hiro/qt/widget/horizontal-scroller.cpp deleted file mode 100644 index 9fb45d46..00000000 --- a/hiro/qt/widget/horizontal-scroller.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#if defined(Hiro_HorizontalScroller) - -namespace hiro { - -auto pHorizontalScroller::construct() -> void { - qtWidget = qtHorizontalScroller = new QtHorizontalScroller(*this); - qtHorizontalScroller->setRange(0, 100); - qtHorizontalScroller->setPageStep(101 >> 3); - qtHorizontalScroller->connect(qtHorizontalScroller, SIGNAL(valueChanged(int)), SLOT(onChange())); - - pWidget::construct(); - _setState(); -} - -auto pHorizontalScroller::destruct() -> void { - delete qtHorizontalScroller; - qtWidget = qtHorizontalScroller = nullptr; -} - -auto pHorizontalScroller::minimumSize() const -> Size { - return {0, 15}; -} - -auto pHorizontalScroller::setLength(unsigned length) -> void { - _setState(); -} - -auto pHorizontalScroller::setPosition(unsigned position) -> void { - _setState(); -} - -auto pHorizontalScroller::_setState() -> void { - signed length = state().length + (state().length == 0); - qtHorizontalScroller->setRange(0, length - 1); - qtHorizontalScroller->setPageStep(length >> 3); - qtHorizontalScroller->setValue(state().position); -} - -auto QtHorizontalScroller::onChange() -> void { - p.state().position = value(); - p.self().doChange(); -} - -} - -#endif diff --git a/hiro/qt/widget/list-view-cell.cpp b/hiro/qt/widget/list-view-cell.cpp index d747535d..6469ca64 100644 --- a/hiro/qt/widget/list-view-cell.cpp +++ b/hiro/qt/widget/list-view-cell.cpp @@ -49,18 +49,22 @@ auto pListViewCell::_parent() -> maybe { auto pListViewCell::_setState() -> void { if(auto parent = _parent()) { - parent->qtItem->setBackground(self().offset(), CreateBrush(self().backgroundColor(true))); - if(state().checkable) { - parent->qtItem->setCheckState(self().offset(), state().checked ? Qt::Checked : Qt::Unchecked); - } else { - //extremely unintuitive; but this is the only way to remove an existing checkbox from a cell - parent->qtItem->setData(self().offset(), Qt::CheckStateRole, QVariant()); + if(auto grandparent = parent->_parent()) { + grandparent->lock(); + parent->qtItem->setBackground(self().offset(), CreateBrush(self().backgroundColor(true))); + if(state().checkable) { + parent->qtItem->setCheckState(self().offset(), state().checked ? Qt::Checked : Qt::Unchecked); + } else { + //extremely unintuitive; but this is the only way to remove an existing checkbox from a cell + parent->qtItem->setData(self().offset(), Qt::CheckStateRole, QVariant()); + } + parent->qtItem->setFont(self().offset(), pFont::create(self().font(true))); + parent->qtItem->setForeground(self().offset(), CreateBrush(self().foregroundColor(true))); + parent->qtItem->setIcon(self().offset(), CreateIcon(state().icon)); + parent->qtItem->setText(self().offset(), QString::fromUtf8(state().text)); + parent->qtItem->setTextAlignment(self().offset(), CalculateAlignment(self().alignment(true))); + grandparent->unlock(); } - parent->qtItem->setFont(self().offset(), pFont::create(self().font(true))); - parent->qtItem->setForeground(self().offset(), CreateBrush(self().foregroundColor(true))); - parent->qtItem->setIcon(self().offset(), CreateIcon(state().icon)); - parent->qtItem->setText(self().offset(), QString::fromUtf8(state().text)); - parent->qtItem->setTextAlignment(self().offset(), CalculateAlignment(self().alignment(true))); } } diff --git a/hiro/qt/widget/list-view-item.cpp b/hiro/qt/widget/list-view-item.cpp index bb3bb57b..7bd9d922 100644 --- a/hiro/qt/widget/list-view-item.cpp +++ b/hiro/qt/widget/list-view-item.cpp @@ -6,10 +6,12 @@ auto pListViewItem::construct() -> void { } auto pListViewItem::destruct() -> void { + if(auto parent = _parent()) parent->lock(); if(qtItem) { delete qtItem; qtItem = nullptr; } + if(auto parent = _parent()) parent->unlock(); } auto pListViewItem::append(sListViewCell cell) -> void { diff --git a/hiro/qt/widget/list-view.cpp b/hiro/qt/widget/list-view.cpp index 7f1ac186..2c2e87c6 100644 --- a/hiro/qt/widget/list-view.cpp +++ b/hiro/qt/widget/list-view.cpp @@ -17,7 +17,7 @@ auto pListView::construct() -> void { qtListView->connect(qtListView, SIGNAL(itemSelectionChanged()), SLOT(onChange())); qtListView->connect(qtListView, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(onContext())); qtListView->connect(qtListView->header(), SIGNAL(sectionClicked(int)), SLOT(onSort(int))); - qtListView->connect(qtListView, SIGNAL(itemChanged(QTreeWidgetItem*, int)), SLOT(onToggle(QTreeWidgetItem*))); + qtListView->connect(qtListView, SIGNAL(itemChanged(QTreeWidgetItem*, int)), SLOT(onToggle(QTreeWidgetItem*, int))); setBackgroundColor(state().backgroundColor); setBatchable(state().batchable); @@ -57,12 +57,6 @@ auto pListView::remove(sListViewHeader header) -> void { auto pListView::remove(sListViewItem item) -> void { } -auto pListView::reset() -> void { - lock(); - qtListView->clear(); - unlock(); -} - auto pListView::resizeColumns() -> void { lock(); @@ -194,15 +188,13 @@ auto QtListView::onActivate() -> void { } auto QtListView::onChange() -> void { -/* - for(auto& item : listView.state.items) item.selected = false; - for(unsigned position = 0; position < qtListView->topLevelItemCount(); position++) { - if(auto item = qtListView->topLevelItem(position)) { - if(item->isSelected()) listView.state.items[position].selected = true; + for(auto& item : p.state().items) { + item->state.selected = false; + if(auto self = item->self()) { + if(self->qtItem->isSelected()) item->state.selected = true; } } - if(!locked() && listView.onChange) listView.onChange(); -*/ + if(!p.locked()) p.self().doChange(); } auto QtListView::onContext() -> void { @@ -217,22 +209,17 @@ auto QtListView::onSort(int columnNumber) -> void { } } -auto QtListView::onToggle(QTreeWidgetItem* item) -> void { -/* - maybe row; - for(unsigned position = 0; position < qtListView->topLevelItemCount(); position++) { - if(auto topLevelItem = qtListView->topLevelItem(position)) { - if(topLevelItem == item) { - row = position; - break; +auto QtListView::onToggle(QTreeWidgetItem* qtItem, int column) -> void { + for(auto& item : p.state().items) { + if(auto self = item->self()) { + if(qtItem == self->qtItem) { + if(auto cell = item->cell(column)) { + cell->state.checked = (qtItem->checkState(column) == Qt::Checked); + if(!p.locked()) p.self().doToggle(cell); + } } } } - if(row) { - listView.state.items[*row].checked = (item->checkState(0) == Qt::Checked); - if(!locked() && listView.onToggle) listView.onToggle(*row); - } -*/ } auto QtListView::mousePressEvent(QMouseEvent* event) -> void { diff --git a/hiro/qt/widget/list-view.hpp b/hiro/qt/widget/list-view.hpp index 0aa1b7a8..20bac6bc 100644 --- a/hiro/qt/widget/list-view.hpp +++ b/hiro/qt/widget/list-view.hpp @@ -9,7 +9,6 @@ struct pListView : pWidget { auto append(sListViewItem item) -> void; auto remove(sListViewHeader header) -> void; auto remove(sListViewItem item) -> void; - auto reset() -> void; auto resizeColumns() -> void; auto setAlignment(Alignment alignment) -> void; auto setBackgroundColor(Color color) -> void; diff --git a/hiro/qt/widget/tab-frame-item.cpp b/hiro/qt/widget/tab-frame-item.cpp index 82297ca0..72d8ca73 100644 --- a/hiro/qt/widget/tab-frame-item.cpp +++ b/hiro/qt/widget/tab-frame-item.cpp @@ -35,12 +35,14 @@ auto pTabFrameItem::setGeometry(Geometry geometry) -> void { } auto pTabFrameItem::setIcon(const image& icon) -> void { + _setState(); } auto pTabFrameItem::setMovable(bool movable) -> void { } auto pTabFrameItem::setSelected() -> void { + _setState(); } auto pTabFrameItem::setText(const string& text) -> void { @@ -60,6 +62,8 @@ auto pTabFrameItem::_parent() -> maybe { auto pTabFrameItem::_setState() -> void { if(auto parent = _parent()) { + parent->qtTabFrame->setTabIcon(self().offset(), CreateIcon(state().icon)); + if(state().selected) parent->qtTabFrame->setCurrentIndex(self().offset()); parent->qtTabFrame->setTabText(self().offset(), QString::fromUtf8(state().text)); if(auto layout = state().layout) { auto geometry = parent->self().geometry(); diff --git a/hiro/qt/widget/tab-frame.cpp b/hiro/qt/widget/tab-frame.cpp index d773f4bc..d1fb1a5d 100644 --- a/hiro/qt/widget/tab-frame.cpp +++ b/hiro/qt/widget/tab-frame.cpp @@ -16,6 +16,7 @@ auto pTabFrame::destruct() -> void { } auto pTabFrame::append(sTabFrameItem item) -> void { + setGeometry(self().geometry()); } auto pTabFrame::remove(sTabFrameItem item) -> void { @@ -24,91 +25,17 @@ auto pTabFrame::remove(sTabFrameItem item) -> void { auto pTabFrame::setEdge(Edge edge) -> void { } -/* -auto pTabFrame::container(Widget& widget) -> QWidget* { - Layout* widgetLayout = GetParentWidgetLayout(&widget); - unsigned selection = 0; - for(auto& layout : tabFrame.state.layout) { - if(layout == widgetLayout) return qtTabFrame->widget(selection); - selection++; - } - return nullptr; -} - -auto pTabFrame::displacement() -> Position { - return {5, 33}; -} - -auto pTabFrame::remove(unsigned selection) -> void { - qtTabFrame->removeTab(selection); -} - -auto pTabFrame::setEnabled(bool enabled) -> void { - for(auto& layout : tabFrame.state.layout) { - if(layout) layout->setEnabled(layout->enabled()); - } - pWidget::setEnabled(enabled); -} - auto pTabFrame::setGeometry(Geometry geometry) -> void { pWidget::setGeometry(geometry); - geometry.x += 0, geometry.width -= 5; - geometry.y += 29, geometry.height -= 33; - for(auto& layout : tabFrame.state.layout) { - if(layout) layout->setGeometry(geometry); - } - synchronizeLayout(); -} -*/ - -auto pTabFrame::setGeometry(Geometry geometry) -> void { - pWidget::setGeometry(geometry); - -// geometry.setPosition({0, 0}); -// geometry.setWidth(geometry.width() - 4); -// geometry.setHeight(geometry.height() - 25); for(auto& item : state().items) { if(auto self = item->self()) self->setGeometry(geometry); } } -/* -auto pTabFrame::setIcon(unsigned selection, const image& icon) -> void { - qtTabFrame->setTabIcon(selection, CreateIcon(image)); -} - -auto pTabFrame::setSelected(unsigned selection) -> void { - lock(); - qtTabFrame->setCurrentIndex(selection); - synchronizeLayout(); - unlock(); -} - -auto pTabFrame::setVisible(bool visible) -> void { - for(auto& layout : tabFrame.state.layout) { - if(layout) layout->setVisible(layout->visible()); - } - pWidget::setVisible(visible); -} -*/ - -/* -auto pTabFrame::synchronizeLayout() -> void { - unsigned selection = 0; - for(auto& layout : tabFrame.state.layout) { - if(layout) layout->setVisible(selection == tabFrame.state.selection); - selection++; - } -} -*/ - auto pTabFrame::_setState() -> void { for(auto& item : state().items) { if(auto self = item->self()) self->_setState(); -// if(auto layout = item->state.layout) { -// item->setVisible(item->visible(true)); -// } } } @@ -118,9 +45,12 @@ auto QtTabFrame::showEvent(QShowEvent* event) -> void { } auto QtTabFrame::onChange(int selection) -> void { -// state().selection = selection; -// synchronizeLayout(); -// if(!p.locked()) p.self().doChange(); + //geometry of tab frames is only valid once said tab frame is visible + //as such, as need to call _setState() to update the TabFrameItem's geometry here + if(auto item = p.self().item(selection)) { + if(auto self = item->self()) self->_setState(); + } + if(!p.locked()) p.self().doChange(); } } diff --git a/hiro/qt/widget/vertical-scroll-bar.cpp b/hiro/qt/widget/vertical-scroll-bar.cpp new file mode 100644 index 00000000..b470ffdc --- /dev/null +++ b/hiro/qt/widget/vertical-scroll-bar.cpp @@ -0,0 +1,46 @@ +#if defined(Hiro_VerticalScrollBar) + +namespace hiro { + +auto pVerticalScrollBar::construct() -> void { + qtWidget = qtVerticalScrollBar = new QtVerticalScrollBar(*this); + qtVerticalScrollBar->setRange(0, 100); + qtVerticalScrollBar->setPageStep(101 >> 3); + qtVerticalScrollBar->connect(qtVerticalScrollBar, SIGNAL(valueChanged(int)), SLOT(onChange())); + + pWidget::construct(); + _setState(); +} + +auto pVerticalScrollBar::destruct() -> void { + delete qtVerticalScrollBar; + qtWidget = qtVerticalScrollBar = nullptr; +} + +auto pVerticalScrollBar::minimumSize() const -> Size { + return {15, 0}; +} + +auto pVerticalScrollBar::setLength(unsigned length) -> void { + _setState(); +} + +auto pVerticalScrollBar::setPosition(unsigned position) -> void { + _setState(); +} + +auto pVerticalScrollBar::_setState() -> void { + signed length = state().length + (state().length == 0); + qtVerticalScrollBar->setRange(0, length - 1); + qtVerticalScrollBar->setPageStep(length >> 3); + qtVerticalScrollBar->setValue(state().position); +} + +auto QtVerticalScrollBar::onChange() -> void { + p.state().position = value(); + p.self().doChange(); +} + +} + +#endif diff --git a/hiro/qt/widget/vertical-scroller.hpp b/hiro/qt/widget/vertical-scroll-bar.hpp similarity index 54% rename from hiro/qt/widget/vertical-scroller.hpp rename to hiro/qt/widget/vertical-scroll-bar.hpp index c6d3c6c4..9a8f7619 100644 --- a/hiro/qt/widget/vertical-scroller.hpp +++ b/hiro/qt/widget/vertical-scroll-bar.hpp @@ -1,9 +1,9 @@ -#if defined(Hiro_VerticalScroller) +#if defined(Hiro_VerticalScrollBar) namespace hiro { -struct pVerticalScroller : pWidget { - Declare(VerticalScroller, Widget) +struct pVerticalScrollBar : pWidget { + Declare(VerticalScrollBar, Widget) auto minimumSize() const -> Size override; auto setLength(unsigned length) -> void; @@ -11,7 +11,7 @@ struct pVerticalScroller : pWidget { auto _setState() -> void; - QtVerticalScroller* qtVerticalScroller = nullptr; + QtVerticalScrollBar* qtVerticalScrollBar = nullptr; }; } diff --git a/hiro/qt/widget/vertical-scroller.cpp b/hiro/qt/widget/vertical-scroller.cpp deleted file mode 100644 index 1f18c9ec..00000000 --- a/hiro/qt/widget/vertical-scroller.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#if defined(Hiro_VerticalScroller) - -namespace hiro { - -auto pVerticalScroller::construct() -> void { - qtWidget = qtVerticalScroller = new QtVerticalScroller(*this); - qtVerticalScroller->setRange(0, 100); - qtVerticalScroller->setPageStep(101 >> 3); - qtVerticalScroller->connect(qtVerticalScroller, SIGNAL(valueChanged(int)), SLOT(onChange())); - - pWidget::construct(); - _setState(); -} - -auto pVerticalScroller::destruct() -> void { - delete qtVerticalScroller; - qtWidget = qtVerticalScroller = nullptr; -} - -auto pVerticalScroller::minimumSize() const -> Size { - return {15, 0}; -} - -auto pVerticalScroller::setLength(unsigned length) -> void { - _setState(); -} - -auto pVerticalScroller::setPosition(unsigned position) -> void { - _setState(); -} - -auto pVerticalScroller::_setState() -> void { - signed length = state().length + (state().length == 0); - qtVerticalScroller->setRange(0, length - 1); - qtVerticalScroller->setPageStep(length >> 3); - qtVerticalScroller->setValue(state().position); -} - -auto QtVerticalScroller::onChange() -> void { - p.state().position = value(); - p.self().doChange(); -} - -} - -#endif diff --git a/hiro/windows/platform.cpp b/hiro/windows/platform.cpp index f42e12db..36fc5196 100644 --- a/hiro/windows/platform.cpp +++ b/hiro/windows/platform.cpp @@ -38,7 +38,7 @@ #include "widget/combo-button-item.cpp" #include "widget/frame.cpp" #include "widget/hex-edit.cpp" -#include "widget/horizontal-scroller.cpp" +#include "widget/horizontal-scroll-bar.cpp" #include "widget/horizontal-slider.cpp" #include "widget/label.cpp" #include "widget/line-edit.cpp" @@ -53,7 +53,7 @@ #include "widget/tab-frame.cpp" #include "widget/tab-frame-item.cpp" #include "widget/text-edit.cpp" -#include "widget/vertical-scroller.cpp" +#include "widget/vertical-scroll-bar.cpp" #include "widget/vertical-slider.cpp" #include "widget/viewport.cpp" diff --git a/hiro/windows/platform.hpp b/hiro/windows/platform.hpp index 9d273910..954c2bc0 100644 --- a/hiro/windows/platform.hpp +++ b/hiro/windows/platform.hpp @@ -67,7 +67,7 @@ static vector windows; #include "widget/combo-button-item.hpp" #include "widget/frame.hpp" #include "widget/hex-edit.hpp" -#include "widget/horizontal-scroller.hpp" +#include "widget/horizontal-scroll-bar.hpp" #include "widget/horizontal-slider.hpp" #include "widget/label.hpp" #include "widget/line-edit.hpp" @@ -82,7 +82,7 @@ static vector windows; #include "widget/tab-frame.hpp" #include "widget/tab-frame-item.hpp" #include "widget/text-edit.hpp" -#include "widget/vertical-scroller.hpp" +#include "widget/vertical-scroll-bar.hpp" #include "widget/vertical-slider.hpp" #include "widget/viewport.hpp" diff --git a/hiro/windows/utility.cpp b/hiro/windows/utility.cpp index 480b9609..69e4bbef 100644 --- a/hiro/windows/utility.cpp +++ b/hiro/windows/utility.cpp @@ -103,7 +103,7 @@ static auto ScrollEvent(HWND hwnd, WPARAM wparam) -> unsigned { info.fMask = SIF_POS; SetScrollInfo(hwnd, SB_CTL, &info, TRUE); - //Windows may clamp position to scroller range + //Windows may clamp position to scrollbar range GetScrollInfo(hwnd, SB_CTL, &info); return info.nPos; } @@ -351,9 +351,9 @@ static auto CALLBACK Shared_windowProc(WindowProc windowProc, HWND hwnd, UINT ms auto object = (mObject*)GetWindowLongPtr((HWND)lparam, GWLP_USERDATA); if(!object) break; - #if defined(Hiro_HorizontalScroller) - if(auto horizontalScroller = dynamic_cast(object)) { - return horizontalScroller->self()->onChange(wparam), true; + #if defined(Hiro_HorizontalScrollBar) + if(auto horizontalScrollBar = dynamic_cast(object)) { + return horizontalScrollBar->self()->onChange(wparam), true; } #endif @@ -363,9 +363,9 @@ static auto CALLBACK Shared_windowProc(WindowProc windowProc, HWND hwnd, UINT ms } #endif - #if defined(Hiro_VerticalScroller) - if(auto verticalScroller = dynamic_cast(object)) { - return verticalScroller->self()->onChange(wparam), true; + #if defined(Hiro_VerticalScrollBar) + if(auto verticalScrollBar = dynamic_cast(object)) { + return verticalScrollBar->self()->onChange(wparam), true; } #endif diff --git a/hiro/windows/widget/check-button.cpp b/hiro/windows/widget/check-button.cpp index 66b0f2d1..badd781e 100644 --- a/hiro/windows/widget/check-button.cpp +++ b/hiro/windows/widget/check-button.cpp @@ -19,7 +19,7 @@ auto pCheckButton::destruct() -> void { DestroyWindow(hwnd); } -auto pCheckButton::minimumSize() -> Size { +auto pCheckButton::minimumSize() const -> Size { auto size = pFont::size(hfont, state().text); if(state().orientation == Orientation::Horizontal) { diff --git a/hiro/windows/widget/check-button.hpp b/hiro/windows/widget/check-button.hpp index 1b0f8ac5..3083cb2d 100644 --- a/hiro/windows/widget/check-button.hpp +++ b/hiro/windows/widget/check-button.hpp @@ -5,7 +5,7 @@ namespace hiro { struct pCheckButton : pWidget { Declare(CheckButton, Widget) - auto minimumSize() -> Size; + auto minimumSize() const -> Size override; auto setBordered(bool bordered) -> void; auto setChecked(bool checked) -> void; auto setIcon(const image& icon) -> void; diff --git a/hiro/windows/widget/horizontal-scroller.cpp b/hiro/windows/widget/horizontal-scroll-bar.cpp similarity index 63% rename from hiro/windows/widget/horizontal-scroller.cpp rename to hiro/windows/widget/horizontal-scroll-bar.cpp index 93ece5f1..ab347542 100644 --- a/hiro/windows/widget/horizontal-scroller.cpp +++ b/hiro/windows/widget/horizontal-scroll-bar.cpp @@ -1,8 +1,8 @@ -#if defined(Hiro_HorizontalScroller) +#if defined(Hiro_HorizontalScrollBar) namespace hiro { -auto pHorizontalScroller::construct() -> void { +auto pHorizontalScrollBar::construct() -> void { hwnd = CreateWindow( L"SCROLLBAR", L"", WS_CHILD | WS_TABSTOP | SBS_HORZ, 0, 0, 0, 0, _parentHandle(), nullptr, GetModuleHandle(0), 0 @@ -13,24 +13,24 @@ auto pHorizontalScroller::construct() -> void { setPosition(state().position); } -auto pHorizontalScroller::destruct() -> void { +auto pHorizontalScrollBar::destruct() -> void { DestroyWindow(hwnd); } -auto pHorizontalScroller::minimumSize() const -> Size { +auto pHorizontalScrollBar::minimumSize() const -> Size { return {0, 18}; } -auto pHorizontalScroller::setLength(unsigned length) -> void { +auto pHorizontalScrollBar::setLength(unsigned length) -> void { length += (length == 0); SetScrollRange(hwnd, SB_CTL, 0, length - 1, TRUE); } -auto pHorizontalScroller::setPosition(unsigned position) -> void { +auto pHorizontalScrollBar::setPosition(unsigned position) -> void { SetScrollPos(hwnd, SB_CTL, position, TRUE); } -auto pHorizontalScroller::onChange(WPARAM wparam) -> void { +auto pHorizontalScrollBar::onChange(WPARAM wparam) -> void { unsigned position = ScrollEvent(hwnd, wparam); if(position == state().position) return; state().position = position; diff --git a/hiro/windows/widget/horizontal-scroller.hpp b/hiro/windows/widget/horizontal-scroll-bar.hpp similarity index 64% rename from hiro/windows/widget/horizontal-scroller.hpp rename to hiro/windows/widget/horizontal-scroll-bar.hpp index 50312e71..180249f8 100644 --- a/hiro/windows/widget/horizontal-scroller.hpp +++ b/hiro/windows/widget/horizontal-scroll-bar.hpp @@ -1,9 +1,9 @@ -#if defined(Hiro_HorizontalScroller) +#if defined(Hiro_HorizontalScrollBar) namespace hiro { -struct pHorizontalScroller : pWidget { - Declare(HorizontalScroller, Widget) +struct pHorizontalScrollBar : pWidget { + Declare(HorizontalScrollBar, Widget) auto minimumSize() const -> Size override; auto setLength(unsigned length) -> void; diff --git a/hiro/windows/widget/list-view.cpp b/hiro/windows/widget/list-view.cpp index 572eb291..ff29cf48 100644 --- a/hiro/windows/widget/list-view.cpp +++ b/hiro/windows/widget/list-view.cpp @@ -57,15 +57,6 @@ auto pListView::remove(sListViewHeader header) -> void { auto pListView::remove(sListViewItem item) -> void { } -auto pListView::reset() -> void { - lock(); - ListView_DeleteAllItems(hwnd); - LVCOLUMN lvColumn{LVCF_WIDTH}; - while(ListView_GetColumn(hwnd, 0, &lvColumn)) ListView_DeleteColumn(hwnd, 0); - _setIcons(); //free icon resources - unlock(); -} - auto pListView::resizeColumns() -> void { lock(); @@ -200,7 +191,12 @@ auto pListView::onCustomDraw(LPARAM lparam) -> LRESULT { bool selected = state().items(row)->state.selected; if(auto cell = self().item(row)->cell(column)) { - HBRUSH brush = CreateSolidBrush(selected ? GetSysColor(COLOR_HIGHLIGHT) : CreateRGB(cell->backgroundColor(true))); + auto backgroundColor = cell->backgroundColor(true); + HBRUSH brush = CreateSolidBrush( + selected ? GetSysColor(COLOR_HIGHLIGHT) + : backgroundColor ? CreateRGB(backgroundColor) + : GetSysColor(COLOR_WINDOW) + ); FillRect(hdc, &rc, brush); DeleteObject(brush); @@ -235,7 +231,12 @@ auto pListView::onCustomDraw(LPARAM lparam) -> LRESULT { if(!alignment) alignment = {0.0, 0.5}; utf16_t wText(text); SetBkMode(hdc, TRANSPARENT); - SetTextColor(hdc, selected ? GetSysColor(COLOR_HIGHLIGHTTEXT) : CreateRGB(cell->foregroundColor(true))); + auto foregroundColor = cell->foregroundColor(true); + SetTextColor(hdc, + selected ? GetSysColor(COLOR_HIGHLIGHTTEXT) + : foregroundColor ? CreateRGB(foregroundColor) + : GetSysColor(COLOR_WINDOWTEXT) + ); auto style = DT_SINGLELINE | DT_NOPREFIX | DT_END_ELLIPSIS; style |= alignment.horizontal() < 0.333 ? DT_LEFT : alignment.horizontal() > 0.666 ? DT_RIGHT : DT_CENTER; style |= alignment.vertical() < 0.333 ? DT_TOP : alignment.vertical() > 0.666 ? DT_BOTTOM : DT_VCENTER; @@ -246,9 +247,12 @@ auto pListView::onCustomDraw(LPARAM lparam) -> LRESULT { DeleteObject(font); } } else { - auto color = state().backgroundColor; - if(!color) color = {255, 255, 255}; - HBRUSH brush = CreateSolidBrush(selected ? GetSysColor(COLOR_HIGHLIGHT) : CreateRGB(color)); + auto backgroundColor = state().backgroundColor; + HBRUSH brush = CreateSolidBrush( + selected ? GetSysColor(COLOR_HIGHLIGHT) + : backgroundColor ? CreateRGB(backgroundColor) + : GetSysColor(COLOR_WINDOW) + ); FillRect(hdc, &rc, brush); DeleteObject(brush); } diff --git a/hiro/windows/widget/list-view.hpp b/hiro/windows/widget/list-view.hpp index 3fc58203..4aff0796 100644 --- a/hiro/windows/widget/list-view.hpp +++ b/hiro/windows/widget/list-view.hpp @@ -9,7 +9,6 @@ struct pListView : pWidget { auto append(sListViewItem item) -> void; auto remove(sListViewHeader header) -> void; auto remove(sListViewItem item) -> void; - auto reset() -> void; auto resizeColumns() -> void; auto setAlignment(Alignment alignment) -> void; auto setBackgroundColor(Color color) -> void; diff --git a/hiro/windows/widget/radio-button.cpp b/hiro/windows/widget/radio-button.cpp index 01021a7c..06751286 100644 --- a/hiro/windows/widget/radio-button.cpp +++ b/hiro/windows/widget/radio-button.cpp @@ -19,7 +19,7 @@ auto pRadioButton::destruct() -> void { DestroyWindow(hwnd); } -auto pRadioButton::minimumSize() -> Size { +auto pRadioButton::minimumSize() const -> Size { auto size = pFont::size(hfont, state().text); if(state().orientation == Orientation::Horizontal) { diff --git a/hiro/windows/widget/radio-button.hpp b/hiro/windows/widget/radio-button.hpp index dbf71a11..31f4d917 100644 --- a/hiro/windows/widget/radio-button.hpp +++ b/hiro/windows/widget/radio-button.hpp @@ -5,7 +5,7 @@ namespace hiro { struct pRadioButton : pWidget { Declare(RadioButton, Widget) - auto minimumSize() -> Size; + auto minimumSize() const -> Size override; auto setBordered(bool bordered) -> void; auto setChecked() -> void; auto setGroup(sGroup group) -> void override; diff --git a/hiro/windows/widget/vertical-scroller.cpp b/hiro/windows/widget/vertical-scroll-bar.cpp similarity index 63% rename from hiro/windows/widget/vertical-scroller.cpp rename to hiro/windows/widget/vertical-scroll-bar.cpp index f1d00e50..9dd9370c 100644 --- a/hiro/windows/widget/vertical-scroller.cpp +++ b/hiro/windows/widget/vertical-scroll-bar.cpp @@ -1,8 +1,8 @@ -#if defined(Hiro_VerticalScroller) +#if defined(Hiro_VerticalScrollBar) namespace hiro { -auto pVerticalScroller::construct() -> void { +auto pVerticalScrollBar::construct() -> void { hwnd = CreateWindow( L"SCROLLBAR", L"", WS_CHILD | SBS_VERT, 0, 0, 0, 0, _parentHandle(), nullptr, GetModuleHandle(0), 0 @@ -13,24 +13,24 @@ auto pVerticalScroller::construct() -> void { setPosition(state().position); } -auto pVerticalScroller::destruct() -> void { +auto pVerticalScrollBar::destruct() -> void { DestroyWindow(hwnd); } -auto pVerticalScroller::minimumSize() const -> Size { +auto pVerticalScrollBar::minimumSize() const -> Size { return {18, 0}; } -auto pVerticalScroller::setLength(unsigned length) -> void { +auto pVerticalScrollBar::setLength(unsigned length) -> void { length += (length == 0); SetScrollRange(hwnd, SB_CTL, 0, length - 1, TRUE); } -auto pVerticalScroller::setPosition(unsigned position) -> void { +auto pVerticalScrollBar::setPosition(unsigned position) -> void { SetScrollPos(hwnd, SB_CTL, position, TRUE); } -auto pVerticalScroller::onChange(WPARAM wparam) -> void { +auto pVerticalScrollBar::onChange(WPARAM wparam) -> void { unsigned position = ScrollEvent(hwnd, wparam); if(position == state().position) return; state().position = position; diff --git a/hiro/windows/widget/vertical-scroller.hpp b/hiro/windows/widget/vertical-scroll-bar.hpp similarity index 65% rename from hiro/windows/widget/vertical-scroller.hpp rename to hiro/windows/widget/vertical-scroll-bar.hpp index acafd1fd..e849a914 100644 --- a/hiro/windows/widget/vertical-scroller.hpp +++ b/hiro/windows/widget/vertical-scroll-bar.hpp @@ -1,9 +1,9 @@ -#if defined(Hiro_VerticalScroller) +#if defined(Hiro_VerticalScrollBar) namespace hiro { -struct pVerticalScroller : pWidget { - Declare(VerticalScroller, Widget) +struct pVerticalScrollBar : pWidget { + Declare(VerticalScrollBar, Widget) auto minimumSize() const -> Size override; auto setLength(unsigned length) -> void; diff --git a/hiro/windows/widget/vertical-slider.cpp b/hiro/windows/widget/vertical-slider.cpp index 57435d71..9a31e863 100644 --- a/hiro/windows/widget/vertical-slider.cpp +++ b/hiro/windows/widget/vertical-slider.cpp @@ -18,7 +18,7 @@ auto pVerticalSlider::destruct() -> void { } auto pVerticalSlider::minimumSize() const -> Size { - return {0, 25}; + return {25, 0}; } auto pVerticalSlider::setLength(unsigned length) -> void { diff --git a/nall/image/scale.hpp b/nall/image/scale.hpp index 4ca810b9..44bfa69f 100644 --- a/nall/image/scale.hpp +++ b/nall/image/scale.hpp @@ -4,6 +4,7 @@ namespace nall { auto image::scale(unsigned outputWidth, unsigned outputHeight, bool linear) -> void { + if(!_data) return; if(_width == outputWidth && _height == outputHeight) return; //no scaling necessary if(linear == false) return scaleNearest(outputWidth, outputHeight); diff --git a/nall/range.hpp b/nall/range.hpp index 159a30d2..2af781c2 100644 --- a/nall/range.hpp +++ b/nall/range.hpp @@ -35,7 +35,8 @@ inline auto range(signed offset, signed size, signed step) { return range_t{offset, size, step}; } -inline auto rangeReverse(signed size) { +//reverse-range +inline auto rrange(signed size) { return range_t{size - 1, -1, -1}; } @@ -43,6 +44,10 @@ template inline auto range(const vector& container) { return range_t{0, (signed)container.size(), 1}; } +template inline auto rrange(const vector& container) { + return range_t{(signed)container.size() - 1, -1, -1}; +} + } #endif diff --git a/target-tomoko/program/program.cpp b/target-tomoko/program/program.cpp index 406426a0..3d21d0ba 100644 --- a/target-tomoko/program/program.cpp +++ b/target-tomoko/program/program.cpp @@ -9,7 +9,7 @@ #include "utility.cpp" Program* program = nullptr; -Program::Program() { +Program::Program(lstring args) { program = this; directory::create({configpath(), "tomoko/"}); Application::onMain({&Program::main, this}); @@ -67,6 +67,10 @@ Program::Program() { presentation->drawSplashScreen(); updateVideoFilter(); + + if(args.size() == 2 && directory::exists(args[1])) { + loadMedia(args[1]); + } } auto Program::main() -> void { diff --git a/target-tomoko/program/program.hpp b/target-tomoko/program/program.hpp index d9c4bec7..39596f0b 100644 --- a/target-tomoko/program/program.hpp +++ b/target-tomoko/program/program.hpp @@ -1,6 +1,6 @@ struct Program : Emulator::Interface::Bind { //program.cpp - Program(); + Program(lstring args); auto main() -> void; auto quit() -> void; diff --git a/target-tomoko/tomoko.cpp b/target-tomoko/tomoko.cpp index 4996f423..88d77c99 100644 --- a/target-tomoko/tomoko.cpp +++ b/target-tomoko/tomoko.cpp @@ -15,6 +15,6 @@ auto locate(string pathname, string filename) -> string { #include auto nall::main(lstring args) -> void { Application::setName("tomoko"); - new Program; + new Program(args); Application::run(); }