mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-30 15:32:38 +00:00
Merge branch 'main' into beta
This commit is contained in:
commit
694ec4a86c
@ -5,18 +5,48 @@
|
|||||||
Basic statements:
|
Basic statements:
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
void global_function(int arg1, int arg2,
|
void global_function(int arg1,
|
||||||
int arg3, ...)
|
const int arg2, // You can use "const" preferably
|
||||||
|
const int arg3, ...)
|
||||||
{
|
{
|
||||||
int value;
|
int value;
|
||||||
const int constValue = 0;
|
const int constValue = 0;
|
||||||
|
|
||||||
|
// We prefer to use "var = (condition ? ...: ...)" instead of
|
||||||
|
// "var = condition ? ...: ...;" to make clear about the
|
||||||
|
// ternary operator limits.
|
||||||
|
int conditionalValue1 = (condition ? 1: 2);
|
||||||
|
int conditionalValue2 = (condition ? longVarName:
|
||||||
|
otherLongVarName);
|
||||||
|
|
||||||
|
// If a condition will return, we prefer the "return"
|
||||||
|
// statement in its own line to avoid missing the "return"
|
||||||
|
// keyword when we read code.
|
||||||
|
if (condition)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// You can use braces {} if the condition has multiple lines
|
||||||
|
// or the if-body has multiple lines.
|
||||||
|
if (condition1 ||
|
||||||
|
condition2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (condition) {
|
if (condition) {
|
||||||
...
|
...
|
||||||
|
...
|
||||||
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We prefer to avoid whitespaces between "var=initial_value"
|
||||||
|
// or "var<limit" to see better the "; " separation. Anyway it
|
||||||
|
// can depend on the specific condition/case, etc.
|
||||||
for (int i=0; i<10; ++i) {
|
for (int i=0; i<10; ++i) {
|
||||||
...
|
...
|
||||||
|
// Same case as in if-return.
|
||||||
|
if (condition)
|
||||||
|
break;
|
||||||
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
while (condition) {
|
while (condition) {
|
||||||
@ -61,17 +91,38 @@ Define classes with `CapitalCase` and member functions with `camelCase`:
|
|||||||
```c++
|
```c++
|
||||||
class ClassName {
|
class ClassName {
|
||||||
public:
|
public:
|
||||||
ClassName();
|
ClassName()
|
||||||
|
: m_memberVarA(1),
|
||||||
|
m_memberVarB(2),
|
||||||
|
m_memberVarC(3) {
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~ClassName();
|
virtual ~ClassName();
|
||||||
|
|
||||||
|
// We can return in the same line for getter-like functions
|
||||||
int memberVar() const { return m_memberVar; }
|
int memberVar() const { return m_memberVar; }
|
||||||
void setMemberVar();
|
void setMemberVar();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void protectedMember();
|
virtual void onEvent1() { } // Do nothing functions can be defined as "{ }"
|
||||||
|
virtual void onEvent2() = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_memberVar;
|
int m_memberVarA;
|
||||||
|
int m_memberVarB;
|
||||||
|
int m_memberVarC;
|
||||||
|
int m_memberVarD = 4; // We can initialize variables here too
|
||||||
|
};
|
||||||
|
|
||||||
|
class Special : public ClassName {
|
||||||
|
public:
|
||||||
|
Special();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void onEvent2() override {
|
||||||
|
...
|
||||||
|
}
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite Document Library
|
// Aseprite Document Library
|
||||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
// Copyright (C) 2019-2021 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2016 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
@ -172,7 +172,8 @@ bool Remap::isFor8bit() const
|
|||||||
bool Remap::isInvertible(const PalettePicks& usedEntries) const
|
bool Remap::isInvertible(const PalettePicks& usedEntries) const
|
||||||
{
|
{
|
||||||
PalettePicks picks(size());
|
PalettePicks picks(size());
|
||||||
for (int i=0; i<size(); ++i) {
|
const int n = std::min(size(), usedEntries.size());
|
||||||
|
for (int i=0; i<n; ++i) {
|
||||||
if (!usedEntries[i])
|
if (!usedEntries[i])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user