Skip to content

Commit

Permalink
Update borealis
Browse files Browse the repository at this point in the history
  • Loading branch information
xfangfang committed Sep 6, 2024
1 parent d336dfa commit c3ae64c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion library/borealis
4 changes: 2 additions & 2 deletions wiliwili/include/view/grid_dropdown.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class CommonDataSourceDropdown : public DataSourceDropdown {
*/
class BaseDropdown : public EmptyDropdown {
public:
BaseDropdown(const std::string& title, ValueSelectedEvent::Callback cb, int selected = 0);
BaseDropdown(const std::string& title, ValueSelectedEvent::Callback cb, size_t selected = 0);

RecyclingGrid* getRecyclingList();

Expand All @@ -131,7 +131,7 @@ class BaseDropdown : public EmptyDropdown {
ValueSelectedEvent::Callback getSelectCallback();

static BaseDropdown* text(const std::string& title, const std::vector<std::string>& values,
ValueSelectedEvent::Callback cb, int selected = 0, const std::string& hint = "");
ValueSelectedEvent::Callback cb, size_t selected = 0, const std::string& hint = "");

protected:
BRLS_BIND(RecyclingGrid, recycler, "grid_dropdown/recycler");
Expand Down
8 changes: 4 additions & 4 deletions wiliwili/source/utils/config_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ void ProgramConfig::loadHomeWindowState() {

if (hWidth == 0 || hHeight == 0) return;

int minWidth = getIntOption(SettingItem::MINIMUM_WINDOW_WIDTH);
int minHeight = getIntOption(SettingItem::MINIMUM_WINDOW_HEIGHT);
uint32_t minWidth = getIntOption(SettingItem::MINIMUM_WINDOW_WIDTH);
uint32_t minHeight = getIntOption(SettingItem::MINIMUM_WINDOW_HEIGHT);
if (hWidth < minWidth) hWidth = minWidth;
if (hHeight < minHeight) hHeight = minHeight;

Expand Down Expand Up @@ -762,9 +762,9 @@ void ProgramConfig::checkOnTop() {
case 2: {
// 自动模式,根据窗口大小判断是否需要切换到置顶模式
double factor = brls::Application::getPlatform()->getVideoContext()->getScaleFactor();
int minWidth =
uint32_t minWidth =
ProgramConfig::instance().getIntOption(SettingItem::ON_TOP_WINDOW_WIDTH) * factor + 0.1;
int minHeight =
uint32_t minHeight =
ProgramConfig::instance().getIntOption(SettingItem::ON_TOP_WINDOW_HEIGHT) * factor + 0.1;
bool onTop = brls::Application::windowWidth <= minWidth || brls::Application::windowHeight <= minHeight;
brls::Application::getPlatform()->setWindowAlwaysOnTop(onTop);
Expand Down
12 changes: 6 additions & 6 deletions wiliwili/source/view/danmaku_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ void DanmakuCore::loadMaskData(const std::string &url) {
BILI::get_webmask(
url, 16, 16 * maskData.length + 15,
[this](const std::string &text) {
if (text.size() != 16 * maskData.length) {
if (text.size() != (size_t)(16 * maskData.length)) {
brls::Logger::error("解析数据头2失败: {} != {}", text.size(), 16 * maskData.length);
return;
}
Expand Down Expand Up @@ -572,7 +572,7 @@ void DanmakuCore::draw(NVGcontext *vg, float x, float y, float width, float heig
}

// 实际弹幕显示行数 (小于等于总行数且受弹幕显示区域限制)
int LINES = height / lineHeight * DANMAKU_STYLE_AREA * 0.01f;
size_t LINES = height / lineHeight * DANMAKU_STYLE_AREA * 0.01f;
if (LINES > lineNum) LINES = lineNum;

//取出需要的弹幕
Expand Down Expand Up @@ -750,7 +750,7 @@ void DanmakuCore::draw(NVGcontext *vg, float x, float y, float width, float heig
}
i.speed = (width + i.length) / SECOND;
i.showing = true;
for (int k = 0; k < LINES; k++) {
for (size_t k = 0; k < LINES; k++) {
if (i.type == 4) {
//底部
if (i.time < centerLines[LINES - k - 1]) continue;
Expand Down Expand Up @@ -810,14 +810,14 @@ void WebMask::parseHeader2(const std::string &text) {

sliceList.reserve(length);
uint64_t time, offset, currentOffset = 0;
for (size_t i = 0; i < length; i++) {
for (int32_t i = 0; i < length; i++) {
std::memcpy(&time, text.data() + currentOffset, sizeof(uint64_t));
std::memcpy(&offset, text.data() + currentOffset + 8, sizeof(uint64_t));
time = ntohll(time);
offset = ntohll(offset);
sliceList.emplace_back(time, offset, 0);
if (i != 0) sliceList[i - 1].offsetEnd = offset;
if (i == length - 1) sliceList[i].offsetEnd = -1;
if (i == length - 1) sliceList[i].offsetEnd = 0xFFFFFFFFFFFFFFFF;
currentOffset += 16;
}

Expand Down Expand Up @@ -868,7 +868,7 @@ const MaskSlice &WebMask::getSlice(size_t index) {
// 解压分片数据
std::string data;
try {
if (slice.offsetEnd == -1) slice.offsetEnd = text.size() + offset;
if (slice.offsetEnd == 0xFFFFFFFFFFFFFFFF) slice.offsetEnd = text.size() + offset;
data = wiliwili::decompressGzipData(
text.substr(slice.offsetStart - offset, slice.offsetEnd - slice.offsetStart));
} catch (const std::runtime_error &e) {
Expand Down
8 changes: 4 additions & 4 deletions wiliwili/source/view/grid_dropdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void TextDataSourceDropdown::clearData() { this->data.clear(); }

/// BaseDropdown

BaseDropdown::BaseDropdown(const std::string& title, ValueSelectedEvent::Callback cb, int selected)
BaseDropdown::BaseDropdown(const std::string& title, ValueSelectedEvent::Callback cb, size_t selected)
: cb(std::move(cb)), selected(selected) {
this->inflateFromXMLRes("xml/views/grid_dropdown.xml");
this->title->setText(title);
Expand All @@ -110,8 +110,8 @@ BaseDropdown::BaseDropdown(const std::string& title, ValueSelectedEvent::Callbac
RecyclingGrid* BaseDropdown::getRecyclingList() { return recycler; }

void BaseDropdown::setDataSource(DataSourceDropdown* dataSource) {
// 当设置的选中项为 -1 时,表示不选中任何项,但是焦点位于第一项
recycler->setDefaultCellFocus(selected == -1 ? 0 : selected);
// 当设置的选中项为 0xFFFFFFFF (-1) 时,表示不选中任何项,但是焦点位于第一项
recycler->setDefaultCellFocus(selected == 0xFFFFFFFF ? 0 : selected);
recycler->setDataSource(dataSource);

brls::Style style = brls::Application::getStyle();
Expand Down Expand Up @@ -142,7 +142,7 @@ size_t BaseDropdown::getSelected() const { return this->selected; }
ValueSelectedEvent::Callback BaseDropdown::getSelectCallback() { return this->cb; }

BaseDropdown* BaseDropdown::text(const std::string& title, const std::vector<std::string>& values,
ValueSelectedEvent::Callback cb, int selected, const std::string& hint) {
ValueSelectedEvent::Callback cb, size_t selected, const std::string& hint) {
auto* dropdown = new BaseDropdown(title, std::move(cb), selected);
dropdown->getRecyclingList()->registerCell("Cell", []() {
auto* cell = new GridRadioCell();
Expand Down

0 comments on commit c3ae64c

Please sign in to comment.